Jump to content
• Advertisement

# Beginner camera problem

This topic is 4825 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 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; }

#### Share this post

##### Share on other sites
Advertisement
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.

#### Share this post

##### Share on other sites

• Advertisement

### Announcements

• Advertisement

• ### Popular Contributors

1. 1
2. 2
3. 3
Rutin
21
4. 4
5. 5
khawk
14
• Advertisement

• 9
• 11
• 11
• 23
• 10
• ### Forum Statistics

• Total Topics
633653
• Total Posts
3013151
×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!