Flying vehicle demo
Posted: Mon Apr 08, 2013 5:02 am
I was trying to get vehicle demo working with my mesh, but I encountered a problem.
Here's the code from sample:
If on this line: localTrans.setOrigin(btVector3(0,1,0)); I set number less than 1, car starts to move up to the sky.
Leaving 1 wouldn't be a problem, but returned coordinates for my mesh are aroung 0, -0.2, 0 which leaves my mesh half in the ground.
And the chassisShape box is over my car model.
If I remove compound variable and pass chassisShape to localCreateRigidBody instead, chassisShape perfectly aligns with my car model, but then again... car starts flying into the sky >,<
Can someone tell my how to stop car from flying or how to properly align my mesh with chassisShape?
Here's the code from sample:
Code: Select all
btCollisionShape* chassisShape = new btBoxShape(btVector3(1.f,0.5f,2.f));
m_collisionShapes.push_back(chassisShape);
btCompoundShape* compound = new btCompoundShape();
m_collisionShapes.push_back(compound);
btTransform localTrans;
localTrans.setIdentity();
//localTrans effectively shifts the center of mass with respect to the chassis
localTrans.setOrigin(btVector3(0,1,0));
#endif
compound->addChildShape(localTrans,chassisShape);
tr.setOrigin(btVector3(0,0.f,0));
m_carChassis = localCreateRigidBody(800,tr,compound);//chassisShape);
Leaving 1 wouldn't be a problem, but returned coordinates for my mesh are aroung 0, -0.2, 0 which leaves my mesh half in the ground.
And the chassisShape box is over my car model.
If I remove compound variable and pass chassisShape to localCreateRigidBody instead, chassisShape perfectly aligns with my car model, but then again... car starts flying into the sky >,<
Can someone tell my how to stop car from flying or how to properly align my mesh with chassisShape?