Skip to content

Commit

Permalink
First work on #9
Browse files Browse the repository at this point in the history
Tested so far:
* DQ component values correspond between Blender and SMF, though differ in a minus sign for a still unknown reason
* All matrices that are actually written/converted to DQ in Blender seem to be orthogonal, i.e. the vectors in the upper-left 3x3 submatrix are orthogonal

This can probably work and needs further looking into.
  • Loading branch information
bartteunis committed Mar 31, 2022
1 parent 544dfc1 commit c776312
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion export_smf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SMF export scripts for Blender
#
#from .pydq import dq_create_matrix_vector, dq_to_tuple_smf
from .pydq import dq_create_matrix, dq_to_tuple_xyzw
import bpy
from struct import Struct, pack, calcsize
from mathutils import *
Expand Down Expand Up @@ -422,6 +422,13 @@ def write_animation_data(name, scene, byte_data, rig_object, keyframe_times, fra

mat.translation = bone.tail[:]
mat_final = apply_world_matrix(mat, rig_object.matrix_world)
mat_final.normalize()
m = mat_final.to_3x3()
dq = dq_create_matrix(mat_final)
print(m)
print(dq_to_tuple_xyzw(dq))
# print(m.is_orthogonal)
# print(m.is_orthogonal_axis_vectors)
vals = [j for i in mat_final.col for j in i]
byte_data.extend(pack('f'*16, *vals))

Expand Down

0 comments on commit c776312

Please # to comment.