PDA

View Full Version : glRotatef() - A newbie question... please help



09-11-2000, 12:23 AM
Drawscene()
{
glTranslatef(-1*myposx,-1*myposy,-1*mypoz);
glPushMatrix();
glRotatef(theta,0,1,0);
drawWorld(); //draws the world
glPopMatrix();
}

should that appear as if I I was standing at myposx, myposy, myposz looking in the theta direction... but that doesn't happen, instead of that... the whole world moves around the original origin (before glTranslate) instead of after the translate... I can work around this problem with gluLookAt, but it's not ALWAYS the best solution, I don't want to neglect glRotatef and glTranslate... could anyone tell me what I am doing wrong?

foobar
09-11-2000, 02:12 PM
[B]


Drawscene()
{
//assuming identity is set
glRotatef(theta,0,1,0);
glTranslatef(-myposx,-myposy,-mypoz);
drawWorld(); //draws the world

}


You need to be looking in the correct direction before you translate to your viewing position.

09-11-2000, 10:21 PM
that doesn't work http://www.opengl.org/discussion_boards/ubb/frown.gif, when I comment out the glRotatef() nothing changes...

dummy
09-15-2000, 01:24 PM
can anyone else give me a hint? http://www.opengl.org/discussion_boards/ubb/frown.gif

David
09-18-2000, 03:46 AM
Try this,

Drawscene()
{
glRotatef(theta,0,1,0);
glPushMatrix();
glTranslatef(-1*myposx,-1*myposy,-1*mypoz);

drawWorld(); //draws the world
glPopMatrix();
}

It seems that what you were originally doing was translating out, then rotating, which would rotate around the origin.

This way rotates at the origin, putting the viewer in the correct position, and then translates to where it should be.

David.