Gravity Problem [solved]

shoki

20-05-2006 18:30:22

Hi there!

So I've got a problem. I'm using OgreNewt and I import a OSM scene from ofusion. Each component from the static scene is declared as a tree collision like that :

OgreNewt::Collision* mCol = new OgreNewt::CollisionPrimitives::TreeCollision(mWorld,pObjNode,true);
OgreNewt::Body* mBody = new OgreNewt::Body(mWorld,mCol);
mBody->attachToNode(pObjNode);
delete mCol;


Else I declare a cylinder who normally has to fall on the floor of my scene... I declare it like that :

Entity* floor;
SceneNode* floornode;
floor = mSceneMgr->createEntity("Floor", "cylinder.mesh" );
floor->setNormaliseNormals(true);
floornode = mSceneMgr->getRootSceneNode()->createChildSceneNode( "FloorNode" );
floornode->attachObject( floor );
Ogre::Vector3 siz(20,5,5);
floornode->setScale( siz );
OgreNewt::Collision* col = new OgreNewt::CollisionPrimitives::Cylinder(mWorld, 2.5, 5);
OgreNewt::Body* bod = new OgreNewt::Body( mWorld, col );
delete col;
bod->attachToNode( floornode );
bod->setPositionOrientation( Ogre::Vector3(0.0,50,0.0), Ogre::Quaternion::IDENTITY );

Real mass = 20.0;
Vector3 inertia = OgreNewt::MomentOfInertia::CalcCylinderSolid( mass, 2.5, 5 );
bod->setMassMatrix( mass, inertia );
bod->attachToNode( floornode );
bod->setStandardForceCallback();


It's the same code as the wiki tutorial, this to only try to have a gravity in my world declared like that :

mWorld = new OgreNewt::World();
mWorld->setWorldSize(Vector3(-2000,-100,-2000),Vector3(2000,1000,2000));


The problem is that gravity doesn't work when I'm importing an OSM Scene, else (without importation) all works perfectly. I don't understand so maybe you can light me :roll:
I just want to remind that OSMScene importer works with TinyXML, maybe it comes from that.

So thx for your help,
++ Shoki

abecam

21-05-2006 15:08:57

As I use TinyXML too (to import a dotScene using the collision tree), it shouln't be the problem, so far it works well for me. I have only this problem having an rigid body inside a convex object (my last post), I am curious to know what is the deal, but I never had a problem with a simple case. Have you try to push a very simple OSM scene (a plane) using this method? It should work.

shoki

21-05-2006 20:42:02

ok thx for your help!

I've found the problem, it was because my newton world wasn't large enough.
But I still have a problem, the collision on the floor is not clean, I've two planes, one upper the other one, and when my cylinder fall down on the floor, it first collides in the air with an invisible object which is not present in my scene and on the floor it stays tilted. But i don't don't know where it come from ( maybe my scene is not "clean"). One end touch the plane but not the other, if it make sense...

So maybe you can help me!
++ shoki

abecam

21-05-2006 20:55:47

This problem I had... It might mean that the created bodies do not correspond to the meshes... Check by pressing F3 where are the collision bodies, if it doesn't match, there is a problem with the scene import. And the mismatch is easier to understand then.

shoki

21-05-2006 22:00:24

Ok thx a lot mate, you're right!
The collision boxes doesn't match with the mesh. But how could I modify the position of my body if it's a treecollision. I've checked the differents constructors but there's nothing to set the position...

Maybe you know,
thx a lot,
shoki

shoki

21-05-2006 22:18:26

Ok sorry I've found, you'll only have to do that :

mBody->setPositionOrientation(pObjNode->getPosition(),pObjNode->getOrientation());

But I've one more problem. When my cylinder is on the floor, the all entity is'nt upon the plan, one part stays under. How could I modify that?

Thx for your help,
Shoki

shoki

22-05-2006 11:12:27

Ok ok, i'm a beginner :?
I've found the solution : the collision box of my cylinder didn't match with my mesh, it was less big!
I begin to understand the system, that's not too hard...

So thx for your help guys,
see you soon,
Shoki