Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


How to calculate camera roll...


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 tmason   Members   -  Reputation: 326

Like
0Likes
Like

Posted 11 August 2014 - 07:25 PM

Hello,

 

I have hopefully a simple question regarding calculating the roll of a camera.

 

I can calculate the yaw and pitch just fine using GLM:

CameraAxis = glm::cross(DirectionOfWhereCameraIsFacing, DirectionOfUpForPerson);
CameraQuatPitch = glm::angleAxis(CurrentCameraViewingSettings.Pitch, CameraAxis);
CameraQuatYaw = glm::angleAxis(CurrentCameraViewingSettings.Yaw, DirectionOfUpForPerson);

The first problem is calculating the roll of the camera. I tried this but my math is off as this doesn't work:

CameraQuatRoll = glm::angleAxis(CurrentCameraViewingSettings.Roll, CameraAxis);

This seems to me like another pitch calculation.

 

The second piece is accuratly combining the changed roll to find out where the camera is finally facing.

 

I do this for the yaw and pitch above by doing the following below:

CameraQuatBothPitchAndYaw = glm::cross(CameraQuatPitch, CameraQuatYaw);
CameraQuatBothPitchAndYaw = glm::normalize(CameraQuatBothPitchAndYaw);
DirectionOfWhereCameraIsFacing = glm::rotate(CameraQuatBothPitchAndYaw, DirectionOfWhereCameraIsFacing);

How do I also incorporate roll into this?

 

Thank you for your time.



Sponsor:

#2 NumberXaero   Prime Members   -  Reputation: 1909

Like
1Likes
Like

Posted 11 August 2014 - 08:34 PM

Build qpitch, qyaw, combine for qPitchYaw which now holds the new camera forward after pitch and yawing, build qroll from this new forward direction, combine qroll with qpitchYaw for qPitchYawRoll the new orientation.


Edited by NumberXaero, 11 August 2014 - 08:35 PM.


#3 tmason   Members   -  Reputation: 326

Like
0Likes
Like

Posted 12 August 2014 - 05:42 PM

Build qpitch, qyaw, combine for qPitchYaw which now holds the new camera forward after pitch and yawing, build qroll from this new forward direction, combine qroll with qpitchYaw for qPitchYawRoll the new orientation.

 

Thanks, will try this out and report back.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS