Question about wheels and terrain penetration

Looking for any help or suggestions on what might cause this to happen quite frequently, vehicle mass isn’t very high, and ive tried to set the suspension quite soft.



A few screenshots:



Raise the maxForce.

Ok, I tried this a few ways, from within the editor and saving the value didn’t seem to go beyond 6,000.

I was assuming in jME the setMaxSuspensionForce, was the same.



so I tried:



[java]

float suspensionForce;

truck.setMaxSuspensionForce(800000);



suspensionForce = truck.getMaxSuspensionForce();

System.out.println(suspensionForce);



[/java]



The results seemed the same.



Edit: Meaning the vehicle could still penetrate the terrain, mainly when jumping, or a hard roll over.

Set the maxSuspensionForce parameter in the properties editor for the Vehicle Control, in code you’d have to set it for each wheel.

I’ve tried it both ways, would this be the correct way in code?



[java]

truck.setMaxSuspensionForce(0, 18000.0f);

truck.setMaxSuspensionForce(1, 18000.0f);

truck.setMaxSuspensionForce(2, 18000.0f);

truck.setMaxSuspensionForce(3, 18000.0f);

[/java]



If you would like, I could upload the project, was also testing out 9 512 quad terrains :slight_smile:

It would be nice to see your code :smiley:

After a bunch more tweaking i"m getting some better results :slight_smile: if I set the suspension any more relaxed the wheels seem to penetrate the ground more frequently.



Video of some testing here: Video link



Code of the truck:



[java]

private void buildTruck() {



final float mass = 700;



matWire = new Material(assetManager, “Common/MatDefs/Misc/WireColor.j3md”);

matWire.setColor(“Color”, ColorRGBA.Red);



//load vehicle and access VehicleControl

Spatial vehicle = assetManager.loadModel(“Scenes/Truck100.j3o”);

//vehicle.setMaterial(matWire);

//then use the control to control the vehicle:

truck = vehicle.getControl(VehicleControl.class);

bulletAppState.getPhysicsSpace().add(truck);



//Set the start Rotation

Matrix3f truckRot = new Matrix3f();

truckRot.setColumn(0, new Vector3f(0,0,-1));

truckRot.setColumn(1, new Vector3f(0,1,0));

truckRot.setColumn(2, new Vector3f(1,0,0));



truck.setPhysicsRotation(truckRot);

//Mass

truck.setMass(mass);

//Gravity

Vector3f gravity = (new Vector3f(0f, -35.0f, 0f));

truck.setGravity(gravity);



//Suspension Stiffness // lower = slower

truck.setSuspensionStiffness(0, 25.5f);//25.5

truck.setSuspensionStiffness(1, 25.5f);

truck.setSuspensionStiffness(2, 25.5f);

truck.setSuspensionStiffness(3, 25.5f);

// Compression // Lower = more suspension travel

truck.setSuspensionCompression(0, 9.5f);//9.5

truck.setSuspensionCompression(1, 9.5f);

truck.setSuspensionCompression(2, 9.5f);

truck.setSuspensionCompression(3, 9.5f);

// Dampening //release higher then stiff Lower = slower suspension recovery

truck.setSuspensionDamping(0, 37.1f);//25

truck.setSuspensionDamping(1, 37.1f);

truck.setSuspensionDamping(2, 37.1f);

truck.setSuspensionDamping(3, 37.1f);



//truck.setAngularFactor(1.1f);



float truckStiffness;

truckStiffness = truck.getSuspensionStiffness();

System.out.println(truckStiffness); //default 5.88.



//Suspension force

truck.setMaxSuspensionForce(0, 9000000000000.0f);

truck.setMaxSuspensionForce(1, 9000000000000.0f);

truck.setMaxSuspensionForce(2, 9000000000000.0f);

truck.setMaxSuspensionForce(3, 9000000000000.0f);



//Roll Influence

truck.setRollInfluence(0, 1.0f);

truck.setRollInfluence(1, 1.0f);

truck.setRollInfluence(2, 1.0f);

truck.setRollInfluence(3, 1.0f);



// Friction

truck.setFriction(2.95f);



truck.setFrictionSlip(0, 2.9f);

truck.setFrictionSlip(1, 2.9f);

truck.setFrictionSlip(2, 2.81f);

truck.setFrictionSlip(3, 2.81f);



vehicle.setShadowMode(ShadowMode.CastAndReceive);

truck.setPhysicsLocation(startLocation);

rootNode.attachChild(vehicle);



camSpatial = vehicle.center();

}

[/java]

Read the javadoc on setting the suspension settings, its quite sensitive at times, the sliders in the jMP Vehicle Editor do the suggested math to create usable settings.

Setting the suspension hasn’t been the issue, I was meaning the more squishy I make the suspension, the more often the wheels will fall through the ground. The more rigid the less it seems to happen.

Yes and what I mean is that seemingly “weak” suspension might just be a combination of wrong other settings, a maxForce of over one Million seems a bit off the chart :wink:

Setting it down to 90,000 seems to have the same results, was over exaggerating it trying to prevent the penetration :slight_smile:

It seems to get a bit worse around 9000. Is it possible to add another ray from the wheel? like a slight angle forward?

You can have the ray for the wheel point almost anywhere, yes.

Here is the jMP project, the vehicles were created with vehicle creator. I’ve tried all the settings before trying to set them in code.

The vehicle that were created with the editor are in the scene dir, 100, is real scale, 200 is double, and 300 is triple size.



The project is here: Project files.



I can’t seem to get it to work either way. Hope this can help :slight_smile:



Edit, w,a,s,d controls, enter resets :slight_smile:

The track is complete, objective: make it around a lap :slight_smile:

Any ideas on this yet?



The idea of this game concept is something between the arcade classics Super off-road and one of my all time fav’s hydrothunder



Both great games imo, were great fun :slight_smile:

I dont have time tinkering with this model, it works with any model since the physics is not geometry dependent, it just depends on the vehicle settings.

OK… in this case it doesn’t seem to work. Did you look at the project? It would be easy to just comment out the settings and use it direct from the created vehicle.



Or maybe offer a setting to use the wheels as bullet objects instead of ray casts?

Just like to add, that the vehicle Truck100, is modeled to actual world size, and I’ve spent prob close to 40 hours trying to get it to work with the terrain. And honestly it is a bit fun in it’s current state, although I would add a bit more rougher terrain throughout if the vehicle could handle it. And if you wanted to you could even add this as some sort of test case. I’m just trying to provide feedback on the vehicle creator :slight_smile:



[Edit:] On a side note, the only use I could see from this point from the vehicle creator is a low profile vehicle, where the hull shape of the body prevents the wheels from being able to penetrate the terrain as in the examples I’ve shown. So in essence this should only be used for a low profile race care type vehicle in this case? Since the hull shape seems to hardly ever penetrate the terrain unless it’s subjected to something more then extreme circumstances.

Bullet natively provides the raycast vehicle as an object, the editor is there to implement it on a model. Creating a car out of joints, cylinders etc. would require a completely different approach. I have used it with three different models and I had problems that I could fix by tweaking the settings as I said but I don’t see how I could solve them generally through the editor. Your problem is the bullet vehicle, not the editor.

So what would you suggest for my case? Did you get a chance to look at the project? Relying on a chance of one certain tweak hardly seems like a stable solution at this point. Or would it be possible to build such a rugged vehicle from within jME and the bullet physics with the wheels being there own bullet shapes?

I looked at your project, when I open the vehicle in the editor, they have a box as collision shape and no wheels attached… The code doesn’t seem to add them either so I don’t really know what you are trying to do. Either you add the wheels to the model in SceneComposer and then edit the vehicle in the VehicleEditor or you assemble the car in code like its done in TestPhysicsVehicle.