link3rn3l: Thanks a lot! You are the man!
I finally fixed my car. It is working now, but I do not understand why yet. I am using box shapes for collisions, but they behave very differently, depending on usage. I'll dig into this and, hopefully, find a solution.
I'll spend this weekend on the PhysCar.cpp, clean up it and post the final version. There is too much testing code and harcoded values in it.
Here are some descriptions and parameters for a car. (Based on knowledge gained here on the forum - thanks goes to Kester Maddock for his "Vehicle Simulation With Bullet" paper).
Code: Select all
// The coefficient of friction between the tyre and the ground.
// Should be about 0.8 for realistic cars, but can increased for better handling.
// Set large (10000.0) for kart racers
m_wheelFriction = 10; //BT_LARGE_FLOAT;
// The stiffness constant for the suspension.
// 10.0 - Offroad buggy, 50.0 - Sports car, 200.0 - F1 Car
m_suspensionStiffness = 10.f;
// The damping coefficient for when the suspension is expanding.
// See the comments for m_wheelsDampingCompression for how to set k.
// m_wheelsDampingRelaxation should be slightly larger than m_wheelsDampingCompression, eg 0.2 to 0.5
m_suspensionDamping = 0.2f;
// The damping coefficient for when the suspension is compressed.
// Set to k * 2.0 * btSqrt(m_suspensionStiffness) so k is proportional to critical damping.
// k = 0.0 undamped & bouncy, k = 1.0 critical damping
// 0.1 to 0.3 are good values
m_suspensionCompression = 0.1f;
// The maximum length of the suspension (metres)
m_suspensionRestLength = 0.1f * PHYSCAR_SCALE;
// Reduces the rolling torque applied from the wheels that cause the vehicle to roll over.
// This is a bit of a hack, but it's quite effective. 0.0 = no roll, 1.0 = physical behaviour.
// If m_frictionSlip is too high, you'll need to reduce this to stop the vehicle rolling over.
// You should also try lowering the vehicle's centre of mass
m_rollInfluence = 1.0f;
Note: The car model is from this demo:
http://www.codeproject.com/KB/game/IRRCarSim.aspx
It is modeled in a specific way (dictated by the IPhysics library), so it has to be rotated in a 3D editor, before used. No rotation in game will be needed.
Thanks again, I'll publish the final/fixed version next week.