Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


simple vector camera rotation

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

I''ve been having some trouble rotating my camera. It is defined by four vectors (position, up, forward, and right; where up, forward, and right are relative to position). I want to be able to modify the camera''s yaw, pitch, and roll. I initially wanted to simply pass an angle into a function and create a transformation matrix based on this angle, but I couldn''t get this to work at all (for not enough understanding/practice in matrix math). Next I tried to also store 3 floats - r, p, and y (for roll, pitch, yaw). Then I update my three vectors based on trig of a unit circle. Thus:
float Camera:itch(float angle) {
  update(); }
float Camera::yaw...
float Camera::roll...
float Camera::update() {
  forward.x = cos(y);
  forward.y = sin(p);
  forward.z = sin(y);
  right.x = cos(p+pi/2);
  right.y = sin(r);
  right.z = sin(p+pi/2);
  up=CrossProduct(forward, right); } 
This code goes haywire - the vectors arent calculated correctly. What am I doing wrong - or, could I have a few tips on the first method? -- Dustin

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!