4x4 Transformation Matrix question

Hi

I have been moving from intermediate mode to to full opengl 3+, it has gone well but I still have a couple of issues to solve. One of the biggest I have is the move to having 4x4 transformation matrix.

I understand where the translation bits go, the rotation bits and the scaling bits go but I am a little unsure as to how best to handle the multiplication. I have a single 4x4 matrix with the scaling, rotation and translation all applied, lets say I have a bone skeleton and i want to work out the initial positions (So I need to multiply in a recursive way). When I multiply this out to work out the bones final positions I “should” (in my mind) just be able to multiply the 4x4 transformations but I don’t think this is right.

The scale components effect the rotation components so I am thinking should I actually keep the scale, rotation and translation components separate and multiply these like I did before and only combine to a 4x4 at the very end when I have the final transformation, or am I talking rubbish and the 4x4 matrix multiplication should all work and there is a bug else where in my code? (I can’t get my objects to draw correctly as they were before so there is definitely a problem somewhere).

To give you are idea of what I did before, this is the pseudo code for the transformation code I had before (scale, rotation and translation kept as separate items)

newXXX = the result of the multiplication
currentXXX = the current transformation values
toMultiplyXXX = the transformation to multiplied with
(newXXX = currentXXX * toMultiplyXXX)

newPosition = (currentRotation * toMultiplyPosition) + currentPosition
newRotation = currentRotation * toMultiplyRotation
newScale = currentScale * toMultipleScale

Yes.

The scale components effect the rotation components

They can affect the translation components too, depending on your order of multiplication. Also, regardless, they will affect the translation components of subsequent transformations.

For starters, you might consider omitting scale and only add that later when you’re more solid on this.

…so I am thinking should I actually keep the scale, rotation and translation components separate and multiply these like I did before and only combine to a 4x4 at the very end when I have the final transformation, or am I talking rubbish and the 4x4 matrix multiplication should all work

Either way.

…and there is a bug else where in my code?

Always a possibility.

To give you are idea of what I did before, this is the pseudo code for the transformation code I had before (scale, rotation and translation kept as separate items)

newXXX = the result of the multiplication
currentXXX = the current transformation values
toMultiplyXXX = the transformation to multiplied with 
(newXXX = currentXXX * toMultiplyXXX)

newPosition = (currentRotation * toMultiplyPosition) + currentPosition
newRotation = currentRotation * toMultiplyRotation
newScale = currentScale * toMultipleScale

You’re trying to expand an SRT (scale-rotate-translate) times a SRT. If you do it this way, it’s more complicated than that. I would just punt this and composite your scale, rotate, and translate together using a normal transform composite (e.g. matrix multiply, if you’re using matrices) operation and be done with it. Then you don’t have to worry about fixing your expansion.