Correct transformations?

Hi!

I’m once again having problems with my transformations… :slight_smile:

How does OpenGL apply a matrix to its vertices?

I need to be able to perform correct transformations, i.e. rotating on local axises. I’ve managed to do this using the glRotatef() and glVertex3d(), but since I need to do my own rotations, I cannot use these calls.

So, here’s how I do it:

tX = X * privateMatrix [0] +
Y * privateMatrix [1] +
Z * privateMatrix [2] +
privateMatrix [12];
tY = X * privateMatrix [4] +
Y * privateMatrix [5] +
Z * privateMatrix [6] +
privateMatrix [13];
tZ = X * privateMatrix [8] +
Y * privateMatrix [9] +
Z * privateMatrix [10] +
privateMatrix [14];

where tX is the transformed coordinate X, and privateMatrix is a matrix that OpenGL calculated. This only rotates on the world axises.

However, I’ve found that if I swap rows and columns in the matrix, I get the desired rotations. Is this correct? Does anyone know of a better way to perform correct transformations?

TIA

Ivan

I used this code in one of my programs:

newpt.x = pt->x * m[0] + pt->y * m[4] + pt->z * m[8] + m[12];
newpt.y = pt->x * m[1] + pt->y * m[5] + pt->z * m[9] + m[13];
newpt.z = pt->x * m[2] + pt->y * m[6] + pt->z * m[10] + m[14];

Turns out you were right, and I was wrong from the beginning. I looked into my tutorials once more, and into my old books. They were right too. Must’ve gone wrong in some odd place. :slight_smile:
However, it’s curious it works with the matrices swapped.

Thanks a lot!