Skip to main content
GameDev.net gamedev.net
🔒 Locked

Beginner camera problem

Started by SFSpoto Sep 24, 2005 at 10:48 AM 0 replies 450+ views
Original Post
SFSpoto
SFSpoto
Hi to all. This is my first post:) I have defined three function that calculate the rotation around the x axis, the y axis and traslation. Then i use this functions to compute the parameters to paste to glulookat. No problem with traslation, but when i use the two rotation simultaneously the camera doesn't work fine. In fact it rotate olny arount the y axis. But when i use only one rotation it works fine. Why? Tnx to all. There are the functions: // translate camera void MoveCamera ( FVector3D Direction ) { Position = Position + Direction; } // rotate around x void RotateCameraX ( GLfloat Angle ) { RotatedX += Angle; //Rotate viewdir around the right vector: ViewDir = (ViewDir*cos(Angle*PIdiv180) +UpVector*sin(Angle*PIdiv180)).NormalizeFVector3D(); //now compute the new UpVector (by cross product) UpVector = (ViewDir^RightVector)*-1; } // rotate camera around y void RotateCameraY ( GLfloat Angle ) { RotatedY += Angle; //Rotate viewdir around the up vector: ViewDir = (ViewDir*cos(Angle*PIdiv180) - RightVector*sin(Angle*PIdiv180) ).NormalizeFVector3D(); //now compute the new RightVector (by cross product) RightVector = ViewDir ^ UpVector; }
Zakwayda
Zakwayda
The problem will probably be pretty easy to pick out, but it's a pain to read the code without formatting. You can edit your post with the 'edit' button, and add pre-formatting or source tags to make it more readable.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.