Rotation Problem Parent w/Children

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
crancran
Greenskin
Posts: 136
Joined: Wed May 05, 2010 3:36 pm
x 3

Rotation Problem Parent w/Children

Post by crancran » Sun Oct 05, 2014 11:19 pm

I have two scene nodes, a parent and child where the child's yaw is adjusted based on some trigger during the main render loop. This works nicely but I need to add some functionality where when a trigger is detected, the child node's orientation is used to rotate the parent node to face the same direction without rotating the child node. In other words, I need to rotate the parent scene node so it's facing direction matches that of the child node, but at the same time not rotate the child nodes during the translation process. How would I accomplish this?
0 x

crancran
Greenskin
Posts: 136
Joined: Wed May 05, 2010 3:36 pm
x 3

Re: Rotation Problem Parent w/Children

Post by crancran » Mon Oct 06, 2014 3:16 am

I found the solution:

Code: Select all

// Get quaternion between two vectors.
// In this case, gets the rotation to set the parent node's facing the same as the child's orientation.
Ogre::Quaternion rotation = parentNode->getOrientation().xAxis().getRotationTo(childNode->getOrientation().xAxis(), Ogre::Vector3::UNIT_X);
// Prior to updating the rotation, be sure to freeze the child's orientation so it doesn't get affected.
childNode->setInheritOrientation(false);
// Rotate the parent
parentNode->rotate(rotation);
0 x

Post Reply