Hi Dat,

The AnimationPath assumes a constant speed between each control point
and animates accordingly.

I guess it shouldn't be be possible to come up with the maths so that
one assumes a constant acceleration between control points and then
integrates to get the actual position at a given time.  One would also
need to store the speed at the control point as the position, rotation
and scale.

I'm not really familiar with osgAnimation yet, perhaps it provides
support for what you are after.

Robert.

On Fri, Dec 3, 2010 at 12:44 AM, Nguyen Tien Dat <[email protected]> wrote:
> Dear all,
> I need to move an object along a line with the speed of 1m/s. The
> object starts from stationary (0m/s). I use AnimationPath like this:
>
>                osg::AnimationPath* animationPath = new osg::AnimationPath;
>        animationPath->setLoopMode(osg::AnimationPath::NO_LOOPING);
>
>                osg::Vec3 startPoint(startMat(3,0), startMat(3,1),
> startMat(3,2));
>        animationPath->insert(0.0,osg::AnimationPath::ControlPoint(startPoint
> , rotation));
>
>        osg::Vec3 endPoint(endMat(3,0), endMat(3,1), endMat(3,2));
>
>                float speed = 1.0; // (m/s)
>                float timeOfAnimation = distanceFromStartPointToEndPoint/speed;
>
>        
> animationPath->insert(timeOfAnimation,osg::AnimationPath::ControlPoint(endPoint
> , rotation));
>
>        matTransNode.setUpdateCallback(new 
> osg::AnimationPathCallback(animationPath));
>
> The animation works, but it seems to me that the speed instantly
> becomes 1m/s and there's no acceleration. So my question is: is there
> a way I can specify that, say, in the first second the acceleration is
> +1 m/s^2, and the next few seconds the acceleration is 0 m/s^2 (so
> that the speed is constant), and then in the last second the
> acceleration is -1 m/s^2?
>
> Thank you very much for your help.
> Best,
> Dat
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to