Jump to content

What exactly does engine.game.setTime do?


photo

Recommended Posts

It doesn't seem to change the output of engine.game.getTime() what am I missing here?

 

Also can somebody explain to me the relationship between engine.game.setIFps() engine.game.setFTime() and engine.game.setScale()?

Link to comment

It doesn't seem to change the output of engine.game.getTime() what am I missing here?

 

little bit strange, since setTime() just set variable which is returned by getTime()

 

void Game::setTime(float t) {
time = t;
}

float Game::getTime() const {
return time;
}

Link to comment

Also can somebody explain to me the relationship between engine.game.setIFps() engine.game.setFTime() and engine.game.setScale()?

 

Best guess (because there are quite some different time values used in the code)

 

setIFps

 

This function forces constant frame time increments between rendered frames returned by engine.game.getTime(). Therefore "logical" frame time increments used for animation/expression update etc. are not dependent on "physical" frame render times. Usefull for fixed-framerate video rendering.

 

For example calling setIFps(0.1) will force a getTime() value sequence between frames next time = last time + 0.1 * scale even if "physical" rendering of each frame would take multiple seconds

 

setFTime

 

Not sure, but it looks like setFTime() can be used to force lower frame update rate than "physical" frame rendering rate. As far as I do understand the code (or not) a call to setFTime(0.1) would causes a frame swap rate of 10Hz ( for scale = 1.0, otherwise higher or lower ) even if rendering a single frame just takes 10 ms and would lead to frame swap rate of 100Hz without VSync.

 

setScale

 

Scales both setIFps and seFTime values to achive "slow motion/fast forward" time steps.

 

It think, Alexander should tell us the truth.

Link to comment

Ulf, you are absolutely right.

 

engine.game.setIFps() sets fixed FPS that doesn't depend on the real FPS. This should be useful when we want to grab the video reel with fixed FPS value (for example, 25 frames per second). When this mode is activated, the frame time value (engine.game.getFTime()) will return the same value as fixed FPS value (from engine.game.setIFps()).

 

engine.game.setFTime() restricts maximum rendering FPS value. There is no difference if the real rendering FPS is lower than the fixed frame FPS. But when the real rendering FPS is higher than the fixed frame FPS, the engine will wait until the fixed frame time is over.

 

engine.game.setScale() scales the speed of rendering, physics and game logic. Rate of simulation of particles and game logic directly depends on the time scale. For example, if the scale equals 2 then the simulation of all effects speeds up two times faster. Physics will be simulated with the same fixed physical FPS, but the number of iterations will be higher or lower (depending on the game scale). In same time you can scale physics FPS separately by using engine.physics.setScale() function.

Link to comment
  • 2 months later...

Ulf, you are absolutely right.

 

engine.game.setIFps() sets fixed FPS that doesn't depend on the real FPS. This should be useful when we want to grab the video reel with fixed FPS value (for example, 25 frames per second). When this mode is activated, the frame time value (engine.game.getFTime()) will return the same value as fixed FPS value (from engine.game.setIFps()).

 

engine.game.setFTime() restricts maximum rendering FPS value. There is no difference if the real rendering FPS is lower than the fixed frame FPS. But when the real rendering FPS is higher than the fixed frame FPS, the engine will wait until the fixed frame time is over.

 

engine.game.setScale() scales the speed of rendering, physics and game logic. Rate of simulation of particles and game logic directly depends on the time scale. For example, if the scale equals 2 then the simulation of all effects speeds up two times faster. Physics will be simulated with the same fixed physical FPS, but the number of iterations will be higher or lower (depending on the game scale). In same time you can scale physics FPS separately by using engine.physics.setScale() function.

 

Ok so I if I set engine.game.setIFPS the game logic seems to run a lot faster. If I set the engine.game.setIFPS to 4 then I have to set engine.game.setSCale to 0.01 to compensate - what is going on here?

Link to comment

Main purpose of engine.game.setIFps() function is to grab screenshots for movie with fixed fps.

Speed of logic in this case depends only on computer performance.

 

yes we are using this code to grab screenshots with a fixed fps. My problem is that when I set the IFps the clouds in the sky etc start to hurtle by at an incredible rate. I can set scene scale to compensate but It seems odd to me that I should.

Link to comment
  • 2 weeks later...

Ok figured it out... I needed to use the reciprical of 25 to set Ifps to 25 frames per second.

It says so in the documentation but is a very deceptively named function. grrrrrr....

Link to comment

Ok figured it out... I needed to use the reciprical of 25 to set Ifps to 25 frames per second.

It says so in the documentation but is a very deceptively named function. grrrrrr....

 

IFps = Inverse FPS :-)

Link to comment
×
×
  • Create New...