OgreNewt::World::update

icounter

20-02-2006 13:50:19

I have seen in documentation that "this function is clamped between values representing fps [60,600]. if you pass a smaller value, it is internally clamped to 60fps. likewise a value higher than 600fps is treated as 600fs."
My problem is that my world is moving verrrrrryyy slowly if I'm calling update only 60 times per second. I can not use a biger time_step to accelerate the phisics, and I don't want to call update 200 times per second, I don't think it is normal and good for perfomance.

Anybody have an ideea about this ? or maybe is something I don't understand right :roll:
It is a solution to call update fewer times and the phisics to work normal ??

haffax

20-02-2006 18:16:18

You can update the world as often or as infrequent as you want, just the smallest step size is 1/60 time units.

With bigger steps, the error will get too big, this is why the step size is clamped. Are you sure, you get a performance problem?

What is your special need in the regard of step size and performance and why?

walaber

20-02-2006 18:58:59

99% chance you think the world is moving "slow" because you are using improper sizes/scale for your physics world.

for example, if you have a box that is (10,10,10) in size, and starts at a position of (0,50,0), it will take a long time to fall at standard gravity (-9.8units/sec^2). that is because with that scale for gravity, your object is 10m x 10m x 10m, and has to fall 50m before it hits the ground! drop an object from 50m sometime. it takes a long time to hit the ground.

you need to make sure whatever scale you use, you are consistent throughout. I suggest using 1unit = 1meter, but if you want to use a different scale, you will need to adjust things like gravity to be accurate to your scale.

icounter

21-02-2006 10:20:12

thanks, for the replys ! :D

here is the code for creating a ball ...

Ogre::AxisAlignedBox box = m_pEntity->getBoundingBox();
float scaleFactor = 36.0f / (box.getMaximum().x - box.getMinimum().x);
m_pSceneNode->setScale(scaleFactor,scaleFactor,scaleFactor);

OgreNewt::Collision *pCol = new OgreNewt::CollisionPrimitives::Ellipsoid(m_pWorld,Ogre::Vector3(18,18,18));
m_pBody = new OgreNewt::Body(m_pWorld,pCol);
Ogre::Vector3 inertia = OgreNewt::MomentOfInertia::CalcSphereSolid(10.0f,18);
m_pBody->setMassMatrix(10.0f,inertia);


m_pPlayerBall->SetPosition(Ogre::Vector3(0,500,50));


If for this I call update only 60 times per second ... the ball is falling very slowly. I don't know .... maybe haffax is right. :(

walaber

21-02-2006 17:15:44

please read my post. you are making a sphere with a radius of 18meters. then you set it 500meters in the air. because you haven't shown your force callback, I'm assuming your using the default one, which is designed for 1unit = 1meter. in that case, you can imagine how long it would take to drop an object from a height of 500 meters!!! a long time!

either adjust the gravity to be of a similar scale to your objects, or adjust the scale of your objects.

icounter

21-02-2006 17:37:19

sorry about that .... i have read your post before :cry: ....
but it was not so clear for me. now it is :shock:
sorry again ... and thanks :roll:

walaber

21-02-2006 19:11:42

no problem :)

l34ndr4

28-02-2006 20:45:56

hi,
about the scaling of the world
I have a problem , to use the default gravity function
my objects have to be in scale 1 unit = 1 meter to work right but, that scale seems to small to make an actual game for u to move in the world or to enter big buildings or houses, and most of all to make tha scaling of the objects REAL for the camera, cause the objects seems to small for an FPS for example.

SO I imagine this function is for examples or small things?

walaber

28-02-2006 21:03:14

what do you mean make the scale REAL for the camera?

there is no "scale" to any 3D engine!!! this includes the lights, cameras, and objects!

for some reason everyone wants to use large scales for their objects... this is because back in the day games like Quake used a large scale because of limitations of the technology that no longer make sense. if you make everything in your game world ahdere to 1unit=1meter (or ANY other scale), everything will work fine. period.

Newton works the best if you use the 1unit=1meter scale, so that is why the built-in force callback uses that scale. if you need your own scale, just make a simple callback with your own gravity constant.

yes, the standardForceCallback is deisgned for simple projects, to get things moving.

CaseyB

28-02-2006 21:07:27

It shouldn't matter! If everything in your world is at 1 unit = 1 meter, then everything will work correctly!