How to set the orientation of an object with a Ogre::Vector3

Problems building or running the engine, queries about how to use features etc.
Post Reply
lucky7456969
Gremlin
Posts: 156
Joined: Tue Sep 18, 2012 3:43 am

How to set the orientation of an object with a Ogre::Vector3

Post by lucky7456969 »

I want to set the orientation of an object after I retrieve an Ogre::Vector3 somewhere else?
Ogre::SceneNode *sn;
sn->rotate(...);

this accepts a quaternion, what is the Vector3 counterpart?
Thanks
Jack
User avatar
tod
Troll
Posts: 1394
Joined: Wed Aug 02, 2006 9:41 am
Location: Bucharest
x 94
Contact:

Re: How to set the orientation of an object with a Ogre::Vec

Post by tod »

Thishas the answer.

Code: Select all

// Get rotation to original facing                                          
 Vector3 currentFacing = mNode->getOrientation() * mInitFacing;                          
 Quaternion quat = currentFacing.getRotationTo(mInitFacing);
 mNode->rotate(quat);
But in you case it's the other way around. You use the getRotationTo on your initial directional vector.
lucky7456969
Gremlin
Posts: 156
Joined: Tue Sep 18, 2012 3:43 am

Re: How to set the orientation of an object with a Ogre::Vec

Post by lucky7456969 »

Great! it does the magic.
Jack
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 set the orientation of an object with a Ogre::Vec

Post by Kojack »

There's also SceneNode::setDirection (make the scene node face a direction) and SceneNode::lookAt (make the scene node face towards an absolute position).
Post Reply