Rotation Problem Parent w/Children
-
crancran
- Greenskin
- Posts: 138
- Joined: Wed May 05, 2010 3:36 pm
- x 6
Rotation Problem Parent w/Children
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?
-
crancran
- Greenskin
- Posts: 138
- Joined: Wed May 05, 2010 3:36 pm
- x 6
Re: Rotation Problem Parent w/Children
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);