Hardcoded open override exporting, coord sys conversions need adjustment

This commit is contained in:
Will Snyder 2020-10-11 20:52:34 -04:00
parent 603068b5b5
commit 8dea6fac49
4 changed files with 15 additions and 8 deletions

View File

@ -34,10 +34,19 @@ def gather_animdata(armature: bpy.types.Armature) -> List[Animation]:
for bone in armature.pose.bones: for bone in armature.pose.bones:
xform = ModelTransform() 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.rotation = convert_rotation_space(bone.rotation_quaternion)
'''
xform.translation = bone.location
xform.rotation = bone.rotation_quaternion
anim_data.bone_transforms[bone.name].append(xform) anim_data.bone_transforms[bone.name].append(xform)
'''
return [anim_data] return [anim_data]

View File

@ -2,7 +2,7 @@
saved to a .msh file. """ saved to a .msh file. """
from dataclasses import dataclass, field from dataclasses import dataclass, field
from typing import List, Dict from typing import List, Dict, Tuple
from enum import Enum from enum import Enum
from mathutils import Vector, Quaternion from mathutils import Vector, Quaternion
@ -34,6 +34,7 @@ class GeometrySegment:
material_name: str = "" material_name: str = ""
positions: List[Vector] = field(default_factory=list) positions: List[Vector] = field(default_factory=list)
weights: List[Tuple[int, float]] = field(default_factory=List)
normals: List[Vector] = field(default_factory=list) normals: List[Vector] = field(default_factory=list)
colors: List[List[float]] = None colors: List[List[float]] = None
texcoords: List[Vector] = field(default_factory=list) texcoords: List[Vector] = field(default_factory=list)

View File

@ -44,7 +44,7 @@ def gather_models(apply_modifiers: bool, export_target: str) -> List[Model]:
model.transform.translation = convert_vector_space(local_translation) model.transform.translation = convert_vector_space(local_translation)
if obj.parent is not None: if obj.parent is not None:
if obj.parent.type == "Armature": if obj.parent.type == "ARMATURE":
model.parent = obj.parent.parent.name model.parent = obj.parent.parent.name
else: else:
model.parent = obj.parent.name model.parent = obj.parent.name
@ -167,6 +167,7 @@ def create_mesh_geometry(mesh: bpy.types.Mesh) -> List[GeometrySegment]:
return new_index return new_index
for tri in mesh.loop_triangles: for tri in mesh.loop_triangles:
polygons[tri.material_index].add(tri.polygon_index) polygons[tri.material_index].add(tri.polygon_index)
segments[tri.material_index].triangles.append([ segments[tri.material_index].triangles.append([

View File

@ -222,14 +222,10 @@ def _write_anm2(anm2: Writer, anim: Animation):
kfr3.write_u32(21, 21) #basic testing kfr3.write_u32(21, 21) #basic testing
print(boneName)
for i, xform in enumerate(anim.bone_transforms[boneName]): for i, xform in enumerate(anim.bone_transforms[boneName]):
kfr3.write_u32(i) kfr3.write_u32(i)
kfr3.write_f32(xform.translation.x, xform.translation.y, xform.translation.z) kfr3.write_f32(xform.translation.x, xform.translation.y, xform.translation.z)
print(xform.translation)
for i, xform in enumerate(anim.bone_transforms[boneName]): for i, xform in enumerate(anim.bone_transforms[boneName]):
kfr3.write_u32(i) kfr3.write_u32(i)
kfr3.write_f32(xform.rotation.x, xform.rotation.y, xform.rotation.z, xform.rotation.w) kfr3.write_f32(xform.rotation.x, xform.rotation.y, xform.rotation.z, xform.rotation.w)