Hi Drew,

The initialize of the animation path callback the first time its
called is a deliberate attempt at making sure that the animation
starts at the beginning on the first frame.

Perhaps this reset feature needs to be made optional.

FYI, I am considering placing a start tick into osg::Timer, and
therefore the osg::Timer::instance() to help make it easier to get
time consistently across the app.  I need to ponder on this issue
further before I make any changes though.  I'll ping you if I do.

Robert.

On 12/20/06, Drew Whitehouse <[EMAIL PROTECTED]> wrote:
Well I found a fix that works around my problem, it doesn't really clean
up the behaviour that I noted in the posts above but does do what I
want. The problem was to do with osg::AnimationPathCallback which
calculates it values relative to the first time it's evaluated. So when
the window was first realized the time was already > 0.0. Hence the
_firstTime member variable was set to a number > 0.0 meaning it isn't
evaluated at the framestamp's time for that particular frame. I get
around it by overriding the operator() and zeroing out _firstTime;

Possibly a bug ?

-Drew

class MyAnimationPathCallback : public osg::AnimationPathCallback
{

public:

    MyAnimationPathCallback(osg::AnimationPath* ap,double
timeOffset=0.0,double timeMultiplier=1.0) :
        osg::AnimationPathCallback(ap,timeOffset,timeMultiplier) {}

    void operator()(osg::Node* node, osg::NodeVisitor* nv)
    {
        if (_animationPath.valid() &&
            nv->getVisitorType()==osg::NodeVisitor::UPDATE_VISITOR &&
            nv->getFrameStamp())
        {
            double time = nv->getFrameStamp()->getReferenceTime();
            _latestTime = time;

            if (!_pause)
            {
                // Only update _firstTime the first time, when its value
is still DBL_MAX
                if (_firstTime==DBL_MAX) _firstTime = 0.0; //
<<<<<<----------------------- force it to be 0.0 instead of time
                update(*node);
            }
        }

        // must call any nested node callbacks and continue subgraph
traversal.
        NodeCallback::traverse(node,nv);
    }
};


>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://openscenegraph.net/mailman/listinfo/osg-users
> http://www.openscenegraph.org/
>

_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to