Rotation fix (I think)
This commit is contained in:
parent
1892a1cdbd
commit
f426237785
@ -33,20 +33,17 @@ def gather_animdata(armature: bpy.types.Armature) -> List[Animation]:
|
||||
anim_data.bone_transforms[armature.parent.name].append(ModelTransform()) #for testing
|
||||
|
||||
for bone in armature.pose.bones:
|
||||
|
||||
xform = ModelTransform()
|
||||
|
||||
|
||||
vt = convert_vector_space(bone.location);
|
||||
|
||||
xform.translation = Vector((vt.x * -1.0, vt.y, vt.z))
|
||||
xform.translation = convert_vector_space(bone.location)
|
||||
xform.translation.x *= -1.0
|
||||
xform.rotation = convert_rotation_space(bone.rotation_quaternion)
|
||||
|
||||
'''
|
||||
xform.translation = bone.location
|
||||
xform.rotation = bone.rotation_quaternion
|
||||
|
||||
xform.rotation.x *= -1.0
|
||||
xform.rotation.y *= -1.0
|
||||
xform.rotation.z *= -1.0
|
||||
|
||||
anim_data.bone_transforms[bone.name].append(xform)
|
||||
'''
|
||||
|
||||
|
||||
return [anim_data]
|
||||
|
||||
|
@ -33,6 +33,9 @@ def gather_models(apply_modifiers: bool, export_target: str) -> List[Model]:
|
||||
else:
|
||||
obj = uneval_obj
|
||||
|
||||
if uneval_obj.type == "ARMATURE":
|
||||
continue
|
||||
|
||||
check_for_bad_lod_suffix(obj)
|
||||
|
||||
local_translation, local_rotation, _ = obj.matrix_local.decompose()
|
||||
@ -44,8 +47,13 @@ def gather_models(apply_modifiers: bool, export_target: str) -> List[Model]:
|
||||
model.transform.rotation = convert_rotation_space(local_rotation)
|
||||
model.transform.translation = convert_vector_space(local_translation)
|
||||
|
||||
print("Adding model: " + model.name)
|
||||
|
||||
if obj.parent is not None:
|
||||
if obj.parent.type == "ARMATURE":
|
||||
|
||||
model.parent = "DummyRoot"
|
||||
|
||||
skeleton = obj.parent
|
||||
|
||||
parent_bone_name = obj.parent_bone
|
||||
@ -80,18 +88,20 @@ def gather_models(apply_modifiers: bool, export_target: str) -> List[Model]:
|
||||
|
||||
models_list.append(model)
|
||||
|
||||
|
||||
|
||||
for bone in skeleton.data.bones:
|
||||
|
||||
model = Model()
|
||||
model.name = bone.name
|
||||
model.model_type = ModelType.NULL
|
||||
model.model_type = ModelType.BONE
|
||||
model.hidden = False
|
||||
|
||||
local_translation, local_rotation, _ = bone.matrix_local.decompose()
|
||||
model.transform.rotation = convert_rotation_space(local_rotation)
|
||||
model.transform.translation = convert_vector_space(local_translation)
|
||||
|
||||
print("Adding bone: " + model.name)
|
||||
|
||||
parent_name = bone.parent
|
||||
if parent_name is not None:
|
||||
model.parent = parent_name
|
||||
@ -102,6 +112,8 @@ def gather_models(apply_modifiers: bool, export_target: str) -> List[Model]:
|
||||
model.parent = None
|
||||
|
||||
models_list.append(model)
|
||||
|
||||
|
||||
|
||||
|
||||
return models_list
|
||||
@ -231,7 +243,7 @@ def create_mesh_geometry(mesh: bpy.types.Mesh, is_skinned : bool) -> List[Geomet
|
||||
def get_model_type(obj: bpy.types.Object) -> ModelType:
|
||||
""" Get the ModelType for a Blender object. """
|
||||
if obj.parent_type == "ARMATURE":
|
||||
return ModelType.SKIN
|
||||
return ModelType.SKIN
|
||||
|
||||
if obj.type in MESH_OBJECT_TYPES:
|
||||
return ModelType.STATIC
|
||||
|
@ -72,6 +72,7 @@ def create_scene(generate_triangle_strips: bool, apply_modifiers: bool, export_t
|
||||
|
||||
|
||||
#now that we've collected all models, we should remap WGHT indices...
|
||||
'''
|
||||
names_to_indices = {}
|
||||
for i,model in enumerate(scene.models):
|
||||
names_to_indices[model.name] = i;
|
||||
@ -82,11 +83,12 @@ def create_scene(generate_triangle_strips: bool, apply_modifiers: bool, export_t
|
||||
for i in range(len(segment.weights)):
|
||||
vgroup_index = segment.weights[i][0]
|
||||
segment.weights[i][0] = names_to_indices[model.vgroups_to_modelnames_map[vgroup_index]]
|
||||
'''
|
||||
|
||||
|
||||
scene.materials = remove_unused_materials(scene.materials, scene.models)
|
||||
|
||||
#scene.anims = gather_animdata(bpy.context.scene.objects["Armature"])
|
||||
scene.anims = gather_animdata(bpy.context.scene.objects["Armature"])
|
||||
|
||||
return scene
|
||||
|
||||
|
@ -28,9 +28,9 @@ def save_scene(output_file, scene: Scene):
|
||||
with msh2.create_child("MODL") as modl:
|
||||
_write_modl(modl, model, index, material_index, scene)
|
||||
|
||||
#with hedr.create_child("ANM2") as anm2: #simple for now
|
||||
# for anim in scene.anims:
|
||||
# _write_anm2(anm2, anim)
|
||||
with hedr.create_child("ANM2") as anm2: #simple for now
|
||||
for anim in scene.anims:
|
||||
_write_anm2(anm2, anim)
|
||||
|
||||
with hedr.create_child("CL1L"):
|
||||
pass
|
||||
@ -129,12 +129,13 @@ def _write_modl(modl: Writer, model: Model, index: int, material_index: Dict[str
|
||||
for segment in model.geometry:
|
||||
with geom.create_child("SEGM") as segm:
|
||||
_write_segm(segm, segment, material_index)
|
||||
|
||||
'''
|
||||
if model.model_type == ModelType.SKIN:
|
||||
with modl.create_child("ENVL") as envl:
|
||||
envl.write_u32(len(scene.models))
|
||||
for i in range(len(scene.models)):
|
||||
envl.write_u32(i)
|
||||
'''
|
||||
|
||||
if model.collisionprimitive is not None:
|
||||
with modl.create_child("SWCI") as swci:
|
||||
@ -165,12 +166,14 @@ def _write_segm(segm: Writer, segment: GeometrySegment, material_index: Dict[str
|
||||
for normal in segment.normals:
|
||||
nrml.write_f32(normal.x, normal.y, normal.z)
|
||||
|
||||
'''
|
||||
if segment.weights is not None:
|
||||
with segm.create_child("WGHT") as wght:
|
||||
wght.write_u32(len(segment.weights) / 4)
|
||||
for weight in segment.weights:
|
||||
wght.write_u32(weight[0])
|
||||
wght.write_f32(weight[1])
|
||||
'''
|
||||
|
||||
if segment.colors is not None:
|
||||
with segm.create_child("CLRL") as clrl:
|
||||
@ -217,7 +220,7 @@ def _write_anm2(anm2: Writer, anim: Animation):
|
||||
cycl.write_u32(1)
|
||||
cycl.write_string(anim.name)
|
||||
|
||||
for _ in range(63 - len(anim.name)):
|
||||
for _ in range(64 - (len(anim.name) + 1)):
|
||||
cycl.write_u8(0)
|
||||
|
||||
cycl.write_f32(10.0) #test framerate
|
||||
|
Loading…
Reference in New Issue
Block a user