Frame speed

mnm23

07-09-2006 15:22:19

Hey guys. Any idea how i can slow down my frame speed. Ive tried adding a seperate frame class so i can control the speed from there but that isnt working. Currently in game im getting 400 frames per seccond which is effecting my gravity and movement. Thanks again guys.

betajaen

07-09-2006 15:55:39

Turn on VSync?

mnm23

07-09-2006 16:09:14

Turn on VSync. Whats that.

betajaen

07-09-2006 17:23:51

mnm23

07-09-2006 19:16:10

Ok i see what you mean. This did help but my gravity is still off. The character falls slower than supposed to. As well my animation is being timed right. I even tried multiplying the last frame by a smaller or larger number and this still didnt help.

DaCracker

07-09-2006 20:04:11

just increase the gravity value in nxOgre to fix the
character's slow gravity :wink:

betajaen

07-09-2006 20:32:55

Well if VSync is on, it's around ~60FPS right?.

In Scene::Simulate instead of using time.sinceLastFrame just use 1.0/60.0f

M@gg!

07-09-2006 21:00:41

Well if VSync is on, it's around ~60FPS right?.

The problem is, that it is only running at 60FPS if your PC is fast enough.

I've tested it. When you go under the 60 FPS, you'll get a slowmo effect!

Wretched_Wyx

08-09-2006 06:14:59

I thought VSync capped your FPS at whatever your refresh rate was to make it smoother... IE a good refresh rate would be 85Hz. So if your running at 60fps, with VSync on, wouldn't that mean that you have your monitors refresh rate set at 60Hz? That would give me a headache working with that all the time. Try setting your refresh rate to 85Hz and then try it.

I could be wrong about this though... I'm only throwing my 2 cents in from experience. Whenever I run an Ogre app with VSync on, my frame rate is steady at 85fps, as my refresh rate is the same- so I just assume this is how it works.

betajaen

08-09-2006 09:10:09

Either way hertz or FPS (it's the same thing). Slower computers would have the slow-mo effect, so your back to evt.sinceLastFrame again.

I do have one more trick up my sleeve though, I believe you can set the integrator to "fixed".

M@gg!

08-09-2006 14:29:29

Wretched_Wyx: I use a TFT.

Either way hertz or FPS (it's the same thing). Slower computers would have the slow-mo effect, so your back to evt.sinceLastFrame again.

*#ß"?=?)##*

But the evt.sinceLastFrame is not the real value, as I pointed out before.

Ogre uses average values and that's the reason, why it's causing problems, when you use it for PhysX and why NxOgre needs his own accurate timer.

betajaen

08-09-2006 15:42:13

Average values? Where did you get that from?

M@gg!

08-09-2006 20:39:56

From my own observations, because the time values are defenitly not the right ones.

After this:
From a friend, who has already set up a project with Ogre.

And at last:
From this THREAD.

ogre smooth "timeSinceLastFrame" value by averaging it during the last 0.5 seconds.
this may be the cause of your problem.
Using directly the Timer is the solution, as you did here.

M@gg!

08-09-2006 21:14:51

Ok, now I'm a litle confused, because I found this in the API:


void Ogre::Root::setFrameSmoothingPeriod ( Real period )

Sets the period over which OGRE smooths out fluctuations in frame times.


Remarks:
OGRE by default gives you the raw frame time, but can optionally smooths it out over several frames, in order to reduce the noticeable effect of occasional hiccups in framerate. These smoothed values are passed back as parameters to FrameListener calls.
This method allow you to tweak the smoothing period, and is expressed in seconds. Setting it to 0 will result in completely unsmoothed frame times (the default).

M@gg!

08-09-2006 21:27:25

Ok, I've tested it. The smoothing is per default off.

Maybe I was realy on the wrong track, but why do the projectiles still fly different with the same setting and doesn't so, when I use fixed timesteps?

betajaen

08-09-2006 21:35:57

That still puzzles me.

But try this:

nxOgre::blueprint<nxOgre::scene> bp;
bp.toDefault();
bp.setFixedTimestep();
bp.setMaxTimestep(1.0f/60.0f);
mScene = bp.create(...);


If that doesn't work, you could try the setVelocity function of body.

body.h
void setLinearVelocity(Ogre::Vector3 direction, float velocity);

body.cpp
void body::setLinearVelocity(Ogre::Vector3 direction, float velocity) {
NxVec3 vel = NxTools::convert(direction);
vel.normalize();
vel *= velocity;
mActor->setLinearVelocity(vel);
}

mnm23

09-09-2006 00:04:37

Hey betajaen, thanks for the help. I tried 1/60.0f as well and that didnt slow down the animation. I dont understand why im uunable to control this. It may be my code but i have used this same update method before so i know it works. Its a simple update that takes in the time for the animation.

mnm23

09-09-2006 00:12:03

Ok so once again i should look at my code closer before i talk about how perfect it is. LOL I forgot to add a little snipet of code.

this->mAb->addTime(aTime);



Thanks for the help it works much better now. As for the gravity though that is still off. Any other suggestions besides actually going into the SDK and changing it there. Also on a different topic why doesnt changing the mass to either the body or the character actually have an effect on them.

betajaen

09-09-2006 09:39:07

After you create the body?

You have call that function to recalculate the mass in mActor, the name escapes me for now.