RE: [Algorithms] RE: Using animation keys from 3DSMax
Brought to you by:
vexxed72
|
From: Mike K. <Mik...@bl...> - 2004-04-06 13:39:25
|
Here's some info that might help you out on this data conversion - It = refers to something known in the trade as a 'similarity transform', ( = Q'.R.Q ) Anyway, hope it helps =20 -------------------------------------------------------------------------= ---- =20 Looking at a hierarchy and it's transforms if m defines a vertex position R[i] is a transform 4x4 =20 then inheriting transforms down a hierarchy can be defined as m' =3D R0*R1*R2*...Rn*m =20 so, R0 is the root transform, Rn is the leaf transform.=20 (this is what you get with transforms at every node in your character = skeleton) m,R are all in world space. =20 That's fine. Now, you have source m and all Rs defined in Max coords. = So, you want to transform to your own coordinate system (lets call that = User). Ok, you work out the transform, lets call it Q. =20 So applying Q to your mesh for instance transforms your Max mesh verts = to User coords. Lovely. But what about those transforms?=20 =20 Well ok, here's one method that would work =20 b' =3D Q*R0*R1*R2*....Rn*m =20 meaning you've done all your rotations n stuff in max coords, then = transformed the result to BB. That's not what you want, you want = something more like =20 b' =3D r0*r1*r2*....rn*(Q*m) =20 i.e. your transformed mesh Q*m gives the mesh in b coordinates, and then = r0,...rn rotate it about. So what are r0..rn? =20 Well that's easy enough =20 Take =20 b' =3D Q*R0*R1*R2*....Rn*m =20 To actually move Q along the line you need to introduce lots=20 of Q'.Q (where Q' =3D Inv(Q)) =20 So =20 b' =3D Q*(Q'.Q )*R0*(Q'.Q)*R1*(Q'.Q)*R2*(Q'.Q)*m =20 b' =3D (Q*R0*Q') * (Q*R1*Q') * (Q*R2*Q') * (Q*m) =20 So we have our Qm now, and we know what r0,r1,r2..rn are,=20 they're just (Q.Ri.Q') =20 Simple eh? =20 - Mike =20 PS =20 They also distribute. We currently do this for getting the local = transform from a node and its parent transforms =20 R1 * R0' =20 Ok converting to User space that would be =20 Q*R1*Q' * ( Q*R0*Q' )' =20 to invert reverse matrix order and invert components gives =20 Q*R1*Q' * ( Q* R0' * Q' ) =3D Q* R1*R0' * Q'=20 =20 Hence=20 Q*A*Q' * Q*B*Q' =3D Q*A*B*Q' =20 Well alright! -----Original Message----- From: Ryan Greene [mailto:rg...@qu...] Sent: 31 March 2004 20:47 To: gda...@li... Subject: [Algorithms] RE: Using animation keys from 3DSMax Okay, so my swap is incorrect... but that isn't the problem I'm dealing = with. I can properly transform the mesh and skeleton, however since the = rotation keys I'm getting are in Max's space I can't apply the rotations = to the skeleton properly. It would seem that I would need to convert the = quat from max's z-up space to my y-up space... however I am having = difficulty doing that conversion. This is why I wanted to keep the mesh = in max's z-up space, and then do the conversion when I build each bone's = matrix (it's free). =20 =20 =20 Swapping your Y and Z is not sufficient to change your coordinate = system. And if you need to change handedness you have to do other = things. Assuming your handedness is the same, you need to perform a = clockwise 90 degree rotation about x. (or swap y and z and negate one = of them.) For example, if your engine is the same handedness as MAX swap the y and = the z and negate the Y. This works for me as the engine that I'm = working on right now has the same handedness as MAX. swap =3D3D -y; y =3D3D z; z =3D3D swap; As a side note, are you doing the swizzle at run-time? If so why? Why = not take care of this at export time, then you never have to worry about = using MAX's coordinate system to calculate the parent matrices using = your coordinate system. --Pete =20 ********************************************************************** The information contained in this email and its attachments is confidential. It is intended only for the named addressees=20 and may not be disclosed to anyone else without consent from Blue 52 Games Limited. Blue 52 give no warranty that this email=20 message (including any attachments to it) is free of any virus=20 or other harmful matter and accepts no responsibility for any=20 loss or damage resulting from the recipient receiving, opening or using it.=20 ********************************************************************** |