Jump to content
  • Advertisement
Sign in to follow this  
middy

Rotating object as camera

This topic is 5039 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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!