summaryrefslogtreecommitdiff
path: root/collada_superbmd_export.py
diff options
context:
space:
mode:
Diffstat (limited to 'collada_superbmd_export.py')
-rw-r--r--collada_superbmd_export.py29
1 files changed, 26 insertions, 3 deletions
diff --git a/collada_superbmd_export.py b/collada_superbmd_export.py
index f1b1486..1afae87 100644
--- a/collada_superbmd_export.py
+++ b/collada_superbmd_export.py
@@ -35,6 +35,19 @@ def write_bmd_bdl_collada(context, filepath, triangulate):
blender_funcs.disp_msg("\"%s\": contains non-mesh object (%s)." % (armature.name, child.name))
return {"FINISHED"}
+ # check if there is a single "root level" bone
+ # SuperBMD/SMG needs a sigle root bone and the rest must be added as a child to that bone
+ bone_with_no_parent_found = False
+ for bone in armature.data.bones:
+ # the root bone has been found
+ if (bone.parent == None):
+ if (bone_with_no_parent_found == False):
+ bone_with_no_parent_found = True
+ else: # second root bone?
+ blender_funcs.disp_msg("\"%s\": has 2 or more root level bones (max is 1)."
+ % (armature.name, child.name))
+ return {"FINISHED"}
+
# check if all meshes have an armature modifier that is
# assigned to the armature object and it is binded to
# vertex groups if none of those are just create them,
@@ -62,15 +75,25 @@ def write_bmd_bdl_collada(context, filepath, triangulate):
for mesh in armature.children:
for v_group in mesh.vertex_groups:
if (v_group.name not in bone_name_list):
- blender_funcs.disp_msg(("\"%s\": contains non-valid vert group \"%s\"." % (mesh.name, v_group.name))
+ blender_funcs.disp_msg(("\"%s\": contains non-valid vertex group \"%s\"." % (mesh.name, v_group.name))
+ " Unable to continue.")
return {"FINISHED"}
+
# vertex weight check
for mesh in armature.children:
for vertex in mesh.data.vertices:
+ # check if the vertex is assigned to at least a single vertex group
if (len(vertex.groups) == 0):
- blender_funcs.disp_msg(("\"%s\": contains unweighted vertices."
- % (mesh.name)) + " Unable to continue.")
+ blender_funcs.disp_msg(("\"%s\": contains unweighted vertices." % (mesh.name))
+ + " Unable to continue.")
+ return {"FINISHED"}
+ # check if vertex weights are normalized
+ vertex_weight = 0
+ for group in vertex.groups:
+ vertex_weight += group.weight
+ if (vertex_weight > 1.0):
+ blender_funcs.disp_msg(("\"%s\": contains non normalized weight in vertices." % (mesh.name))
+ + " Unable to continue.")
return {"FINISHED"}
# get the object names