void VehicleObject::init_vehicle_physics(const Vector3f& box_size, const PhysObjInfo& info, const VehicleProperties& properties) { m_iright_index = 0; m_iup_index = 1; m_iforward_index = 2; set_vehicle_properties(properties); m_box_size = btVector3((btScalar)box_size.x, (btScalar)box_size.y, (btScalar)box_size.z); //Physics stuff btCollisionShape* pChassisShape = new btBoxShape(m_box_size); m_pListOfCollisionShapes.push_back(pChassisShape); btCompoundShape* pCompoundShape = new btCompoundShape(); m_pListOfCollisionShapes.push_back(pCompoundShape); btTransform localTrans; localTrans.setIdentity(); localTrans.setOrigin(btVector3(0, 1, 0)); pCompoundShape->addChildShape(localTrans, pChassisShape); //Setup chassis btTransform chassisTrans; chassisTrans.setIdentity(); chassisTrans.setOrigin(btVector3(0, 0, 0)); btVector3 localInertia(0, 0, 0); pCompoundShape->calculateLocalInertia(info.mass, localInertia); btDefaultMotionState* vehicleMotionState = new btDefaultMotionState(chassisTrans); btRigidBody::btRigidBodyConstructionInfo cInfo(info.mass, vehicleMotionState, pCompoundShape, localInertia); if(m_rbody) { delete m_rbody; m_rbody = 0; } m_rbody = new btRigidBody(cInfo); m_rbody->setContactProcessingThreshold(1e18f); m_rbody->setUserPointer(&m_entity_id); //initialise other parts of the vehicle init_engine(); init_vehicle(); init_wheels(); }
void init_robot() { init_bumper(); init_body(); init_wheels(); }