[SOLVED]How to reset Pitch, Pitch & Roll only

Problems building or running the engine, queries about how to use features etc.
Post Reply
iblues1976
Gnome
Posts: 379
Joined: Fri Sep 16, 2011 4:54 pm
x 10

[SOLVED]How to reset Pitch, Pitch & Roll only

Post by iblues1976 »

Hello,

I'm using Ogre 1.9

Currently, I saved the original orientation of the camera, and I reset it to that.. however, I notice that It will be better (for what I need) to only reset Pitch , or Pitch & Roll...

How can I do it,without affecting the other rotation(s)?

Thanks
Last edited by iblues1976 on Fri May 16, 2014 4:30 am, edited 1 time in total.
amartin
Halfling
Posts: 87
Joined: Wed Aug 14, 2013 6:55 am
Location: Norway
x 13

Re: How to reset Pitch, Pitch & Roll only

Post by amartin »

try making a scene node each for pitch, roll and yaw you can then deal with each individually. For most cases this works fine and doesn't cause any major quitks and solves some issues that can happen if you only use 1 node. http://www.ogre3d.org/tikiwiki/tiki-ind ... n%20camera is an example of the setup you could use.
iblues1976
Gnome
Posts: 379
Joined: Fri Sep 16, 2011 4:54 pm
x 10

Re: How to reset Pitch, Pitch & Roll only

Post by iblues1976 »

Thanks... However, I'm wondering to see if is possible to do it with the just the camera node and the functions that it already has... given that my code already uses only the camera... and I'm not looking to change it, at least as of now.
thanks
User avatar
areay
Bugbear
Posts: 819
Joined: Wed May 05, 2010 4:59 am
Location: Auckland, NZ
x 69

Re: How to reset Pitch, Pitch & Roll only

Post by areay »

Get the camera's current facing direction, remove the yaw element (say set facingVec.x = 0) then do a Ogre::Quaternion requiredRot = facingVec.getRotationTo(Ogre::Vector3::UNIT_Z) to get the rotation required to make it face forwards then rotate your camera by that amount.
iblues1976
Gnome
Posts: 379
Joined: Fri Sep 16, 2011 4:54 pm
x 10

Re: How to reset Pitch, Pitch & Roll only

Post by iblues1976 »

Arey,
Thanks for the reply ..

I haven't code it yet... but I think you are saying .... something like

Code: Select all

 
//rotate Y Axis... 
Ogre::Vector3 dir = m_pCamera->getDirection();
dir.X = 0; 
Ogre::Quaternion requiredRot = facingVec.getRotationTo(Ogre::Vector3::UNIT_Z);
m_pCamera->rotate(requiredRot);
m_pCamera->rotate(SomeValueToRotateYAxis);
// is that enough? 
would this works well to to a "good" rotation per axis as well...

Thanks
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: How to reset Pitch, Pitch & Roll only

Post by Kojack »

Due to there not being a simple 1 to 1 relationship between euler angles and quaternions (there are an infinite combination of euler angles that can generate the same quaternion), it's easier to keep the euler angles as explicit values (never try to extract them) and generate the camera quaternion from them when needed. It makes life much simpler. :)
The triple node arrangement is one way to do it, or use something like my euler angle class on the wiki (it was made primarily for controlling cameras and doing things like resetting individual angles).
iblues1976
Gnome
Posts: 379
Joined: Fri Sep 16, 2011 4:54 pm
x 10

Re: How to reset Pitch, Pitch & Roll only

Post by iblues1976 »

Kojack,


After a search, I found the page that I think you were referring about: http://www.ogre3d.org/tikiwiki/tiki-ind ... ngle+Class

I think this is a good option. In the future, or next app, I will implement the FPS camera on the wiki.

Thanks
Post Reply