Page 1 of 1

Make Ogre::Root.getTimer() and Ogre::Timer methods virtual

Posted: Sun Oct 03, 2010 3:58 am
by phoenix_64
Hi,

I currently have some timing issues.
Synchronizing times via Root::renderOneFrame(Real timeSinceLastFrame) and the resulting FrameEvent is possible, but I find one thing very inelegant: Timer::getMicroseconds() etc. doesn't deliver values matching to the manual render time.
E.g. I reset the timer and render 25 frames with a timeSinceLastFrame of 0.04 (exactly 25 fps). One would assume that Timer::getMicroseconds() delivers exactly 1000000 - but it doesn't. Instead, it delivers the "real" time.

In my opinion, a good way to synchronize all times would be to overload the Ogre timer.
To meet this, one would have to overload Root (which contains the timer) and the timer itself. This is a problem, since the timer's methods are not defined virtual, and also Root::getTimer() is not virtual. Making these virtual would not change anything in the Ogre structure, but would make it possible to overload it, if needed. I've tried it and it works fine.

Re: Make Ogre::Root.getTimer() and Ogre::Timer methods virtu

Posted: Sun Oct 03, 2010 9:27 am
by madmarx
It is simply that Ogre::Timer is not meant to do that :) .
There is no 'setTime' or no 'addTime' function in a Ogre::Timer.

Qt's QTime sounds more like what you are looking for.
If you want that badly to use Ogre3D to do synchro (with Ogre::Real), then you can create a fake animation, enabled in your scene, and query where it is (Real AnimationState::getTimePosition (void) const ).

But you can even go for :

Real ControllerManager::getElapsedTime (void) const
void ControllerManager::setElapsedTime (Real elapsedTime)

which is used to control synchro of every animated value (shaders, vertexanimations etc...) things.