summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsaac <isaclien9752@gmail.com>2024-02-15 11:10:17 -0400
committerIsaac <isaclien9752@gmail.com>2024-02-15 11:10:17 -0400
commitb907bcc414eb742f45e2a0c2ea0232256c226a92 (patch)
treefde04737c0c797e9d0b7bf37d1bce69570ba20ad
parentdac44c77fa7442fbae53795a8bde09bcd587f60d (diff)
downloadblenxy-b907bcc414eb742f45e2a0c2ea0232256c226a92.tar.gz
blenxy-b907bcc414eb742f45e2a0c2ea0232256c226a92.zip
small *fix* for some bones not being imported
-rw-r--r--README.md7
-rw-r--r--blenxy_settings_stuff.py2
-rw-r--r--collada_bmd_bdl_export.py5
-rw-r--r--collada_bmd_bdl_import.py79
4 files changed, 83 insertions, 10 deletions
diff --git a/README.md b/README.md
index 205250b..83b4d02 100644
--- a/README.md
+++ b/README.md
@@ -8,6 +8,9 @@ https://humming-owl.neocities.org/smg-stuff/pages/tutorials/t8.html
- CSV Exporter has issues with equivalent keyframes/rotation angles close to -180/+180 degrees (think a fix).
- DAE importer to apply textures to model on import.
+- Think on the possibility of a BTP Importer/Exporter.
+- Add a OBJ exporter/importer for collision models (for conversion to KCL and PA).
+- Rely less on blender's DAE importer/exporter (basically make my own, but I have no clue how cuz currently I have skill issue)
- ...
# Features
@@ -41,3 +44,7 @@ If you want to contribute or report an issue open a new issue in **Issues**. I w
- RenolY2 for J3DView and SuperBMD.
- The authors of the material I could read about BMD/BDL.
- The many stackoverflow threads (or similar) in which Blender Python API issues are discussed.
+
+# Changelog
+
+-
diff --git a/blenxy_settings_stuff.py b/blenxy_settings_stuff.py
index 0c5602c..9636522 100644
--- a/blenxy_settings_stuff.py
+++ b/blenxy_settings_stuff.py
@@ -95,7 +95,7 @@ print("\nExtra stuff to set...")
bpy.context.scene.world.light_settings.use_environment_light = True
# set framerate (SMG runs at 59.94 fps in THP videos)
-# need to check if it is the same for BCK animations
+# BTP animations do run (or at least ideally run) at an aproximate of 60fps
bpy.context.scene.render.fps = 60
bpy.context.scene.render.fps_base = 1.001
diff --git a/collada_bmd_bdl_export.py b/collada_bmd_bdl_export.py
index 4907a73..30bca40 100644
--- a/collada_bmd_bdl_export.py
+++ b/collada_bmd_bdl_export.py
@@ -2,7 +2,7 @@
just a DAE exporter.
it was supposed to only rotate the meshes around the X axis by -90 degrees
but above that it now checks for armature and vertex group stuff
-only exports what is selected
+only exports an armature object selection
'''
import bpy, math
@@ -101,6 +101,9 @@ def write_bmd_bdl_collada(context, filepath, triangulate):
object.select = True
scene.objects.active = object
+ # change mesh to object view (in case it isn't)
+ bpy.ops.object.mode_set(mode='OBJECT')
+
# reset scale, rotation and position of the mesh
bpy.ops.object.transform_apply(location = True, rotation = True, scale = True)
diff --git a/collada_bmd_bdl_import.py b/collada_bmd_bdl_import.py
index 9187193..8894af6 100644
--- a/collada_bmd_bdl_import.py
+++ b/collada_bmd_bdl_import.py
@@ -262,7 +262,7 @@ def read_bmd_bdl_collada(context, filepath, debug_messages, show_armature_pose):
[a[4], a[5], a[6], a[7]],
[a[8], a[9], a[10], a[11]],
[a[12], a[13], a[14], a[15]]
- ))
+ )).normalized()
controller_data[i].append(matrix)
@@ -323,7 +323,7 @@ def read_bmd_bdl_collada(context, filepath, debug_messages, show_armature_pose):
[a[4], a[5], a[6], a[7]],
[a[8], a[9], a[10],a[11]],
[a[12], a[13],a[14],a[15]]
- ))
+ )).normalized()
# append matrix to temp_matrices
temp_matrices.append(temp_matrix)
@@ -392,7 +392,7 @@ def read_bmd_bdl_collada(context, filepath, debug_messages, show_armature_pose):
[a[1], a[5], a[9], a[13]],
[a[2], a[6], a[10], a[14]],
[a[3], a[7], a[11], a[15]]
- ))
+ )).normalized()
###########
# bone data
@@ -478,8 +478,12 @@ def read_bmd_bdl_collada(context, filepath, debug_messages, show_armature_pose):
[a[4], a[5], a[6], a[7]],
[a[8], a[9], a[10], a[11]],
[a[12], a[13], a[14], a[15]]
- ))
-
+ )).normalized()
+ if (bone_matrix.determinant() == 0):
+ bone_matrix = Matrix(([1, 0, 0, 0],
+ [0, 1, 0, 0],
+ [0, 0, 1, 0],
+ [0, 0, 0, 1]))
rest_matrices.append(bone_matrix)
@@ -688,7 +692,7 @@ def read_bmd_bdl_collada(context, filepath, debug_messages, show_armature_pose):
# bone_parenting_diagram[i][j] == 1 returns True
# bone found, create it and assign name
- bpy.ops.armature.bone_primitive_add(name = bones_array[i])
+ bpy.ops.armature.bone_primitive_add(name = bones_array[i])
# find parent bone
# read the rows above the bone row to find its parent
@@ -717,7 +721,8 @@ def read_bmd_bdl_collada(context, filepath, debug_messages, show_armature_pose):
# apply transformation matrix (bind matrix)
armature.data.edit_bones[bones_array[i]].matrix = bind_matrices[i]
- break
+ break
+
# leave edit mode
bpy.ops.object.mode_set(mode='OBJECT')
@@ -775,7 +780,7 @@ def read_bmd_bdl_collada(context, filepath, debug_messages, show_armature_pose):
# armature has finished being built
- print("Re-build done!")
+ print("Re-build done!")
# assign meshes from old armature into new armature
# also reconect mesh's armature modifiers to the new armature
@@ -1004,7 +1009,65 @@ def read_bmd_bdl_collada(context, filepath, debug_messages, show_armature_pose):
elif (show_armature_pose == "OPT_C"):
print("Ignore Rest Pose done!")
+
+ # ~ ####################
+ # ~ # add model textures
+ # ~ ####################
+
+ # ~ # will search for textures in the same place the DAE file is
+ # ~ # if they are not there the program won't do anything
+
+ # ~ print("Getting Texture data...")
+ # ~ mat_json_path = filepath.split(".dae")[0] + "_materials.json"
+ # ~ print(mat_json_path)
+
+ # ~ # open materials JSON
+ # ~ f = open(mat_json_path, 'r', encoding='utf-8')
+
+ # ~ for i in range(len(armature.children)):
+ # ~ while True:
+ # ~ line = f.readline()
+ # ~ # material data start
+ # ~ if (line.find("\"Name\":") + 1):
+
+ # ~ # get mat name
+ # ~ mat_name = re.search(': "(.+?)",', line).group(1)
+
+ # ~ # find material along the
+
+
+ # ~ # get textures associated with this material
+ # ~ while True:
+ # ~ line = f.readline()
+ # ~ tex_name = "dummy"
+ # ~ if (line.find("\"TextureNames\":") + 1):
+ # ~ while (tex_name != ""):
+ # ~ tex_name = re.search('"(.+?)",', f.readline()).group(1)
+ # ~ break
+ # ~ break
+ # ~ break
+
+
+ # ~ for mesh in armature.children:
+ # ~ for i in range(len(mesh.data.materials)):
+ # ~ mesh.active_material_index = i
+ # ~ tex_slot = mesh.data.materials[i].texture_slots.add()
+ # ~ bpy.ops.texture.new() # create new texture
+ # ~ tex_slot.texture = bpy.data.textures[-1]
+
+ # ~ while True:
+
+ # ~ line = f.readline()
+
+ # ~ #########################
+ # ~ # controller start
+ # ~ # the skin stuff for each
+ # ~ # mesh is defined there
+ # ~ #########################
+ # ~ if (line.find("<controller") + 1):
+
# end importer
+ print("Done importing!")
return {'FINISHED'}