Titonus
07-09-2005, 10:38 AM
Hi, I'm doing a bone exporter which exports the ID, number of childs and bone's local matrix but I don't know how I can get correctly the bone's keyframes data relative to its parent (rotation: quaternion and translation: position).
Now I do as follows:
...
at time keyFrame.time
(
-- Rotation, we change Y and Z axis (DirectX) and so we use a matrix (mquat)
q = bone.rotation
local mquat=q as matrix3
local row1 = mquat.row1
local row2 = mquat.row2
local row3 = mquat.row3
row1 = switchYZ row1
row2 = switchYZ row2
row3 = switchYZ row3
mquat.row1 = row
mquat.row2 = row
mquat.row3 = row
mquat = inverse mquat
q = mquat as quat
-- Translation, we change Y and Z (DirectX)
p = bone.pos
p.y = bone.pos.z
p.z = bone.pos.y
-- Write output file
format "KeyFrame %\n" keyFrame.time.frame to: file
format "% % % %\n" q.x q.y q.z q.w to: file
format "% % %\n" p.x p.y p.z to: file
)
...
Thanks in advance.
Now I do as follows:
...
at time keyFrame.time
(
-- Rotation, we change Y and Z axis (DirectX) and so we use a matrix (mquat)
q = bone.rotation
local mquat=q as matrix3
local row1 = mquat.row1
local row2 = mquat.row2
local row3 = mquat.row3
row1 = switchYZ row1
row2 = switchYZ row2
row3 = switchYZ row3
mquat.row1 = row
mquat.row2 = row
mquat.row3 = row
mquat = inverse mquat
q = mquat as quat
-- Translation, we change Y and Z (DirectX)
p = bone.pos
p.y = bone.pos.z
p.z = bone.pos.y
-- Write output file
format "KeyFrame %\n" keyFrame.time.frame to: file
format "% % % %\n" q.x q.y q.z q.w to: file
format "% % %\n" p.x p.y p.z to: file
)
...
Thanks in advance.
