Hi Shiina,

A way to do it could to add an update callback that get the world
transform on the object each frame, then for the time you have the
framstamp, or can get the time with osg::Timer::instance()->time_s()
you can store position and time at previous frame, and do your
computation like that:
currentPosition-previousPosition / (currentTime - previousTime)
I guess to have better result you will have to average the value on more
frames.

for update callback you can read the code from
osgAnimation::UpdateTransform from osgAnimation/UpdateCallack

i guess it will give some clue.

Cheers,
Cedric

-  
+33 659 598 614  Cedric Pinson mailto:[email protected]
http://www.plopbyte.net


On Wed, 2009-09-09 at 00:54 +0000, Shiina Ringo wrote:
> Hi,
> 
> Now just a question have troubled me: is that, an object is moving, using the 
> osgAnimation library, here I want to compute the speed of that object's 
> movement, and if using the "V=S/t" to compute the speed, then I donot kown 
> how to get the Distance"S", even the Time"t". Anyone could give me a good 
> idea for this? 
> 
> 
> Thank you very much!
> 
> Cheers,
> Shiina
> 
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=17165#17165
> 
> 
> 
> 
> 
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> 

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to