|
@@ -204,6 +204,24 @@ def buffer_normal(mesh, options):
|
|
return normals_
|
|
return normals_
|
|
|
|
|
|
|
|
|
|
|
|
+@_mesh
|
|
|
|
+def buffer_face_material(mesh, options):
|
|
|
|
+ """
|
|
|
|
+
|
|
|
|
+ :param mesh:
|
|
|
|
+ :rtype: []
|
|
|
|
+
|
|
|
|
+ """
|
|
|
|
+ face_material = []
|
|
|
|
+ logger.info("Retrieving face materials.")
|
|
|
|
+
|
|
|
|
+ for face in mesh.tessfaces:
|
|
|
|
+ #logger.info("face:%d,%d",face.index,face.material_index)
|
|
|
|
+ face_material.append(face.material_index)
|
|
|
|
+
|
|
|
|
+ return face_material
|
|
|
|
+
|
|
|
|
+
|
|
@_mesh
|
|
@_mesh
|
|
def buffer_position(mesh, options):
|
|
def buffer_position(mesh, options):
|
|
"""
|
|
"""
|
|
@@ -692,9 +710,15 @@ def materials(mesh, options):
|
|
return []
|
|
return []
|
|
|
|
|
|
indices = []
|
|
indices = []
|
|
- for face in mesh.tessfaces:
|
|
|
|
- if face.material_index not in indices:
|
|
|
|
- indices.append(face.material_index)
|
|
|
|
|
|
+
|
|
|
|
+ #manthrax: Disable the following logic that attempts to find only the used materials on this mesh
|
|
|
|
+ #for face in mesh.tessfaces:
|
|
|
|
+ # if face.material_index not in indices:
|
|
|
|
+ # indices.append(face.material_index)
|
|
|
|
+ # instead, export all materials on this object... they are probably there for a good reason, even if they aren't referenced by the geometry at present...
|
|
|
|
+ for index in range(len( mesh.materials )):
|
|
|
|
+ indices.append(index)
|
|
|
|
+
|
|
|
|
|
|
material_sets = [(mesh.materials[index], index) for index in indices]
|
|
material_sets = [(mesh.materials[index], index) for index in indices]
|
|
materials_ = []
|
|
materials_ = []
|
|
@@ -1198,10 +1222,12 @@ def _armature(mesh):
|
|
"""
|
|
"""
|
|
obj = object_.objects_using_mesh(mesh)[0]
|
|
obj = object_.objects_using_mesh(mesh)[0]
|
|
armature = obj.find_armature()
|
|
armature = obj.find_armature()
|
|
- if armature:
|
|
|
|
- logger.info("Found armature %s for %s", armature.name, obj.name)
|
|
|
|
- else:
|
|
|
|
- logger.info("Found no armature for %s", obj.name)
|
|
|
|
|
|
+
|
|
|
|
+ #manthrax: Remove logging spam. This was spamming on every vertex...
|
|
|
|
+ #if armature:
|
|
|
|
+ # logger.info("Found armature %s for %s", armature.name, obj.name)
|
|
|
|
+ #else:
|
|
|
|
+ # logger.info("Found no armature for %s", obj.name)
|
|
return armature
|
|
return armature
|
|
|
|
|
|
|
|
|
|
@@ -1296,6 +1322,7 @@ def _pose_bones(armature):
|
|
bones_.append({
|
|
bones_.append({
|
|
constants.PARENT: bone_index,
|
|
constants.PARENT: bone_index,
|
|
constants.NAME: armature_bone.name,
|
|
constants.NAME: armature_bone.name,
|
|
|
|
+
|
|
constants.POS: (pos.x, pos.z, -pos.y),
|
|
constants.POS: (pos.x, pos.z, -pos.y),
|
|
constants.ROTQ: (rot.x, rot.z, -rot.y, rot.w),
|
|
constants.ROTQ: (rot.x, rot.z, -rot.y, rot.w),
|
|
constants.SCL: (scl.x, scl.z, scl.y)
|
|
constants.SCL: (scl.x, scl.z, scl.y)
|
|
@@ -1326,9 +1353,12 @@ def _rest_bones(armature):
|
|
|
|
|
|
if bone.parent is None:
|
|
if bone.parent is None:
|
|
bone_pos = bone.head_local
|
|
bone_pos = bone.head_local
|
|
|
|
+ logger.debug("Root bone:%s",str(bone_pos))
|
|
bone_index = -1
|
|
bone_index = -1
|
|
else:
|
|
else:
|
|
bone_pos = bone.head_local - bone.parent.head_local
|
|
bone_pos = bone.head_local - bone.parent.head_local
|
|
|
|
+ logger.debug("Child bone:%s",str(bone_pos))
|
|
|
|
+
|
|
bone_index = 0
|
|
bone_index = 0
|
|
index = 0
|
|
index = 0
|
|
for parent in armature.data.bones:
|
|
for parent in armature.data.bones:
|
|
@@ -1337,10 +1367,13 @@ def _rest_bones(armature):
|
|
index += 1
|
|
index += 1
|
|
|
|
|
|
bone_world_pos = armature.matrix_world * bone_pos
|
|
bone_world_pos = armature.matrix_world * bone_pos
|
|
|
|
+
|
|
x_axis = bone_world_pos.x
|
|
x_axis = bone_world_pos.x
|
|
y_axis = bone_world_pos.z
|
|
y_axis = bone_world_pos.z
|
|
z_axis = -bone_world_pos.y
|
|
z_axis = -bone_world_pos.y
|
|
|
|
|
|
|
|
+ logger.debug("Bone pos:%s",str(bone_world_pos))
|
|
|
|
+
|
|
logger.debug("Adding bone %s at: %s, %s",
|
|
logger.debug("Adding bone %s at: %s, %s",
|
|
bone.name, bone_index, bone_index_rel)
|
|
bone.name, bone_index, bone_index_rel)
|
|
bone_map[bone_count] = bone_index_rel
|
|
bone_map[bone_count] = bone_index_rel
|