objects remain static

Elimentz

07-05-2010 21:16:34

Hi

I'm new to OgreNewt, and I've been trying to get it to work. I compiled everything and I followed a tutorial, but still my objects are NOT moving... I have no idea what I'm doing wrong, so I would appreciate a little help


My world is created like this:

OgreNewt::World* mNtWorld = new OgreNewt::World();




My floor is created like this:

Ogre::Vector3 size(300, 1, 300);
Ogre::Entity* mEntity = sceneMgr->createEntity( name, "floor200x200.mesh" );
Ogre::SceneNode* mEntityNode = sceneMgr->getRootSceneNode()->createChildSceneNode( name+"Node", position );
mEntityNode->attachObject( mEntity );
mEntityNode->setScale( size );
Ogre::SceneNode* mCamNode = 0;

OgreNewt::CollisionPtr col( new OgreNewt::CollisionPrimitives::TreeCollision( ntWorld, mEntity, true, 0 ) );

OgreNewt::Body* mNtBody = new OgreNewt::Body( ntWorld, col );
mNtBody->attachNode( mEntityNode );
mNtBody->setPositionOrientation( Ogre::Vector3(0,0,0), Ogre::Quaternion::IDENTITY );



my objects are created like this:

Ogre::Vector3 size = Ogre::Vector3( 10, 10, 10 );
Ogre::Entity* mEntity = sceneMgr->createEntity( name, "cube.1m.mesh" );
Ogre::SceneNode* mEntityNode = sceneMgr->getRootSceneNode()->createChildSceneNode( name+"EntityNode", position );
mEntityNode->attachObject( mEntity );
mEntityNode->scale( size );
Ogre::SceneNode* mCamNode = mEntityNode->createChildSceneNode( name+"CamNode", Ogre::Vector3(-120,80,0) );

mCamNode->yaw(Degree(-90));

// rigid body
OgreNewt::CollisionPrimitives::Box* boxCol = new OgreNewt::CollisionPrimitives::Box(ntWorld, size, 0, Ogre::Quaternion::IDENTITY, Ogre::Vector3::ZERO );
OgreNewt::CollisionPtr col = OgreNewt::CollisionPtr(boxCol);
OgreNewt::Body* mNtBody = new OgreNewt::Body( ntWorld, col, 0 );
mNtBody->attachNode( mEntityNode );

// initial position
mNtBody->setPositionOrientation( position, Ogre::Quaternion::IDENTITY );

Ogre::Real mass = 10.0;
Ogre::Vector3 inertia, centerOfMass;
boxCol->calculateInertialMatrix(inertia, centerOfMass);

inertia *= mass;

mNtBody->setMassMatrix( mass, inertia );
mNtBody->setCenterOfMass( centerOfMass );

// Gravity
mNtBody->setStandardForceCallback();



The tutorial doesn't say anything about updating the World, so I tried fixing the problem by doing it myself, without success...


mNtWorld->update( evt.timeSinceLastFrame );

kallaspriit

09-05-2010 20:16:39

Make sure you set world size big enough

Elimentz

10-05-2010 08:02:07

Make sure you set world size big enough

Thx mate, that was my error... This was not in the tutorials, unfortunately... Are there any other similar things I should know before I continue programming?

SFCBias

14-05-2010 16:09:39

If you are using a single entity for you map, the best solution would be to set the world size to the size of the entity bounding box