From 8dea6fac49286f3a290707830f313677eb4b89a0 Mon Sep 17 00:00:00 2001 From: Will Snyder Date: Sun, 11 Oct 2020 20:52:34 -0400 Subject: [PATCH] Hardcoded open override exporting, coord sys conversions need adjustment --- addons/io_scene_swbf_msh/msh_anim_gather.py | 13 +++++++++++-- addons/io_scene_swbf_msh/msh_model.py | 3 ++- addons/io_scene_swbf_msh/msh_model_gather.py | 3 ++- addons/io_scene_swbf_msh/msh_scene_save.py | 4 ---- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/addons/io_scene_swbf_msh/msh_anim_gather.py b/addons/io_scene_swbf_msh/msh_anim_gather.py index 0b97e97..e525042 100644 --- a/addons/io_scene_swbf_msh/msh_anim_gather.py +++ b/addons/io_scene_swbf_msh/msh_anim_gather.py @@ -34,11 +34,20 @@ def gather_animdata(armature: bpy.types.Armature) -> List[Animation]: for bone in armature.pose.bones: xform = ModelTransform() - xform.translation = convert_vector_space(bone.location) + + + vt = convert_vector_space(bone.location); + + xform.translation = Vector((vt.x * -1.0, vt.y, vt.z)) xform.rotation = convert_rotation_space(bone.rotation_quaternion) + + ''' + xform.translation = bone.location + xform.rotation = bone.rotation_quaternion anim_data.bone_transforms[bone.name].append(xform) - + ''' + return [anim_data] diff --git a/addons/io_scene_swbf_msh/msh_model.py b/addons/io_scene_swbf_msh/msh_model.py index 794a7f4..a855c0c 100644 --- a/addons/io_scene_swbf_msh/msh_model.py +++ b/addons/io_scene_swbf_msh/msh_model.py @@ -2,7 +2,7 @@ saved to a .msh file. """ from dataclasses import dataclass, field -from typing import List, Dict +from typing import List, Dict, Tuple from enum import Enum from mathutils import Vector, Quaternion @@ -34,6 +34,7 @@ class GeometrySegment: material_name: str = "" positions: List[Vector] = field(default_factory=list) + weights: List[Tuple[int, float]] = field(default_factory=List) normals: List[Vector] = field(default_factory=list) colors: List[List[float]] = None texcoords: List[Vector] = field(default_factory=list) diff --git a/addons/io_scene_swbf_msh/msh_model_gather.py b/addons/io_scene_swbf_msh/msh_model_gather.py index 567aa2f..8933304 100644 --- a/addons/io_scene_swbf_msh/msh_model_gather.py +++ b/addons/io_scene_swbf_msh/msh_model_gather.py @@ -44,7 +44,7 @@ def gather_models(apply_modifiers: bool, export_target: str) -> List[Model]: model.transform.translation = convert_vector_space(local_translation) if obj.parent is not None: - if obj.parent.type == "Armature": + if obj.parent.type == "ARMATURE": model.parent = obj.parent.parent.name else: model.parent = obj.parent.name @@ -167,6 +167,7 @@ def create_mesh_geometry(mesh: bpy.types.Mesh) -> List[GeometrySegment]: return new_index + for tri in mesh.loop_triangles: polygons[tri.material_index].add(tri.polygon_index) segments[tri.material_index].triangles.append([ diff --git a/addons/io_scene_swbf_msh/msh_scene_save.py b/addons/io_scene_swbf_msh/msh_scene_save.py index b851713..afc5af4 100644 --- a/addons/io_scene_swbf_msh/msh_scene_save.py +++ b/addons/io_scene_swbf_msh/msh_scene_save.py @@ -222,14 +222,10 @@ def _write_anm2(anm2: Writer, anim: Animation): kfr3.write_u32(21, 21) #basic testing - print(boneName) - for i, xform in enumerate(anim.bone_transforms[boneName]): kfr3.write_u32(i) kfr3.write_f32(xform.translation.x, xform.translation.y, xform.translation.z) - print(xform.translation) - for i, xform in enumerate(anim.bone_transforms[boneName]): kfr3.write_u32(i) kfr3.write_f32(xform.rotation.x, xform.rotation.y, xform.rotation.z, xform.rotation.w)