# mat4 transformation chain

hi,

i’m having problem to correctly animate separate nodes of a model. the nodes are hierarchically structured, and each node has a “mat4 Transform” (relative to its parent). to animate nodes, each nodes has an additional member “mat4 Animation” (relative to the base transform “mat4 Transform”).

to get the final “mat4 world_transform”:

``````mat4 Node::WorldTransform() const
{
return
m_parent ?
inverse(inverse(Animation) * inverse(Transform) * inverse(m_parent->WorldTransform())) :
Transform * Animation;
}
``````

that works fine, but the “assimp” library i use to load models delivers the “mat4 Animation” as absolute transform relative to the node’s parent.

in other words:
–> assimp gives me [Transform * Animation] and [Transform]
–> i want [Animation] only (separated)

how do i do that ??

beside that:
is it better to pre-calculate all the possible animation matrices for each “key frame tick” or just do the calculations “on-the-fly” ?

Note that the above is just an inefficient way of writing

``````
m_parent->WorldTransform() * Transform * Animation

``````

For any matrices A, B: (A·B)-1=B-1·A-1.

Animation = inverse(Transform) * [Transform * Animation]

Matrix multiplication is associative: A·(B·C)=(A·B)·C, the product of a matrix with its inverse is the identity matrix: A·A-1=A-1·A=I, and the identity matrix is both a left identity: I·A=A and a right identity: A·I=A. So A-1·(A·B)=(A-1·A)·B=I·B=B.

thanks for your help! it seems to work now

[QUOTE=GClements;1288759]Note that the above is just an inefficient way of writing

``````
m_parent->WorldTransform() * Transform * Animation

``````

For any matrices A, B: (A·B)-1=B-1·A-1.[/QUOTE]

:doh: seems that i need a little practice with matrices again

[QUOTE=GClements;1288759]Animation = inverse(Transform) * [Transform * Animation]

Matrix multiplication is associative: A·(B·C)=(A·B)·C, the product of a matrix with its inverse is the identity matrix: A·A-1=A-1·A=I, and the identity matrix is both a left identity: I·A=A and a right identity: A·I=A. So A-1·(A·B)=(A-1·A)·B=I·B=B.[/QUOTE]

i was unsure where to add the “inverse(Transform)” to remove the “Transform”-part of the mat4, at the end or at the beginning … thanks again for pointing that out