Advertisement

Camera Rotation Problem

Started by July 29, 2003 02:22 PM
2 comments, last by wolf_10 21 years, 7 months ago
Hi, i have a Problem with rotating my Camera. I try to make a 3D Space Shooter with free 3D Movement, i use a Skybox for Environment. I can rotate my Camera around the Y- Axis, but when i make a rotation around the X-Axis, the Skybox rotate foreward and backward (difficult of explanation). here my code to rotate the camera: GLvoid CCamera::Rotate(float x, float y, float z) { CVector viewVector = View-Position; if (x) // if x>0 { View.z = (float)(Position.z + sin(x)*viewVector.y + cos(x)*viewVector.z); View.y = (float)(Position.y + cos(x)*viewVector.y - sin(x)*viewVector.z); } if(y) { View.z = (float)(Position.z + sin(y)*viewVector.x + cos(y)*viewVector.z); View.x = (float)(Position.x + cos(y)*viewVector.x - sin(y)*viewVector.z); } if(z) { View.x = (float)(Position.x + sin(z)*viewVector.y + cos(z)*viewVector.x); View.y = (float)(Position.y + cos(z)*viewVector.y - sin(z)*viewVector.x); } } . . . . Update Camera . . . and here the call: Input.Update(); int dx, dy; Input.GetMouseMovement(dx, dy); // keep the cursor within the window g_mouseX += dx; if (g_mouseX+CURSOR_SIZE >= 1024) { g_mouseX = 1024-CURSOR_SIZE ; Camera->TurnRight();//OK } if (g_mouseX <= 0) { g_mouseX = 0; Camera->TurnLeft();//OK } g_mouseY += dy; if (g_mouseY >= 768) { g_mouseY = 768; Camera->Rotate(-rot,0,0);//dosen''t work } if (g_mouseY-CURSOR_SIZE <= 0) { g_mouseY = 0+CURSOR_SIZE; Camera->Rotate(rot,0,0);//dosen''t work } Here is the Demo http://theflashback.de/test.zip Can anyone tells me whats wrong ???
You can not easily define free rotation using Euler angles. Search Google and the forums for quaternions.
Advertisement
thanks for reply.

has anyone the (Gametutorial Number 7 free 3D Movement) ?????
i think this was the Tutorial with quaternions

This topic is closed to new replies.

Advertisement