Normal world in game

Celest

13-09-2008 01:23:25

How can I code physic world without bouncing and entity (or node) have only frictions and gravity.
(entity stop immediately or little slide along terrain when it falls from air , and collides terrain)

And how can I code to move entity along terrain without using AddForce function (control node directly).

Thanks in advanced :oops:

BardockSSJ

13-09-2008 11:21:30

First Set elastics to 0.0 - this will disable crazy bouncing
You can move node directly by SetPositionOrientation BUT you should remember to calculate velocity and set it by SetVelocity to body.

To calculate velocity you should get FPS and use this complex formula:
velocity = movement_in_this_frame * FPS;


But you should be aware that you give infinite power to body and collision deosnt matter to it.

It is recommended to use AddForce to move (very easy!):
forceToApply = ((desiredVelocity - body->getVelocity()) * BodyMass ) * FPS;

Celest

13-09-2008 23:25:58

First Set elastics to 0.0 - this will disable crazy bouncing

How to set it ? (I use OgreNewt 0.11 and Newton Engine 1.5 but I can't find any related function)

If I use setPosition directly to ogre node. Is it affects on collision primitive ?

BardockSSJ

14-09-2008 14:48:38

No you cant setPosition to node, instead use Body->setPositionOrientation(pos, orientation);


ow to set it ? (I use OgreNewt 0.11 and Newton Engine 1.5 but I can't find any related function)
Use material and create materialPair it can have own elastic, friction softnes and even own contakt callback!

Celest

15-09-2008 00:41:48

I have another problem.

OgreNewt::MaterialID* mat1 = new OgreNewt::MaterialID(mWorld,1);
OgreNewt::MaterialPair* pair1 = new OgreNewt::MaterialPair(mWorld,mat1,mat1);
pair1->setDefaultElasticity(0.00f);


Program breaks here. I don't know why.

Another question. MaterialID is singleton ?

BardockSSJ

15-09-2008 11:09:43

Hehe you need two materials to make pair :P

OgreNewt::MaterialID* mat1 = new OgreNewt::MaterialID(mWorld);
OgreNewt::MaterialID* mat2 = new OgreNewt::MaterialID(mWorld);

OgreNewt::MaterialPair* pair1 = new OgreNewt::MaterialPair(mWorld,mat1,mat2);
pair1->setDefaultElasticity(0.00f);


And you need to set material to body


anBody->setMaterialID(mat1);

And second to another which interract (example mat1 for ground mat2 for player)