From ef025447c95592b34cba1edb0a4835f93abaced7 Mon Sep 17 00:00:00 2001 From: Owl Date: Tue, 26 Aug 2025 12:36:14 -0400 Subject: some small stuff --- __init__.py | 8 +++++--- bck_export.py | 5 +++++ collada_superbmd_export.py | 29 ++++++++++++++++++++++++++--- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/__init__.py b/__init__.py index 998f396..d20580a 100644 --- a/__init__.py +++ b/__init__.py @@ -3,7 +3,7 @@ # https://web.archive.org/web/20210925181415/https://blenderbrew.com/custom-application-templates-in-blender/ # blenxy module -import importlib, bpy +import importlib, bpy, sys # import the submmodules needed # all submodules have a register/unregister function @@ -48,13 +48,15 @@ def unload_blenxy_stuff(dummy): def register(): # print the welcome - print("\nWelcome to Blenxy!\n") + print("\nWelcome to Blenxy!") + print("Running on Blender: %s\n" % (bpy.app.version.__str__())) + # add this function to load_post first bpy.app.handlers.load_post.append(unload_blenxy_stuff) # add the register functions to load_post (old_blenxy_modules) for mod in blenxy_modules: bpy.app.handlers.load_post.append(mod.register) - + # unregister function that blender will call when a new template is loaded def unregister(): diff --git a/bck_export.py b/bck_export.py index 696f9ce..969152e 100644 --- a/bck_export.py +++ b/bck_export.py @@ -234,6 +234,11 @@ def export_bck_func(options, context): # done! blender_funcs.disp_msg("BCK animation \"%s\" written" % (file_ops.get_file_name(options.filepath))) + + print("\nLMAO\n") + print(options.filepath) + print("\nLMAO\n") + return {"FINISHED"} # Stuff down is for the menu appending 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 -- cgit v1.2.3-70-g09d2