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:
Copy to clipboard
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());
Manipulating manually controlled Bones:
Copy to clipboard
mAnimState->addTime(evt.timeSinceLastFrame); manuallyControlledBone->yaw(Degree(evt.timeSinceLastFrame*100));
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.