gravity problem

misterface

28-02-2006 20:54:59


int massa=100;
Ogre::Vector3 inertia = OgreNewt::MomentOfInertia::CalcBoxSolid( massa, Ogre::Vector3(1000,1000,1000) );
bod->setMassMatrix(massa , inertia );
bod->setStandardForceCallback();


very strange, mass and inertia are set, but the object doesn't 'fall' to the ground. (collision works)

(other objects like the car from demo5 do fall to the ground)

any idea what can be wrong?

walaber

28-02-2006 20:59:40

your object is 1000x1000x1000 units?

misterface

28-02-2006 21:06:20

your object is 1000x1000x1000 units?

tried 1x1x1 too...
tried to set gravity to 10000

-> no effect

misterface

02-03-2006 00:20:23

... a few days later

everything works :d
ogrenewt rules bigtime!!

but one small problem :p

in example5:


void OgreNewtonApplication::createScene()
{


imported meshed, collision on my objects, everything works fine!
car is moving in my world, has gravity, can flip, all the works :) (camera attached to it also :))
imported mesh with chair, collision works; now the problem: fysics don't work!! very strange, I think my code is correct:


Ogre::Real massa=100;
Ogre::Vector3 inertia = OgreNewt::MomentOfInertia::CalcBoxSolid( massa, Ogre::Vector3(100,100,100) );

bod->setMassMatrix(massa , inertia );
bod->setStandardForceCallback();


tried with other integers, so that can't be the problem




!!!!!!!!!!!!!!!!! -----update--------- !!!!!!!!!!!!!!!!!

could the problem be this:

bod->setMassMatrix(massa , inertia );
bod->setStandardForceCallback();

is in ===> void OgreNewtonApplication::createScene() {....

I suppose this is allowed and has not to be in the framelistener, right?!

misterface

05-03-2006 21:55:25

found the cause of the problem:

OgreNewt::Collision* col5 = new OgreNewt::CollisionPrimitives::TreeCollision( m_World, LevelMSTafelstoelenNode, false);


apparently TreeCollision and
bod->setMassMatrix(massa,inertia );
bod->setStandardForceCallback();


give problems, is treecollsion and setStandardForceCallback compatible?

walaber

05-03-2006 22:56:34

no. TreeCollision objects cannot be dynamic. they are for complex background geometry that will not move no matter what.

if you want complex shapes for dynamic objects, you need to use a compound collision made up of convex shapes.

dynamyt

07-03-2006 20:56:59

how did you fix the problem of the gravity? i too am also having trouble with gravity, would be grateful if you could tell me how you fixed it :)

walaber

07-03-2006 22:47:57

he was trying to apply gravity to a body with a TreeCollision shape, which is not allowed.

what is your problem exactly?

dynamyt

08-03-2006 08:06:21

this is my code :


// BOX BODY
// standard 1x1x1 cube.
Ogre::Vector3 size = Ogre::Vector3( 1, 1, 1 );
Ogre::SceneNode * node = mSM->getRootSceneNode()->createChildSceneNode();
Ogre::Entity * ent = mSM->createEntity("box_body", "barrel.mesh" );
node->attachObject( ent );
node->setScale( size );

// rigid body.
OgreNewt::Collision * col = new OgreNewt::CollisionPrimitives::Box( mWorld, size );
OgreNewt::Body * bod = new OgreNewt::Body( mWorld, col );
bod->attachToNode( node );

// initial position
bod->setPositionOrientation( Ogre::Vector3(0,300,0),Ogre::Quaternion::IDENTITY );
delete col;

Ogre::Real mass = 10.0;
Ogre::Vector3 inertia = OgreNewt::MomentOfInertia::CalcBoxSolid( mass, size );
bod->setMassMatrix( mass, inertia );
bod->setStandardForceCallback();


it just stays there and doesnt fall, floating in mid air :S i yhave also written my own frame listener, all it really is is a basic frame listener with "mWorld->update(100)" in the frameStarted funct.

walaber

08-03-2006 16:03:10

bod->setPositionOrientation( Ogre::Vector3(0,300,0),Ogre::Quaternion::IDENTITY );
delete col;


the OgreNewt::World defaults to a size of (-100,-100,-100) to (100,100,100).
objects outside the world limits will be ignored. make the world bigger with world->setSize().

it just stays there and doesnt fall, floating in mid air :S i yhave also written my own frame listener, all it really is is a basic frame listener with "mWorld->update(100)" in the frameStarted funct.

please change that to a more realistic value. you are asking for it to update as it 100 seconds have passed! Newton will clamp that value to 1/60th of a second. you need to pass a float value that is the time elapsed in seconds.

dynamyt

08-03-2006 20:51:13

w00t, it works now. ty! :D