Code: Select all
if(key_press)velocidad = -2.0f;
vehicle->applyEngineForce(velocidad,2);
vehicle->applyEngineForce(velocidad,3);
The second problem is that I notice that both the chassis and the wheels "tremble" when using the raycast technique, even when the vehicle does not move. I get the position and orientation doing this.
Code: Select all
int i;
float mat_wheel[4][16];
for(i=0;i<4;i++){
vehicle->getWheelInfo(i).m_worldTransform.getOpenGLMatrix(mat_wheel[i]);
}
Code: Select all
btDefaultCollisionConfiguration *colisionconfig = new btDefaultCollisionConfiguration();
btCollisionDispatcher *dispatcher = new btCollisionDispatcher(colisionconfig);
btBroadphaseInterface *broadphase = new btDbvtBroadphase();
btSequentialImpulseConstraintSolver *solver = new btSequentialImpulseConstraintSolver;
btDiscreteDynamicsWorld *world = new btDiscreteDynamicsWorld(dispatcher,broadphase,solver,colisionconfig);
world->setGravity(btVector3(0.0f,-10.0f,0.0f));
Code: Select all
for(i=0;i<4;i++){
btWheelInfo &wheel = vehicle->getWheelInfo(i);
wheel.m_suspensionStiffness = 20.0f;
wheel.m_wheelsDampingRelaxation = 2.3f;
wheel.m_wheelsDampingCompression = 1.0f;
wheel.m_frictionSlip = 1000.0f;
wheel.m_rollInfluence = 0.1f;
}
Code: Select all
world->stepSimulation(1.0f/60f,10);
for(i=0;i<4;i++){
vehicle->updateWheelTransform(i,true);
}
Regards.