Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am experiencing difficulties trying to figure out the correct multiplication order for a final transform matrix. I always get either strange movement or distorted geometry. My current model is explained below:

For a single node my multiplication order is:

L = S * R * T

where

L = local transformation matrix

S = local scale matrix

R = local rotation matrix

T = local translate matrix

For a node's world transformation:

W = P.W * L

where

W = world transformation matrix

P.W = parent world transformation matrix

L = the local transformation matrix calculated above

When rendering, for each node I calculate the matrix :

MV = Inv(C) * N.W

where

MV = the model view transformation matrix for a particular node

Inv(C) = the inverse camera transformation matrix

N.W = the node's world transformation matrix calculated above.

Finally, in the shader I have the fallowing transformation:

TVP = PRP * MV * VP

where

TVP = final transformed vertex position

PRP = perspective matrix

MV = the node's world transformation matrix calculated above

VP = untransformed vertex position.

With the current model, child nodes which have local rotation, rotate strangely when transforming the camera. Where did I go wrong with the multiplication order?

share|improve this question
add comment

1 Answer

up vote 14 down vote accepted

Any combination of the order S*R*T gives a valid transformation matrix. However, it is pretty common to first scale the object, then rotate it, then translate it:

L = T * R * S

If you do not do it in that order, then a non-uniform scaling will be affected by the previous rotation, making your object look skewed. And the rotation will be affected by the translation, making the final position of your object very different from what the value of the translation would make you expect.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.