Hi,
In my application, i have modelled a simple cube as a BOX-PROXY_SHAPE and am using discrete dynamics. The cube falls under gravity on a groundplane and doesnt come to rest on its face.
I tried implementing this by using the ccdphysicsdemo application as my guideline.
The cube comes to rest with its edge in contact with the gorundplane....and not the face. So the simulation is not realistic.
Kindly help me in this regard.
Thanx,
Sridhar.
Box falls on its edge. It doesn't come to rest on its face
-
- Posts: 3
- Joined: Thu Mar 01, 2007 5:52 am
-
- Posts: 861
- Joined: Sun Jul 03, 2005 4:06 pm
- Location: Kirkland, WA
-
- Posts: 231
- Joined: Tue Feb 20, 2007 4:56 pm
-
- Posts: 861
- Joined: Sun Jul 03, 2005 4:06 pm
- Location: Kirkland, WA
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
-
- Posts: 3
- Joined: Thu Mar 01, 2007 5:52 am
yes.....the Center of gravity(CG) is not above the edge of the box. Even then it rests on the edge, instead of resting on one of the 6 faces of a cube.
I tried to drop the box such that it makes a point contact with the groud plane. Even then immediately after making the contact, it doesnt topple and doesnt come to rest on one of the faces.
I checked the ccdphysics demo, in that demo, the boxes come to rest on one of the faces.
This is my code,
I tried to drop the box such that it makes a point contact with the groud plane. Even then immediately after making the contact, it doesnt topple and doesnt come to rest on one of the faces.
I checked the ccdphysics demo, in that demo, the boxes come to rest on one of the faces.
This is my code,
Code: Select all
btCollisionShape* boxShape = new btBoxShape(btVector3((M.x-m.x)*0.5f, (M.y-m.y)*0.5f, (M.z-m.z)*0.5f)); //need to give btVector3 of halfExtents
boxShape->setMargin(gCollisionMargin);
s = mObjMgr->ObjInstances[i]->Scale;
boxShape->setLocalScaling(btVector3(s, s, s));
btRigidBody* BTWorld::LocalCreateRigidBody(float mass, const btTransform& startTransform, btCollisionShape* shape)
{
//rigidbody is dynamic if and only if mass is non zero, otherwise static
bool isDynamic = (mass != 0.f);
btVector3 localInertia(0,0,0);
if (isDynamic)
shape->calculateLocalInertia(mass,localInertia);
//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
//btMotionState allows the dynamics world to synchronize the updated world transforms with graphics objects
//#define USE_MOTIONSTATE 1
//#ifdef USE_MOTIONSTATE
btDefaultMotionState* myMotionState = new btDefaultMotionState(startTransform);
myMotionState->setWorldTransform(startTransform);
btRigidBody* body = new btRigidBody(mass,myMotionState,shape,localInertia);
body->setCenterOfMassTransform(startTransform);
//#else
// btRigidBody* body = new btRigidBody(mass,startTransform,shape,localInertia);
//#endif
assert(mDynamicsWorld);
assert(body);
mDynamicsWorld->addRigidBody(body);
return body;
}