[osg-users] How can I get last frame time inn order to create indepent FPS aniamtions?

Ricardo Ruiz osgforum at tevs.eu
Mon Nov 23 06:58:29 PST 2009


Thanks Rafa, but it does not work.



Code:

	double angle=0;
	float delta=1;
	while (!viewer.done()) {
		float start=viewer.getFrameStamp()->getReferenceTime();
		angle=angle+0.05*delta;
		viewer.getCamera()->setViewMatrixAsLookAt(osg::Vec3(0,-400,150), osg::Vec3(0,0,0), osg::Vec3(0,0,1));
		viewer.getCamera()->setViewMatrix(osg::Matrix::rotate(angle*DEG_TO_RAD,0,0,1)*viewer.getCamera()->getViewMatrix());			
		viewer.frame();
		float delta=viewer.getFrameStamp()->getReferenceTime()-start;		
	}
	return 0;




Animation is smooth, (I have a ATI 3870 and quadcore) but faster in release than debug (I mean animation, not FPS).
I has no sense. Maybe release version uses some threads that debug not.

Is this the correct way to implement independent animation time?


By the way Rafa, I'm also studing at UPV, a master in software engineering.

Thanks.

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







More information about the osg-users mailing list