io.write("}\r\n") \r
\r
def __write_object(self, io, info, scene):\r
- #print(info)\r
+ print(info)\r
\r
obj=info.object\r
- if obj.type.upper()!='MESH':\r
+ if obj.type.upper()=='MESH' or obj.type.upper()=='EMPTY':\r
+ pass\r
+ else:\r
+ print(obj.type)\r
return\r
\r
- # duplicate and applyMatrix\r
- mesh, dumy=bl.objectDuplicate(scene, obj)\r
-\r
############################################################\r
# write\r
############################################################\r
io.write("\tmirror 1\r\n")\r
io.write("\tmirror_axis 1\r\n")\r
\r
- # vertices\r
- io.write("\tvertex %d {\r\n" % len(mesh.verts))\r
- for vert in mesh.verts:\r
- x, y, z = convert_to_mqo(vert.co)\r
- io.write("\t\t%f %f %f\r\n" % \r
- (x*self.scale, y*self.scale, z*self.scale)) # rotate to y-up\r
- io.write("\t}\r\n")\r
-\r
- # faces\r
- io.write("\tface %d {\r\n" % len(mesh.faces))\r
- for i, face in enumerate(mesh.faces):\r
- count=bl.faceVertexCount(face)\r
- # V\r
- io.write("\t\t%d V(" % count)\r
- face_list=[]\r
- for j in bl.faceVertices(face):\r
- face_list.insert(0, j)\r
- # flip face\r
- for j in face_list:\r
- io.write("%d " % j)\r
- io.write(")")\r
- # mat\r
- if len(mesh.materials):\r
- io.write(" M(%d)" % \r
- info.material_map[bl.faceMaterialIndex(face)])\r
- # UV\r
- if bl.meshHasUV(mesh) and bl.faceHasUV(mesh, i, face):\r
- io.write(" UV(")\r
- uv_list=[]\r
- for uv in bl.faceGetUV(mesh, i, face, count):\r
- # reverse vertical value\r
- uv_list.insert(0, uv)\r
+ if obj.type.upper()=='MESH':\r
+ # duplicate and applyMatrix\r
+ mesh, dumy=bl.objectDuplicate(scene, obj)\r
+\r
+ # vertices\r
+ io.write("\tvertex %d {\r\n" % len(mesh.verts))\r
+ for vert in mesh.verts:\r
+ x, y, z = convert_to_mqo(vert.co)\r
+ io.write("\t\t%f %f %f\r\n" % \r
+ (x*self.scale, y*self.scale, z*self.scale)) # rotate to y-up\r
+ io.write("\t}\r\n")\r
+\r
+ # faces\r
+ io.write("\tface %d {\r\n" % len(mesh.faces))\r
+ for i, face in enumerate(mesh.faces):\r
+ count=bl.faceVertexCount(face)\r
+ # V\r
+ io.write("\t\t%d V(" % count)\r
+ face_list=[]\r
+ for j in bl.faceVertices(face):\r
+ face_list.insert(0, j)\r
# flip face\r
- for uv in uv_list:\r
- io.write("%f %f " % (uv[0], 1.0-uv[1])) \r
+ for j in face_list:\r
+ io.write("%d " % j)\r
io.write(")")\r
- io.write("\r\n")\r
- io.write("\t}\r\n") # end of faces\r
- io.write("}\r\n") # end of object\r
- ############################################################\r
+ # mat\r
+ if len(mesh.materials):\r
+ io.write(" M(%d)" % \r
+ info.material_map[bl.faceMaterialIndex(face)])\r
+ # UV\r
+ if bl.meshHasUV(mesh) and bl.faceHasUV(mesh, i, face):\r
+ io.write(" UV(")\r
+ uv_list=[]\r
+ for uv in bl.faceGetUV(mesh, i, face, count):\r
+ # reverse vertical value\r
+ uv_list.insert(0, uv)\r
+ # flip face\r
+ for uv in uv_list:\r
+ io.write("%f %f " % (uv[0], 1.0-uv[1])) \r
+ io.write(")")\r
+ io.write("\r\n")\r
+ io.write("\t}\r\n") # end of faces\r
+\r
+ # 削除する\r
+ scene.objects.unlink(dumy)\r
\r
- # 削除する\r
- scene.objects.unlink(dumy)\r
+ io.write("}\r\n") # end of object\r
\r
\r
def __execute(filename, scene, scale=10):\r
RIGID_ANGULAR_DAMPING='rigid_angular_damping'
RIGID_RESTITUTION='rigid_restitution'
RIGID_FRICTION='rigid_friction'
+CONSTRAINT_NAME='constraint_name'
CONSTRAINT_A='const_a'
CONSTRAINT_B='const_b'
CONSTRAINT_POS_MIN='const_pos_min'
material=bl.createMaterial('constraint')
material.diffuse_color=(1, 0, 0)
constraintMeshes=[]
- for c in io.constraints:
+ for i, c in enumerate(io.constraints):
bpy.ops.mesh.primitive_uv_sphere_add(
segments=8,
rings=4,
constraintMeshes.append(meshObject)
mesh=bl.objectGetData(meshObject)
bl.meshAddMaterial(mesh, material)
- meshObject.name='c'+c.getName()
+ meshObject.name='c_%d' % i
#meshObject.draw_transparent=True
#meshObject.draw_wire=True
meshObject.max_draw_type='SOLID'
rot=c.rot
meshObject.rotation_euler=(-rot.x, -rot.z, -rot.y)
+ meshObject[CONSTRAINT_NAME]=c.getName()
meshObject[CONSTRAINT_A]=io.rigidbodies[c.rigidA].getName()
meshObject[CONSTRAINT_B]=io.rigidbodies[c.rigidB].getName()
meshObject[CONSTRAINT_POS_MIN]=bl.VtoV(c.constraintPosMin)