View Full Version : 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

nexusone

06-17-2003, 04:48 AM

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

Originally posted by MKAI:

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

Relic

06-17-2003, 05:15 AM

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.

Deiussum

06-17-2003, 05:39 AM

I could swear I answered this post too. Oh wait! It must be a double post! http://www.opengl.org/discussion_boards/ubb/mad.gif

[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

Deiussum

06-18-2003, 05:14 AM

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.

Coconut

06-18-2003, 05:26 AM

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

Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.