Here's my code:
Code: Select all
///Set above origin
btTransform t;
t.setIdentity();
t.setOrigin(btVector3(0,5,0));
rigidBody->setWorldTransform(t);
physics::world->addRigidBody(rigidBody);
/** Force the bike to stay upright. All movement is allowed except
angular movement around the Z axis. This would cause the bike to roll over.*/
// rigidBody->setAngularFactor(btVector3(1,1,0));
btTransform c;
c.setIdentity();
uprightConstraint = new btGeneric6DofConstraint(
*rigidBody,
btTransform::getIdentity(),
false
);
uprightConstraint->setLimit(0, 1, 0);
uprightConstraint->setLimit(1, 1, 0);
uprightConstraint->setLimit(2, 1, 0);
uprightConstraint->setLimit(3, 1, 0);
uprightConstraint->setLimit(4, 1, 0);
uprightConstraint->setLimit(5, 0, 0);
physics::world->addConstraint(uprightConstraint);
settings = new btRaycastVehicle::btVehicleTuning();
raycaster = new btDefaultVehicleRaycaster(physics::world);
bulletVehicle = new btRaycastVehicle(*settings, rigidBody, raycaster);
bulletVehicle->setCoordinateSystem(0,1,2); ///Bike is sideways if this is set wrong
physics::world->addVehicle(bulletVehicle);