Newbie's questions?

realtiger

30-11-2006 08:59:33

Hi all

I have just downloaded OgreNewt, and I have some questions that I can't find any appropriate answers. I hope someone here can help me.

First: What is "timestep"?
Is it the period of time the world should be updated from the last update?
If yes, can I use world->update(2) to get the world after 2 seconds?
I have found that there two kinds of framerate: render framerate, desired_framerate used in OgreNewt:BasicFrameListener.
desired_framerate = update_framerate;

m_update = (Ogre::Real)(1.0f / (Ogre::Real)desired_framerate);

What is the difference between them?
And if m_World->update( m_elapsed ) calculate the world after m_elapsedTime, why we don't use m_World->update( evt.timeSinceLastFrame ) for each frameStarted.
Why do we use this:
if ((m_elapsed > m_update) && (m_elapsed < (1.0f)) )
{
while (m_elapsed > m_update)
{
m_World->update( m_update );
m_elapsed -= m_update;
count++;
}
}
else
{
if (m_elapsed < (m_update))
{
// not enough time has passed this loop, so ignore for now.
}
else
{
m_World->update( m_elapsed );
count++;
m_elapsed = 0.0f; // reset the elapsed time so we don't become "eternally behind".
}
}


Second: What are MaterialID and MaterialPair?
I have found some code which uses MaterialID and MaterialPair to check collision, but I don't actually understand their meaning.

Those are questions I have found now :D
Any help would be appreciated.

albino

30-11-2006 09:02:57

i think that material pair thingis used to make
different things happening to certain objects which have certain material id
not sure though

nathanwilliams6

30-11-2006 09:53:35

a time step is the amount of time you want to update the world buy per step.

if you had a time step of 0.25 seconds (for example) and wanted to update by 2 seconds, you would do 8 updates of 0.25 seconds

this is to keep your simulation accurate and smooth.

incidentally, newton supports frame rates (and consequently time steps) of 60 to 600 fps.

so you will need a timestep of between 1/60 and 1/600

- desired frame rate is the frame rate you want your physics simulation to run at, render frame rate is the frame rate that your rendering engine has achieved (in this case ogre)

- to answer your question about not using m_World->update( evt.timeSinceLastFrame ), its because newton needs to be updated in time slices for an accurate result, and consequently ogrenewt only accepts update times between 1/60th of a second and 1/600th.

- we use the method you outlined because it take the time that has passed and slices it up into time steps for updating.

Materials
----------

a material ID, is the id of the material you want a given object to use. You can then create a material pair between two materials and decide what should happen when those materials collide.

e.g.

you might want a ball colliding with the ground to result in the ball bouncing alot, but the same ball colliding with a cushion not to bounce at all.

for that, the ball, cushion and floor would need a different material.

then you would create a material pair between the ball and cushion, stating in the callback for that collision that you want the ball not to bounce, and create a pair between the ball and floor, stating that you want the ball to bounce.

hope i have cleared things up a little for you

realtiger

30-11-2006 15:45:03

thank nathanwilliams6.
Your explanation is so clear :wink: