History: ManuallyControllingBones
Source of version: 3 (current)
Copy to clipboard
Sometimes you want to manually control bones in a skeletally animated character, e.g. to turn the characters head toward a target. Here's one technique:
{CODE(wrap="1", colors="c++")} Entity *ent = mSceneMgr->createEntity("robot", "robot.mesh");
SkeletonInstance* skel = ent->getSkeleton();
Animation* anim = skel->getAnimation("Walk");
Bone* manuallyControlledBone = skel->getBone("Joint10");
manuallyControlledBone->setManuallyControlled(true);
anim->destroyTrack(manuallyControlledBone->getHandle());{CODE}
Manipulating manually controlled Bones:
{CODE(wrap="1", colors="c++")}mAnimState->addTime(evt.timeSinceLastFrame);
manuallyControlledBone->yaw(Degree(evt.timeSinceLastFrame*100));{CODE}
The original discussion of this feature can be seen [http://www.ogre3d.org/phpBB2/viewtopic.php?t=1550 here in this forum thread].
__Note:__ Since Ogre v1.6 you have the option of not actually destroying a track, but instead using Skeletal Blend Masks. This was discussed in the forum [http://www.ogre3d.org/phpBB2/viewtopic.php?t=39510 here].