Skip to main content
gamedev.net
🔒 Locked

simple vector camera rotation

Started by thedustbustr 0 replies 500+ views
Original Post
thedustbustr
thedustbustr
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) {
  p+=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

Topic Locked

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

Sign in to reply to this topic.