And here is the VehicleControl setup function. I do not set the braking anywhere in my code to zero…
public void switchModelToCarMode(AppModel am, Quaternion initRotate) {
Node model;
model = am.model;
float stiffness = am.resource.stiffness;// 120.0f;//200=f1 car
float compValue = am.resource.compression;// 0.2f; //(lower than damp!)
float dampValue = am.resource.damping;// 0.3f;
final float mass = am.resource.mass;
Spatial carNode = model.getChild(0);
carNode.setShadowMode(RenderQueue.ShadowMode.Cast);
Geometry chasis = findGeom(carNode, am.resource.chassis);
BoundingBox box = null;//(BoundingBox) chasis.getModelBound();
CollisionShape carHull = CollisionShapeFactory.createDynamicMeshShape(chasis);
VehicleControl modelCtl = new VehicleControl(carHull, mass);
model.addControl(modelCtl);
am.physicalControl = modelCtl;
//Setting default values for wheels
modelCtl.setSuspensionCompression(compValue * 2.0f * FastMath.sqrt(stiffness));
modelCtl.setSuspensionDamping(dampValue * 2.0f * FastMath.sqrt(stiffness));
modelCtl.setSuspensionStiffness(stiffness);
modelCtl.setMaxSuspensionForce(10000);
Vector3f wheelDirection = new Vector3f(0, -1, 0);
Vector3f wheelAxle = new Vector3f(-1, 0, 0);
Geometry wheel_fr = findGeom(carNode, am.resource.frontRightWheel);
wheel_fr.center();
box = (BoundingBox) wheel_fr.getModelBound();
float wheelRadius = box.getYExtent();
float back_wheel_h = (wheelRadius * 1.7f) - 1f;
float front_wheel_h = (wheelRadius * 1.9f) - 1f;
modelCtl.addWheel(wheel_fr.getParent(), box.getCenter().add(0, -front_wheel_h, 0),
wheelDirection, wheelAxle, 0.2f, wheelRadius, true);
Geometry wheel_fl = findGeom(carNode, am.resource.frontLeftWheel);
wheel_fl.center();
box = (BoundingBox) wheel_fl.getModelBound();
modelCtl.addWheel(wheel_fl.getParent(), box.getCenter().add(0, -front_wheel_h, 0),
wheelDirection, wheelAxle, 0.2f, wheelRadius, true);
Geometry wheel_br = findGeom(carNode, am.resource.backRightWheel);
wheel_br.center();
box = (BoundingBox) wheel_br.getModelBound();
modelCtl.addWheel(wheel_br.getParent(), box.getCenter().add(0, -back_wheel_h, 0),
wheelDirection, wheelAxle, 0.2f, wheelRadius, false);
Geometry wheel_bl = findGeom(carNode, am.resource.backLeftWheel);
wheel_bl.center();
box = (BoundingBox) wheel_bl.getModelBound();
modelCtl.addWheel(wheel_bl.getParent(), box.getCenter().add(0, -back_wheel_h, 0),
wheelDirection, wheelAxle, 0.2f, wheelRadius, false);
modelCtl.getWheel(2).setFrictionSlip(am.resource.backRightWheelFrictionSlip);
modelCtl.getWheel(3).setFrictionSlip(am.resource.backLeftWheelFrictionSlip);
bulletAppState.getPhysicsSpace().add(modelCtl);
if(initRotate!=null) {
modelCtl.setPhysicsRotation(initRotate.multLocal(modelCtl.getPhysicsRotation()));
}
}