Too much time...

nathanwilliams6

06-11-2006 14:24:50

Im working on a project that uses OgreNewt, i cant go into much detail due to NDA's etc.

But in order to get the simulation to go at a realistic (to life) speed, i had to update elapsed time in the frame listener using a multiplier.

Eg.

m_rElapsed += evt.timeSinceLastFrame * m_rSpeed;

this works fine, but is inherently flawed, in that the newton is doing more calculations than should be needed, ie. every 0.1 secs thats elapsed, Newton does 0.3 secs worth of updates (in steps, like your example frame listener).

Everything in my world is 100 times bigger, i.e. 1 cm = 1 unit. To simulate this properly, and as previously stated by yourself (walaber) i would need to increase gravity force by multiplying it by 100.

I tried this, and although it looked realistic (speed wise), my objects were falling though one another, cylinders were passing through other cylinders and tree collisions.

I think i have done this right, i increased the size of my objects to a factor of 100, and therefore the mass of said objects and gravity by a factor of 100.

Therefore i am left with a:
Object x 100 size
Mass x 100 size
Gravity and other forces x 100 size

and yet, this go pear shaped, things pass though one another, everything seems like its made of led.

Any advice or pointers on how to make this simulation work as intended would be appreciated.

nathanwilliams6

06-11-2006 14:26:31

also, i have tried making everything its proper size, and mass,

i.e. assuming 1 unit = 1 meter,

i have made objects fractions of a unit (i.e sizes measuring in centimeters) and the same thing occurs

nathanwilliams6

21-11-2006 13:51:54

no-one got any ideas ?

why would things pass though one another when i have 100 times more mass to accommodate for the 100 times more size ? doesn't make sense to me.. unless i am missing some major thing ?

any advice would be appreciated

Markness

23-11-2006 01:30:26

Out of interest, what delta time are you using to update OgreNewt? Because the problem you are having could be associated with an uneven timestep either to newton, or between newton and your game.

nathanwilliams6

23-11-2006 12:49:22

i use a timesliced update as follows (the worlds stuff is for enabling and disabling the world, so it doesnt update when the world is disabled)

bool myFrameListener::frameStarted(const Ogre::FrameEvent &evt)
{

if ( m_mWorlds.size() < 1 )
return true;

m_rElapsed += evt.timeSinceLastFrame * m_rSpeed;


m_iWorldIterator = m_mWorlds.begin();

if (m_iWorldIterator->second.s_bWorldEnabled != true)
return true;

if ((m_rElapsed > m_rUpdate) && (m_rElapsed < (0.30f)) )
{
while (m_rElapsed > m_rUpdate)
{
(*m_iWorldIterator).second.s_wWorld->update( m_rUpdate );
m_rElapsed -= m_rUpdate;
}
}
else
{
if (m_rElapsed < (m_rUpdate))
{
// not enough time has passed this loop, so ignore for now.
}
else
{
OGRELOG("--FORCED BIG UPDATE-- " + TOSTRING(m_rElapsed));
(*m_iWorldIterator).second.s_wWorld->update( m_rElapsed );
m_rElapsed = 0.0;
}
}


return true;
}


m_iFramerate = 120;
m_rUpdate = (Ogre::Real) ( 1.0f / (Ogre::Real)m_iFramerate);

Narf

24-11-2006 09:36:21

Hi ^^

I'm new to Ogre, and even newer to Ogrenewt, and there is something i don't know:
Is the mass a relative mass like "g/m3"(and then it's Newton that calculate the real mass) or is it the real mass of the entire object?

If the mass you set is the mass of the entire object, there is a problem. Maybe i'm saying obvious things to you but i keep talking, just in case.

If you multiply size by100, you multiply every edge by 100, so if you have a box with edges measuring x, y and z, the volume that was équal to x*y*z is now equal to x*100*y*100*z*100
that means = x*y*z*100^3.
In this cas, the mass is not simply multiplied by 100 but by 100^3
Dunno if it will solve your problem or even if it will helps, anyway i thought i had to say it =)