Hi Guys

i've done this in the past, I do have a little class to handle it but it's 
quite a mess so I won't share the whole thing.

Essentially the best thing to do is to get hold of the original animation path 
then split it into the sub animation you require.

Then when you want to play a specific one you set it as the current for the 
AnimationPathCallback

Here's the basic code I use to do that


Code:
void SplitAni::ReSampleSubAni(int subID, int from, int to)
{
        if(subID<0 || subID>=(int)_splitAnis.size())
        {return;}
        //check the original path is good
        if(!_originalAni)
        {return;}
        
        //clear the current path
        _splitAnis[subID]->getTimeControlPointMap().clear();

        //find the number of frames in the original animation
        osg::AnimationPath::TimeControlPointMap timeMap = 
_originalAni->getTimeControlPointMap();

        //seconds per rame
        //int totalFrames = (int)timeMap.size();
        double secsPerFrame = (double)1.0f/_fps;

        //get start end frames as times
        double frameT = from*secsPerFrame;
        double endT = to*secsPerFrame;

        int newCount=0;

        while(frameT<endT)
        {
                osg::AnimationPath::ControlPoint cp;
                _originalAni->getInterpolatedControlPoint(frameT, cp);   

                //insert into the subanimation starting from time 0
                _splitAnis[subID]->insert(newCount*secsPerFrame, cp);

                //step to nxt time
                frameT+=secsPerFrame;

                //increase new frame count
                newCount++;
        }
}



_splitAnis is just an array of osg::AnimationPath and _fps is the frame rate of 
the original animation path.


Hope that helps
Tom

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=47226#47226





_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to