imtrobin
23-11-2006 19:43:56
Hi,
I'm integrating OgreODE into the Practical application without using framelisteners. I can get a box (crate.mesh) from simplescene to drop onto a floor plane successfully. I noticed the box mesh is of size 10x10x10 units so I tried changing scale of the boxgeometry. However, it will fall through the floor if the boxgeomtry is big (> 10)
This is my setup, which is mostly ripped from the SimpleScene demo, except where I scaled the box size.
I'm integrating OgreODE into the Practical application without using framelisteners. I can get a box (crate.mesh) from simplescene to drop onto a floor plane successfully. I noticed the box mesh is of size 10x10x10 units so I tried changing scale of the boxgeometry. However, it will fall through the floor if the boxgeomtry is big (> 10)
This is my setup, which is mostly ripped from the SimpleScene demo, except where I scaled the box size.
// Create the ODE world
mWorld = new OgreOde::World (mSceneMgr);
mSpace = mWorld->getDefaultSpace ();
mWorld->setGravity (Vector3 (0,-9.80665,0));
mWorld->setCFM (10e-5);
mWorld->setERP (0.8);
mWorld->setAutoSleep (true);
mWorld->setContactCorrectionVelocity (1.0);
mWorld->setShowDebugObjects (true);
mStepper = new OgreOde::ForwardFixedInterpolatedQuickStepper (0.01);
mStepper->setAutomatic (OgreOde::Stepper::AutoMode_NotAutomatic, mRoot);
mStepper->setStepListener (&mOgreODEHandler);
// Create a default plane to act as the ground
mPlane = new OgreOde::InfinitePlaneGeometry
(Plane (Vector3 (0,1,0),0),mWorld->getDefaultSpace ());
// Create the visual representation
Entity * entity = mSceneMgr->createEntity ("TestBody", "crate.mesh") ;
SceneNode* node = mSceneMgr->getRootSceneNode ()->createChildSceneNode ("TestBody");
node->attachObject (entity);
entity->setNormaliseNormals (true);
entity->setCastShadows (true);
// Create a body associated with the node we created
mBody = new OgreOde::Body ();
node->attachObject (mBody);
//%%%%% THIS IS WHERE CHANGING THE SIZE WILL MAKE BOX FALL THROUGH FLOOR
// scale box
Vector3 size (50,50,50);
// this makes box bigger as box is 10x10x10
node->setScale (5,5,5);
mGeom = new OgreOde::BoxGeometry (size,mSpace);
OgreOde::BoxMass mass (10.0, size);
mass.setDensity (5.0,size);
mBody->setMass (mass);
// Tie the collision geometry to the physical body
mGeom->setBody (mBody);
// put box 100 units above ground
mBody->setPosition (Vector3 (50, 100, 0));
// In game loop, if step is using elapsed time, it will give assertion error
if (mStepper->step (0.01))
{
mWorld->synchronise ();
}