Hi KE
I didn't quote your reply, so I hope I get everything clear for you.
The next lot of floats after the skeleton are global position vectors for the bones, so number of frames by number of bones by x, y, z. (I get a lot more than 76 floats here
are you sure you just haven't printed off the first three float values of each frame's worth??). Although the local positon value hasn't changed, you have to remember this is preprocesed to plug into the engine. The only significant one to worry about is the y value for the first bone this give the movement perpendicular to the ground plane.
Next there is number of frames by x and z 'incremental' movement for the first bone (pelvis). This shows you how much the figure moves parallel to the ground plane each frame.
Below is the function I'm using for Quat to Euler conversion :-
Code:
QuatToEuler(a4,a1,a2,a3);data read in from original file - a1,a2,a3,a4
Function QuatToEuler(w#,x#,y#,z#)
Local sint#, cost#, sinv#, cosv#, sinf#, cosf#
Local cost_temp#
sint = (2 * w * y) - (2 * x *z)
cost_temp = 1.0 - (sint * sint)
If Abs(cost_temp) > QuatToEulerAccuracy
cost = Sqr(cost_temp)
Else
cost = 0
EndIf
If Abs(cost) > QuatToEulerAccuracy
sinv = ((2 * y * z) + (2 * w * x)) / cost
cosv = (1 - (2 * x * x) - (2 * y * y)) / cost
sinf = ((2 * x * y) + (2 * w * z)) / cost
cosf = (1 - (2 * y * y) - (2 * z * z)) / cost
Else
sinv = (2 * w * x) - (2 * y * z)
cosv = 1 - (2 * x * x) - (2 * z * z)
sinf = 0
cosf = 1
EndIf
; Generate the output rotation
roll# = -ATan2(sinv, cosv) ; inverted due to change in handedness of coordinate system
pitch# = ATan2(sint, cost)
yaw# = ATan2(sinf, cosf)
End Function
Don't worry about the QuatToEulerAccuracy, I thought it was a bit fancy-shmancy, so I just deleted the constant but haven't updated the function yet. Read it as '0'.
I wrote this code a while ago and it exports the animation but facing in the -z direction. Shouldn't take much to fix but the Menu/Tools/Mirror All fixes the orientation.
Now the results come out as calculated roll equalling pitch, calculated pitch equalling yaw and calculated yaw equalling negative roll. I've never got around to cleaning it up as long as I was getting the right numbers out
.
If you want to take the language for a shareware ride I can pass the code onto you.
Cheers
GrumpyOldMan
Bookmarks