Sorry, Got nothing to do in holidays. So flipping the work again.
Hello Merry Christmas first,
void cPhysics::addMesh(CObject* pObj) {
D3DXVECTOR3 vMin, vMax;
pObj->GetMesh()->GetBox(&vMin, &vMax);
float width = vMax.x - vMin.x;
float length = vMax.y - vMin.y;
float height = vMax.z - vMin.z;
btBoxShape *shape = new btBoxShape(btVector3(width / 2.0f, length / 2.0f, height / 2.0f));
m_collisionShapes.push_back(shape);
AgentMotionState* motionState = new AgentMotionState(pObj);
pObj->SetSimMotionState(motionState);
btTransform transform;
motionState->getWorldTransform(transform);
localCreateRigidBody(10.0f, motionState, transform, shape);
}
btRigidBody* cPhysics::localCreateRigidBody(float mass, AgentMotionState* ms, const btTransform& startTransform,btCollisionShape* shape)
{
btAssert((!shape || shape->getShapeType() != INVALID_SHAPE_PROXYTYPE));
//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);
btRigidBody* body = new btRigidBody(mass,0,shape,localInertia);
body->setWorldTransform(startTransform);
body->setContactProcessingThreshold(m_defaultContactProcessingThreshold);
m_dynamicsWorld->addRigidBody(body);
return body;
}
When I specify the second parameter in btRigidBody, all movable objects fall thru thenon-movable ones.
But If I don't, no effects are observed in GameObjects about physics.
Any ideas?
Thanks
Jack