# Camera Class glitches

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

## 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.

1. 1
2. 2
3. 3
Rutin
13
4. 4
5. 5

• 26
• 10
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633696
• Total Posts
3013394
×