Hi everyone.
I'm kind of new to game programming and am trying to wrap my head around transformation matrices. My problem is that any articles i find on this topic focus far too heavily on the underlying graphics API being used. I think i have a pretty solid grasp on this; but some confirmation would be great.
So, here is what i understand so far:
- To get a transformation matrix we have to concatenate three matrices: one for translation, one for rotation and one for scaling.
- The order of the concatenation matters, as each operation is relative to the origin of the matrix. This is regardless of handedness.
- The concept of pre v post multiplication is a separate issue from concatenation order.
The correct order of concatenating these matrices is as follows: First Rotate, this will rotate the object around it's point of origin. Next Scale, since we don't want the scaling to affect how far the object is translated from origin it must be scaled first. Finally Translate.
In HLSL this would mean:
float4x4 transform = mul( mul( rotation, scale ), translate);
float4 worldPosition = mul(vertex, transform); However in GLSL it would be:
mat4 translation = translate * scale * rotate;
vec4 worldPosition = translation * vertex; Am i correct in assuming all of the above, or did i miss something in there?