PDA

View Full Version : glRotate problem



Dies_Irae
02-14-2002, 11:37 AM
Hi,

Ive created 2 sphears and rendering them something like this:

glPushMatrix();
glTranslatef();
glRotate(ang, 1, y, z);
draw sphear
glPopMatrix();

glPushMatrix();
glTranslatef();
glRotate(ang, x, y, 1);
draw sphear
glPopMatrix();


The first sphear rotates ok, (around x)
but the second one rotates around both x and z

Whats causing that?
Doesnt glPushMatrix means to load a clean matrix without any transformation?

(I dont want to use glLoadidentity()
but maybe thats the only way?

Hope not, then i need to relocate whole my world http://www.opengl.org/discussion_boards/ubb/smile.gif

Thanks guys.

satan
02-14-2002, 11:56 AM
glpushmatrix pushes the current matrix to the matrix stack (clever name for such a function http://www.opengl.org/discussion_boards/ubb/wink.gif)
glloadidentity sets the current matrix to identity and is perhaps what you mean by a 'clean matrix'


[This message has been edited by satan (edited 02-14-2002).]

Dies_Irae
02-14-2002, 12:00 PM
Ok,
but how do i rotate the sphears without having the first affecting the other?

Without using glLoadIdentity()

tx

02-14-2002, 12:26 PM
Unless of course, you had left some value for x when you rotate the 2nd sphere


Originally posted by Dies_Irae:
Ok,
but how do i rotate the sphears without having the first affecting the other?

Without using glLoadIdentity()

tx

Jambolo
02-14-2002, 08:43 PM
Everything appears ok to me except for the x, y, and z variables in the glRotate calls.

If you want to rotate around the X axis, the call should be:

glRotate(ang, 1, 0, 0);

If you want to rotate around the Z axis, the call should be:

glRotate(ang, 0, 0, 1);

I bet you put the x, y, and z values in because of the translations. Don't do that.

Dies_Irae
02-14-2002, 10:46 PM
Hey,

Yea sorry its like that, dont know why i typed like that,


glRotate(90, 1, 0, 0)

glRotate(90, 0, 0, 1)


If you Push and Pop matricies around them ,
the 2nd one should not rotate

(x 90 z 90) if thats true there must be something else with my code, time for some serious debuging http://www.opengl.org/discussion_boards/ubb/smile.gif

Thanks guys. (Or ladies)

Dies_Irae
02-14-2002, 11:52 PM
Ah crap, just a small mistake http://www.opengl.org/discussion_boards/ubb/smile.gif

tx.