Sign in to follow this  
unruly83

Multiple Calls to glRotate*

Recommended Posts

When making multiple calls to glRotate* (glRotated in this case); glRotated(angley, 1.0, 0.0, 0.0); glRotated(anglex, 0.0, 1.0, 0.0); I find that (here) it rotates bout the x axis, and then with the same matrix rotates it about the y axis. I am trying to rotate a quadric in two directions with respect to the 'observer' (after calls to glLookAt). Is there a way in which I can rotate the object two times in the 'world matrix' and not once in the world matrix, and the second time in the 'local matrix' (world perceived by the object)? Apologies if I am not making myself clear. Basically, when I call glRotated I find that the other axis are in fact being rotated along with the object I am currentl focusing on.

Share this post


Link to post
Share on other sites
seperate the calls to glrotate* by a push and pop i.e. :

glpushmatrix();
rotatey();
glPopmatrix();

glpushmatrix();
rotatex();
glpopmatrix();


Jon

Share this post


Link to post
Share on other sites
But...
"glPopMatrix pops the current matrix stack, replacing the current matrix with the one below it on the stack."
(tried, and it didn't look like it was rotating at all)
I'll try to further explain
I have a very simple setup. There is a plane (as in a big white square) and a ball on it. I want to rotate the ball 'a' degrees around the x-axis, then 'b'-degrees around the y axis. If i simply call two glRotate functions, it rotates the ball correctly around one axis, but the other rotation is respective to the new matrix.
Is it possible to have the two rotations respective to the original matrix, but apply them both?

Share this post


Link to post
Share on other sites
Quote:
Original post by unruly83
Is it possible to have the two rotations respective to the original matrix, but apply them both?
Although I'm not completely clear on what you're trying to do, I don't think you can do it with Euler angles as you're doing now. When you perform a sequence of global-axis rotations, one of them will always appear to be about a local axis. If you want the object to always rotate about the global axes regardless of its orientation, you may have to track the orientation and perform the rotations yourself. You won't be able to do this via OpenGL (at least not easily); you'll have to write the code for it yourself.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this