How to create keyframes for skeleton animation?

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
koreos
Halfling
Posts: 43
Joined: Fri Jun 20, 2014 7:05 pm

How to create keyframes for skeleton animation?

Post by koreos »

I have a skeleton animation that contains 15 keyframes. Now I want to remove all those 15 keyframes and insert new 150 ( or any number of ) keyframes manually which I have calculated. How should I do it?

I tried somthing like this for playing 150 keyfrmaes from another skeleton animation. But it still playing only 15 :(

Code: Select all

    Ogre::Animation *animation = skeleton->getAnimation("my_animation");
    Ogre::Animation *refanimation = refskeleton->getAnimation("my_animation");

    animation->destroyAllNodeTracks();

    Ogre::Real length = 150/24;
    const float timeInterval = length/(150-1);

    for (unsigned short i = 0; i < refanimation->getNumNodeTracks(); ++i)
    {
        if (!refanimation->hasNodeTrack(i))
        {
            continue;
        }

        Ogre::NodeAnimationTrack *refnodeAnimTrack = refanimation->getNodeTrack(i);
        Ogre::NodeAnimationTrack *animationTrack;
        if(!animation->hasNodeTrack(i))
            animationTrack = animation->createNodeTrack(i);
        else
            animationTrack = animation->getNodeTrack(i);

        for (unsigned short j = 0,k=0; j<150; j++,k++)
        {
            Ogre::TransformKeyFrame *refkeyframe = refnodeAnimTrack->getNodeKeyFrame(j);
            float timePos = timeInterval * j;
            Ogre::TransformKeyFrame *key = animationTrack->createNodeKeyFrame(timePos);
            key->setTranslate(refkeyframe->getTranslate());
            key->setRotation(refkeyframe->getRotation());
            key->setScale(refkeyframe->getScale());
        }
    }
Post Reply