Zaslal: if.then
Popis: Můj export skript. Bohužel v něm špatně fungují kosti :-(
Jazyk: Python
Vloženo: 3.2.2010, 17:43
Stáhnout jako soubor
#!BPY """ Name: 'Ifthen triple D (.itd)' Blender: 244 Group: 'Export' Tooltip: 'File format like .obj' """ import Blender import bpy def write_bone(bone,out): out.write("b n "+bone.name+"\n") out.write("b h") for i in [0,1,2]: head = (bone.head["ARMATURESPACE"][i]) if bone.hasParent(): parentTail = (bone.parent.tail["ARMATURESPACE"][i]) out.write(" %f"%((parentTail)-(head))) else: out.write(" %f"%(head)) out.write("\n") out.write("b t") for i in [0,1,2]: head = (bone.head["ARMATURESPACE"][i]) tail = (bone.tail["ARMATURESPACE"][i]) out.write(" %f"%(-((head)-(tail)))) out.write("\n") out.write("b l %f\n" % (bone.length)) if bone.hasParent(): out.write("b p "+bone.parent.name+"\n") else: out.write("b r x\n") for bonechild in bone.children: write_bone(bonechild,out) def write_itd(filename): out = file(filename, "w") sce = bpy.data.scenes.active materials = bpy.data.materials for mat in materials: out.write("m n "+(mat.name)+"\n") for mattex in mat.getTextures(): if mattex!=None: if(mattex.tex.getImage()!=None): out.write("m t "+mattex.tex.getName()+"\n") out.write("m f "+mattex.tex.getImage().getName()+"\n") for ob in sce.objects: out.write("o n "+(ob.name)+"\n") out.write("o t "+(ob.type)+"\n") out.write("o p") for i in [0,1,2]: out.write( " %f" % (ob.loc[i])) out.write("\n") out.write("o s") for i in [0,1,2]: out.write( " %f" % (ob.size[i])) out.write("\n") out.write("o r") for i in [0,1,2]: out.write( " %f" % (ob.rot[i]*180/3.14159265)) out.write("\n") if ob.type=="Mesh": mesh = ob.getData(mesh=1) for meshMat in mesh.materials: if meshMat!=None: out.write("o m "+meshMat.name+"\n") break; for vert in mesh.verts: out.write( "v %f %f %f\n" % (vert.co.x, vert.co.y, vert.co.z) ) for bonedata in mesh.getVertexInfluences(vert.index): out.write("i "+bonedata[0]+(" %f\n" % (bonedata[1]))) for face in mesh.faces: out.write("f") for vertnum in range(3): out.write(" %i" % (face.verts[vertnum].index + 1) ) out.write("\n") if mesh.faceUV: out.write("c") for vertnum in range (3): out.write(" %f %f" % (face.uv[vertnum][0],face.uv[vertnum][1])) out.write("\n"); if ob.type=="Armature": arm_data = ob.getData() bones = arm_data.bones.values() for bone in bones: if not bone.hasParent(): write_bone(bone,out); out.close() Blender.Window.FileSelector(write_itd, "Export",".blender\something.itd")
© 2006 Michal Tuláček, Syntax Highlight - GeSHi (thx bref)
