Preserving the order of trasformations

Hi
As you know, in OpenGL, successive transformations affect in the reverse order they are issued. For example in the following code segmnent:

glMatrixMode(GL_MODELVIEW);
t1;
t2;
t3;
DrawShape();

The transformations are applied with the order t3 then t2 and finally t1.

I need a way (except using a data structure like stack to reverse the default order of transformations) to force OpenGL to transform in the order that I write in code. Any idea?

Thanks
MKAI

I am guessing it will be easier to change your code then try and change openGL.

Originally posted by MKAI:
[b]Hi
As you know, in OpenGL, successive transformations affect in the reverse order they are issued. For example in the following code segmnent:

glMatrixMode(GL_MODELVIEW);
t1;
t2;
t3;
DrawShape();

The transformations are applied with the order t3 then t2 and finally t1.

I need a way (except using a data structure like stack to reverse the default order of transformations) to force OpenGL to transform in the order that I write in code. Any idea?

Thanks
MKAI[/b]

This is because matrices in OpenGL are left-multiplied.
v’ = T1 * T2 * T3 * v;

What you want is right-multiplied matrices
v’ = v * T1 * T2 * T3;

The only (very simple) way to do that in OpenGL is to write your own matrix multiplication routines and load the transposed matrix at the end.

I could swear I answered this post too. Oh wait! It must be a double post!

[This message has been edited by Deiussum (edited 06-17-2003).]

Excuse me, Excuse me, Exceuse me!

Sorry for multiple posts. My browser has a problem and the pages weren’t updated. Sorry!

And about transformations: What is the matrix for rotating a point around the arbitrary vector
(x, y, z). (I know it for (1, 0, 0), (0, 1, 0) and (0, 0, 1) vectors).

Thanks

Check the apendices of the red book (It’s available online, just do a google search for it.) It gives details on how matrices around an arbitrary vector are setup. You will need to understand some of the notation used, which can be a little daunting at first, but if you sit down and really try to figure it out, you should be able to.

Have you tried searching google using keywords like “rotation” “matrix” and “axis”?