PDA

View Full Version : Camera Problem



Questions Burner
10-29-2001, 05:14 AM
//I have something like this
void positionCamera()
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60, 1.3333, 0.1, 50);
glTranslatef(tx, ty, tz);
glRotatef(rx, 1, 0, 0);
glRotatef(ry, 0, 1, 0);
}
//with tx, ty, tz, rx and ry are global
//variables which I increment them to rotate
//and position the 'camera' but the problem
//is the glRotatef(ry, 0, 1, 0);
//the y rotation point is at the origin???
//not the center of the 'camera'
//And I don't want to use gluLookAt

pythagoras
10-29-2001, 07:06 AM
Should be:

void positionCamera()
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60, 1.3333, 0.1, 50);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glRotatef(rx, 1, 0, 0);
glRotatef(ry, 0, 1, 0);
// translate first, then rotate
glTranslatef(tx, ty, tz);
}

(I think http://www.opengl.org/discussion_boards/ubb/smile.gif )

G.

Questions Burner
10-30-2001, 03:30 AM
Tried it before(both matrix mode and transformation order) but then the translation will have problems.