I'm using the following code to create a new animation state from only a section of the model's animation, but the animation isn't playing. The model just stays static.
If I list the animation states, I can confirm that "walk" was successfully added to the AnimationStateSet. I have no trouble playing the base animation "Anim_1", but "walk" won't play. What am I doing wrong?
According to the documentation it requires at least the name of the animation, the starting frame, and duration (which I've done), so there's really no way to create a blank state.
For that I assume you would work directly with an animation as opposed to an animationstate (myEntity->getSkeleton()->getAnimation("my_anim_name")). Truth be told, I don't really know as I leave this up to my DCC tool exporter and I create all my animation tracks there.
Ogre::Animation* walkAnim = m_OgreEntity->getSkeleton()->getAnimation("Anim_1")->clone("walk");
walkAnim->setLength(40);
walkAnim->setUseBaseKeyFrame(true, 20);
// PROBLEM: How do I apply this "walkAnim" to my skeleton now? There is no method "addAnimation()"
Ogre::Animation* walkAnim = m_OgreEntity->getSkeleton()->createAnimation("walk", 40);
// PROBLEM: How do I copy the existing animation "Anim_1" to my newly created animation?
I looked in my exporter (well not mine, but the one I use) and this is how it creates animations:
- Calling Skeleton::createAnimation
- Calling Animation::createNodeTrack for a specific bone
- Calling NodeAnimationTrack::createNodeKeyFrame for each keyframe it needs to create
- sets the rotation, translation and scale of the newly created keyframe