Re: [osg-users] moving a vehicle at constant velocity
Hi Alfonso, I'm afraid I already have the KB896256 patch installed because I have Windows XP sp3. I will try to update the nvidia drivers to see if the timer problems are solved. Hmmm, it was just a guess anyways. I have never really seen timer inaccuracies of the order you describe... I'm afraid you're on your own on this. Sorry I couldn't help more. J-S -- __ Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] moving a vehicle at constant velocity
Jean-Sebastien, Robert and all, I'm afraid I already have the KB896256 patch installed because I have Windows XP sp3. I will try to update the nvidia drivers to see if the timer problems are solved. Thank you, Alfonso ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] moving a vehicle at constant velocity
Jean-Sebastien, Robert and all, I'm afraid I already have the KB896256 patch installed because I have Windows XP sp3. I will try to update the nvidia drivers to see if the timer problems are solved. Thank you, Alfonso ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] moving a vehicle at constant velocity
Hi Robert, Alfonso, I still find it curious that your timer is so erratic, the problems that you are having certainly aren't something that lots of people have problems with, yet the task of moving objects around is very common indeed. One thing to check, on Windows XP systems with dual-core processors there are patches you need to install for Windows to handle timers correctly, otherwise it might give results like those you are seeing... Presumably the timer code gets switched from running on one core to the other and that gives a jump in timer values. I just checked to refresh my memory, and there is one Windows patch, one AMD patch (only if you have an AMD CPU) and one modification to boot.ini that you need to make. The details are here: http://forum.notebookreview.com/showthread.php?t=60416 (note: not sure the registry edits are necessary... but the other three are definitely useful) Hope this helps, J-S -- __ Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] moving a vehicle at constant velocity
Hi Alfonso, I still find it curious that your timer is so erratic, the problems that you are having certainly aren't something that lots of people have problems with, yet the task of moving objects around is very common indeed. Robert. On Mon, Jan 26, 2009 at 11:02 AM, Alfonso Callejo Goena wrote: > Hi Robert: > > I have two ways of performing the displacement: > > -- time = nv->getFrameStamp()->getSimulationTime(); >mT.makeTranslate( vehSpeed*time, 0., 0. ); > > -- mT.makeTranslate( dist, 0., 0. ); >dist=dist+avgTime*vehSpeed; // avgTime is the average time per callback > > In the first case jumps appear regardless the vsync is on or off. > In the second case jumps don't appear but, whenever the framerate changes > (for instance by turning vsync off framerate turns from 60 to 160 fps), the > avgTime needs to be recomputed in order to keep the desired velocity. > I think I'm going to adopt the second strategy, but I am still wondering why > the first one doesn't work. > > Thank you, > Alfonso > ___ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] moving a vehicle at constant velocity
Hi Robert: I have two ways of performing the displacement: -- time = nv->getFrameStamp()->getSimulationTime(); mT.makeTranslate( vehSpeed*time, 0., 0. ); -- mT.makeTranslate( dist, 0., 0. ); dist=dist+avgTime*vehSpeed; // avgTime is the average time per callback In the first case jumps appear regardless the vsync is on or off. In the second case jumps don't appear but, whenever the framerate changes (for instance by turning vsync off framerate turns from 60 to 160 fps), the avgTime needs to be recomputed in order to keep the desired velocity. I think I'm going to adopt the second strategy, but I am still wondering why the first one doesn't work. Thank you, Alfonso ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] moving a vehicle at constant velocity
Hi Alfonso, Is it possible to disable the second core? It'd be interesting to see if this affects the quality of the results from the timer. Also are you running your app with vsync enabled? Robert. On Thu, Jan 22, 2009 at 9:22 AM, Alfonso Callejo Goena wrote: > I'm using a Core 2 Duo 1.8 GHz 3 GB and a GeForce 8600 512 MB. > I have seen that some jumps come when the time between callbacks is between > the average 0.016 s and 0.040 s, and others with a delta time higher than > 0.040 s. I can understand the latter jumps, but not the former... > I will try what Jim suggested about computing an average time and > translation between frames, but I don't think this will help because > regardless the delta time between frames, I am eventually multiplying the > velocity by the current time. > Of course if the time returned by the timer is not consistent, the > translation is not computed correctly... Is this possible? > > Thanks, > Alfonso > ___ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] moving a vehicle at constant velocity
I'm using a Core 2 Duo 1.8 GHz 3 GB and a GeForce 8600 512 MB. I have seen that some jumps come when the time between callbacks is between the average 0.016 s and 0.040 s, and others with a delta time higher than 0.040 s. I can understand the latter jumps, but not the former... I will try what Jim suggested about computing an average time and translation between frames, but I don't think this will help because regardless the delta time between frames, I am eventually multiplying the velocity by the current time. Of course if the time returned by the timer is not consistent, the translation is not computed correctly... Is this possible? Thanks, Alfonso ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] moving a vehicle at constant velocity
HI Alfonso, What hardware/OS platform are you working on? I'm wondering if the timer code is not producing consistent results, as even if frame rate changes that speed that an object moves should be related to the time delta between frames. Robert. On Wed, Jan 21, 2009 at 4:30 PM, Alfonso Callejo Goena wrote: > I have disabled the "threaded optimization" of my nvidia GPU and the > simulation runs significantly smoother. > However, if the vehicle's speed is high, the jumps reappear. I have also > examined the osggeometry example, as Paul suggested, and the effect is also > present, though not so clear (this could be because my model is more complex > than the 2D texture of the example). > I don't know if it is a hardware problem or it is caused by the unconstant > refresh rate of the update callback. Is there any possibility that the > frequency of the update callback is smaller than the 25 fps needed to have a > smooth movement? > > Thanks a lot, > Alfonso > ___ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] moving a vehicle at constant velocity
I have disabled the "threaded optimization" of my nvidia GPU and the simulation runs significantly smoother. However, if the vehicle's speed is high, the jumps reappear. I have also examined the osggeometry example, as Paul suggested, and the effect is also present, though not so clear (this could be because my model is more complex than the 2D texture of the example). I don't know if it is a hardware problem or it is caused by the unconstant refresh rate of the update callback. Is there any possibility that the frequency of the update callback is smaller than the 25 fps needed to have a smooth movement? Thanks a lot, Alfonso ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] moving a vehicle at constant velocity
>I am trying to move a vehicle on scene by means of an update callback. It >should be a realistic simulation, and I want the vehicle to move, for >instance, at a constant velocity of 5 m/s. >The callback function I have written has the following aspect: If the frame-rate surges/stalls often, you might have to average the time between frames, then translate by a nearly-constant vector. Every n seconds, recompute the average time and translation vector. Or get a faster system (no sarcasm). ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] moving a vehicle at constant velocity
Alfonso Callejo Goena wrote: I have changed the line double t = osg::Timer::instance()->time_m()/1000; by double t = nv->getFrameStamp()->getSimulationTime(); and the rough behaviour persists. In fact they are almost the same... How does the osggeometry example run for you? Does it show these 'jumps' as well? That example is about as simple as use of the simulation time to drive a transform can get (see the MyTransformCallback class). Paul ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] moving a vehicle at constant velocity
I have changed the line double t = osg::Timer::instance()->time_m()/1000; by double t = nv->getFrameStamp()->getSimulationTime(); and the rough behaviour persists. In fact they are almost the same... Using osgSim would help me in such a simple case? Thanks, Alfonso ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] moving a vehicle at constant velocity
Hi Alfonso, Use the osg::FrameStamp object that used by the OSG to record the time of a frame, this object is maintained by the Viewer, and is passed into the callback via the NodeVisitor. So do: nv->getFrameStamp()->getSimulationTime(); Robert. On Wed, Jan 21, 2009 at 9:52 AM, Alfonso Callejo Goena wrote: > Hello: > > I am trying to move a vehicle on scene by means of an update callback. It > should be a realistic simulation, and I want the vehicle to move, for > instance, at a constant velocity of 5 m/s. > The callback function I have written has the following aspect: > > osg::Matrix mT, dmT; // global variables containing the current and > differential translations of the vehicle > > > class myUpdateCallback : public osg::NodeCallback { > public: > myUpdateCallback() { > vehSpeed=5/3.6; // 5 km/h in m/s > tLast=0.; > } > virtual void operator()( osg::Node* node, osg::NodeVisitor* nv ) { > osg::MatrixTransform* mTransf = dynamic_cast( > node ); > > double t = osg::Timer::instance()->time_m()/1000; > double dt=t-tLast; > dmT.makeTranslate( vehSpeed*dt, 0., 0. ); > mT=mT*dmT; > tLast=t; > > mTransf->setMatrix( mT ); > traverse( node, nv ); > } > protected: > double tLast; > double vehSpeed; > }; > > The thing is that the resulting movement is not smooth, it has > discontinuities like little "jumps". I think this can be related with the > frequency the program performs the callback (around 62 Hz), but I don't know > how to solve it. > Thank you in advance for your help. > Fusu > ___ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] moving a vehicle at constant velocity
There is a simulation time in the osg core. i would use this time as base of a simulation. and my you should have a look at simulation libaray 2009/1/21 Alfonso Callejo Goena > Hello: > > I am trying to move a vehicle on scene by means of an update callback. It > should be a realistic simulation, and I want the vehicle to move, for > instance, at a constant velocity of 5 m/s. > The callback function I have written has the following aspect: > > osg::Matrix mT, dmT; // global variables containing the current and > differential translations of the vehicle > > class myUpdateCallback : public osg::NodeCallback { > public: > myUpdateCallback() { > vehSpeed=5/3.6; // 5 km/h in m/s > tLast=0.; > } > virtual void operator()( osg::Node* node, osg::NodeVisitor* nv ) { > osg::MatrixTransform* mTransf = > dynamic_cast( node ); > > double t = osg::Timer::instance()->time_m()/1000; > double dt=t-tLast; > dmT.makeTranslate( vehSpeed*dt, 0., 0. ); > mT=mT*dmT; > tLast=t; > > mTransf->setMatrix( mT ); > traverse( node, nv ); > } > protected: > double tLast; > double vehSpeed; > }; > > The thing is that the resulting movement is not smooth, it has > discontinuities like little "jumps". I think this can be related with the > frequency the program performs the callback (around 62 Hz), but I don't know > how to solve it. > Thank you in advance for your help. > Fusu > > ___ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > -- Adrian Egli ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] moving a vehicle at constant velocity
Hello: I am trying to move a vehicle on scene by means of an update callback. It should be a realistic simulation, and I want the vehicle to move, for instance, at a constant velocity of 5 m/s. The callback function I have written has the following aspect: osg::Matrix mT, dmT; // global variables containing the current and differential translations of the vehicle class myUpdateCallback : public osg::NodeCallback { public: myUpdateCallback() { vehSpeed=5/3.6; // 5 km/h in m/s tLast=0.; } virtual void operator()( osg::Node* node, osg::NodeVisitor* nv ) { osg::MatrixTransform* mTransf = dynamic_cast( node ); double t = osg::Timer::instance()->time_m()/1000; double dt=t-tLast; dmT.makeTranslate( vehSpeed*dt, 0., 0. ); mT=mT*dmT; tLast=t; mTransf->setMatrix( mT ); traverse( node, nv ); } protected: double tLast; double vehSpeed; }; The thing is that the resulting movement is not smooth, it has discontinuities like little "jumps". I think this can be related with the frequency the program performs the callback (around 62 Hz), but I don't know how to solve it. Thank you in advance for your help. Fusu ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org