Vehicle and wheel with entity

Show what you made with Bullet Physics SDK: Games, Demos, Integrations with a graphics engine, modeler or any other application
Mario Ruiz Perez
Posts: 4
Joined: Tue Oct 22, 2013 1:04 pm

Vehicle and wheel with entity

Post by Mario Ruiz Perez »

Hello guys, I am working in a simulator of vehicles using Ogre and Bullet, but I don't how add entities (.mesh) at the wheels.

My code is:
.....
//Create node of vehicle and entity attached at vehicle.
.....

m_physicsWorld = physicsCtrl->getPhysicsWorld();
btCollisionShape* chassisShape;

//envoltura is a btvector3
chassisShape = new btBoxShape(envoltura);

btCompoundShape* compound = new btCompoundShape();

btTransform localTrans;
localTrans.setIdentity();
localTrans.setOrigin(OrigenChasis);
compound->addChildShape(localTrans,chassisShape);

m_carChassis = physicsCtrl->addRigidBody(this->getEntity(),compound);
m_carChassis->setDamping(0.2,0.2);

m_vehicleRayCaster = new btDefaultVehicleRaycaster(m_physicsWorld);
m_vehicle = new btRaycastVehicle(m_tuning,m_carChassis,m_vehicleRayCaster);
m_physicsWorld->addVehicle(m_vehicle);

m_vehicle->setCoordinateSystem(0,1,2);

bool isFrontWheel;

isFrontWheel = true;
//R0
btVector3 connectionPointCS0(CUBE_HALF_EXTENTS-(ConexionRueda0.x * gWheelWidth),ConexionRueda0.y,ConexionRueda0.z);
m_vehicle->addWheel(connectionPointCS0,wheelDirectionCS0,wheelAxleCS,gSuspensionRestLength,gWheelRadius,m_tuning,isFrontWheel);

//R1
connectionPointCS0 = btVector3(-CUBE_HALF_EXTENTS+(ConexionRueda1.x*gWheelWidth), ConexionRueda1.y, ConexionRueda1.z);
m_vehicle->addWheel(connectionPointCS0,wheelDirectionCS0,wheelAxleCS,gSuspensionRestLength,gWheelRadius,m_tuning,isFrontWheel);

isFrontWheel = false;

//R2
//connectionPointCS0 = btVector3(-CUBE_HALF_EXTENTS+(-3.3*gWheelWidth),connectionHeight,-2*CUBE_HALF_EXTENTS+gWheelRadius);
connectionPointCS0 = btVector3(-CUBE_HALF_EXTENTS+(ConexionRueda2.x*gWheelWidth),ConexionRueda2.y,ConexionRueda2.z);
m_vehicle->addWheel(connectionPointCS0,wheelDirectionCS0,wheelAxleCS,gSuspensionRestLength,gWheelRadius,m_tuning,isFrontWheel);

//R3
//connectionPointCS0 = btVector3(CUBE_HALF_EXTENTS-(-4.3*gWheelWidth), connectionHeight, -2*CUBE_HALF_EXTENTS+gWheelRadius);
connectionPointCS0 = btVector3(CUBE_HALF_EXTENTS-(ConexionRueda3.x*gWheelWidth), ConexionRueda3.y, ConexionRueda3.z);
m_vehicle->addWheel(connectionPointCS0,wheelDirectionCS0,wheelAxleCS,gSuspensionRestLength,gWheelRadius,m_tuning,isFrontWheel);