Page 1 of 1

Rotation Problem Parent w/Children

Posted: Sun Oct 05, 2014 11:19 pm
by crancran
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?

Re: Rotation Problem Parent w/Children

Posted: Mon Oct 06, 2014 3:16 am
by crancran
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.
// Rotate the parent