Jump to content
  • Advertisement
Sign in to follow this  
middy

Rotating object as camera

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
See my code from a previous post it might help you:
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 this post


Link to post
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 this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!