# Rotating object as camera

This topic is 5118 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello everyone I want to rotate an object the same way as my camera. From my camera I have, an UP,DOWN, SIDE and POSITION vector. So I thought I could copy UP,DOWN, SIDE into an matrixand then do glMultmatrix(matrix) but this completely messes up my geometry. Question 1) What could I be doing wrong Question 2) Is the a better way todo this?

##### Share on other sites
void MoveForward()
{
GLfloat angle = 0.1;
glMatrixMode(GL_MODELVIEW);
glTranslatef(0.0, 0.0, angle);

angle=angle + 0.1;
}

void MoveBack()
{
GLfloat angle = 0.1;
glMatrixMode(GL_MODELVIEW);
glTranslatef(0.0, 0.0, -angle);

angle=angle + 0.1;
}

void StrafeRight()
{
GLfloat angle = 0.03;
glMatrixMode(GL_MODELVIEW);
glTranslatef(-angle, 0.0, 0.0);

angle=angle + 0.05;
}

void StrafeLeft()
{
GLfloat angle = 0.03;
glMatrixMode(GL_MODELVIEW);
glTranslatef(angle, 0.0, 0.0);

angle=angle + 0.05;
}

##### Share on other sites
The "camera" matrix is the inverse of what you want. You want this matrix:

[ Sx Ux Fx Px ][ Sy Uy Fy Py ][ Sz Uz Fz Pz ][ 0  0  0  1 ]

Multiply into the modelview matrix after any camera transforms.

##### Share on other sites
python... thanks alot, that helped :)

1. 1
2. 2
3. 3
Rutin
15
4. 4
khawk
14
5. 5
frob
12

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633662
• Total Posts
3013231
×