Combining node transforms

While going through the visual_scenes, for each node I’m combining all the transforms into a single matrix (as I assume everyone does). The flow is something like this:


create local matrix for current node: nodeTrans
for each transform element in node
  create matrix representing this transform: trans
  nodeTrans *= trans

I’m stuck on how to create a matrix representing a single rotation or scale. I’m using Irrlicht which has functions for setting the scale or rotation of a matrix, but these simply overwrite cells, so if you set rotation it’ll mess up scale and vice versa. Can anyone point me to an example of how to either create a rotation matrix that preserves uniform scale (1, 1, 1) or create a scaling matrix that preserves zero rotation? Thanks in advance!

I also posted on the Irrlicht forum btw: http://irrlicht.sourceforge.net/phpBB2/ … p?p=150629

http://www.euclideanspace.com/maths/geo … /index.htm

Thanks for the speedy reply, Remi!

This axis+angle to matrix function seems to suffer from the same problem; as you can see in the example at the bottom, creating a matrix containing a 90 degree rotation about the x-axis results in the matrix:

1 0 0
0 0 -1
0 1 0

which also contains a scale transform of (1, 0, 0), so if I multiply anything by this rotation matrix, the y and z scale of the result will be zeroed out.

I suspect I’m missing something fundamental about 3d transforms. As I understand it, rotation is contained in the top left 3x3 block of a 4x4 transform matrix. Scale is contained in the diagonal of this 3x3 block: m(0,0), m(1,1), m(2,2). So to make a matrix that contains purely rotation, shouldn’t m(0,0), m(1,1), and m(2,2) each equal 1 to preserve the scale?

Apologies if this is a dumb question!

Nevermind - realized my misunderstanding: although you can create a scaling matrix by setting three cells, you can’t extract scale by simply reading the values of those cells. Scale permeates other cells in ways that I don’t understand yet :] Anyway I found a simple workaround for my specific implementation problem in Irrlicht so all is well. Thanks again!