#!BPY # -------------------------------------------------- # ++++++++++++++++++++++++++++++++++++++++++++++++++ # ================================================== """ Name: 't3d format (*.t3g)' Blender: 125 Group: 'Export' Tooltip: 't3g file' """ # ------------------------------------ # ++++++++++++++++++++++++++++++++++++ # ==================================== __author__ = ["SYT 2008"] __url__ = ("http://starworld.syt.ru") __version__ = "0.1.9" __bpydoc__ = """\ T3g export script. """ # ----------------------- # +++++++++++++++++++++++ # ======================= import Blender # -------------------------- # ++++++++++++++++++++++++++ # ========================== def my_export(filename): # -=((( Otrkoem file dlya zapisi )))=- myfile = open(filename + '.t3g', 'w') myfile.write(". Конвертировано из BLENDERа \n") myfile.write(". СЮТ г. Железногорска \n") myfile.write(". Конвертор версии 0.1.9 beta \n") print 'Ќ з «® ®Ўа Ў®вЄЁ' # -=((( Poluchim spisok obyektov tekushey sceni )))=- MYOBJECTS = Blender.Scene.GetCurrent().getChildren() # -=((( Proydemsa po vsem objektam )))=- # export Meshey myfile.write(" 1 ") kol=0 for object in MYOBJECTS: if object.getType() != 'Mesh': continue mesh = object.getData(); faces = mesh.faces for face in faces: kol=kol # +1 kol=kol +1 myfile.write("%i " % kol) myfile.write(" 0 0 0 0 0 0 \n") # myfile.write(" 2 1 10 1 0 0 0 . center \n") for object in MYOBJECTS: # myfile.write(". ВСЕ!! %s \n" % object.name) if object.getType() == 'Texture': myfile.write(". Texture %s \n" % object.name) if object.getType() != 'Mesh': continue print 'mesh:' + object.name mesh = object.getData(); material = mesh.materials #mesh.transform(object.matrix, True) mesh.transform(object.matrixWorld) #print mesh.center faces = mesh.faces myfile.write(". %s \n" % object.name) Tcol = 7.0 if (not material) : #myfile.write("7") Tcol = 7.0 else : if object.getType() == 'Material': myfile.write(". Material %s \n" % material[0].name) mcol = material[0].rgbCol Rcol = ((round(((mcol[0] *1000) /3.92156862745)/64))*64) Gcol = ((round(((mcol[1] *1000) /3.92156862745)/64))*64) Bcol = ((round(((mcol[2] *1000) /3.92156862745)/64))*64) if (Bcol == 64.0) : Bcol = 0 if (Gcol == 64.0) : Gcol = 0.0 if (Rcol == 64.0) : Rcol = 0.0 if (Rcol == 0.0) & (Gcol == 0.0) & (Bcol == 0.0) : Tcol = 0.0 if (Rcol == 0.0) & (Gcol == 0.0) & (Bcol == 128.0) & (Bcol <= 192.0) : Tcol = 1.0 if (Rcol == 0.0) & (Gcol == 128.0) & (Gcol <= 128.0) & (Bcol == 0.0) : Tcol = 2.0 if (Rcol == 0.0) & (Gcol == 128.0) & (Bcol == 128.0) & (Gcol <= 192.0) & (Bcol <= 192.0) : Tcol = 3.0 if (Rcol == 128.0) & (Rcol <= 192.0) & (Gcol == 0.0) & (Bcol == 0.0) : Tcol = 4.0 if (Rcol == 128.0) & (Rcol <= 192.0) & (Gcol == 0.0) & (Bcol == 128.0) & (Bcol <= 192.0) : Tcol = 5.0 if (Rcol >= 128.0) & (Gcol >= 128.0) & (Rcol <> 0.0) & (Gcol <> 0.0) & (Bcol == 0.0) : Tcol = 6.0 if (Rcol == 192.0) & (Gcol == 192.0) & (Bcol == 192.0) : Tcol = 7.0 if (Rcol >= 128.0) & (Gcol >= 128.0) & (Bcol >= 128.0) : Tcol = 8.0 if (Rcol <= 192.0) & (Gcol <= 192.0) & (Bcol >= 192.0) : Tcol = 9.0 if (Rcol <= 192.0) & (Gcol >= 192.0) & (Bcol <= 192.0) : Tcol = 10.0 if (Rcol <= 192.0) & (Gcol >= 192.0) & (Bcol >= 192.0) : Tcol = 11.0 if (Rcol >= 192.0) & (Gcol <= 192.0) & (Bcol <= 192.0) : Tcol = 12.0 if (Rcol >= 192.0) & (Gcol <= 192.0) & (Bcol >= 192.0) : Tcol = 13.0 if (Rcol >= 192.0) & (Gcol >= 192.0) & (Bcol <= 192.0) : Tcol = 14.0 if (Rcol >= 192.0) & (Gcol >= 192.0) & (Bcol >= 192.0) : Tcol = 15.0 for face in faces: #if (len(face.v)=2): myfile.write(" 2 4 %i " % (Tcol)) myfile.write("%i " % len(face.v)) K=len(face.v) #k=k+1 II=0 while K>0: X=face.v[II].co[0]*20 Y=face.v[II].co[1]*20 Z=face.v[II].co[2]*20 myfile.write("%f %f %f " % ((X),(Y),(Z))) K=K-1 II=II+1 myfile.write("\n") # export Lamp for object in MYOBJECTS: if object.getType() != 'Lamp': continue print 'lamp:' + object.name # export Camer for object in MYOBJECTS: if object.getType() != 'Camera': continue print 'camera:' + object.name # myfile.write(". Список всех объектов") for object in MYOBJECTS: myfile.write(". %s \n" % object.name) myfile.close() # -------------------------------------------- # ++++++++++++++++++++++++++++++++++++++++++++ # ============================================ Blender.Window.FileSelector(my_export, "Export to t3g file")