Jump to content
  • Advertisement
Sign in to follow this  
Ross_K

Camera Class glitches

This topic is 4234 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

Hi, I am rather new to the game development scene ( little over a year all together ), and I am writing a game engine. It's not got to be perfect, but I want it to teach me more about graphics and math. I have written a very basic camera class. First, I wrote the basic panning/rotation/zooming functions, which all worked horizontally. This seemed to work perfectly, until I tried to implement vertical movement. Now, when I try and rotate the camera around the X axis, ( look up or down ), I get a weird 'S' shape. Here is the code: //Rotate the camera vertically void camera::Vrotate( float angle ){ if( projection == ORTHOGRAPHIC ) return; VrotationAngle += angle; //Convert to radians angle = VrotationAngle*PI/180; //Create a vector containg the camera's direction and radius vector dir = direction - position; //Rotate direction.y = cosf(angle)*dir.length()+position.y; direction.z = sinf(angle)*dir.length()+position.z; cout << direction << endl; update(); return; } //Rotate the camera horizontally void camera::Hrotate( float angle ){ if( projection == ORTHOGRAPHIC ) return; HrotationAngle += angle; //Convert to radians angle = HrotationAngle*PI/180; //Create a vector containg the camera's direction and radius vector dir = direction - position; //Rotate direction.x = cosf(angle)*dir.length()+position.x; direction.z = sinf(angle)*dir.length()+position.z; update(); return; } VrotationAngle and HrotationAngle are data members that hold the current rotation. I have decided to leave ORTHO projection when it comes to the camera.

Share this post


Link to post
Share on other sites
Advertisement
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!