Where is the code does the physics of a Vehicle (Jbullet)

I am looking to make a proper car traction model for my game.

Which class would I be overwriting to do this?
I have looked at the source code but there is no obvious class that I can find that handles it.

Also which part of the source code is it in?

I can contribute it later (if I get far enough)


The first part of the code is here: jmonkeyengine/PhysicsVehicle.java at master · jMonkeyEngine/jmonkeyengine · GitHub

Then you have in Line 129 a “new RaycasterVehicle”. The reason you didn’t find them in JME is because we are simply using the jar lib of JBullet and don’t compile JBullet from scratch.

I didn’t find JBullet on Github (or atleast not the official one), http://jbullet.advel.cz/ is the correct source for that.

Two things to contribution: You would need to make sure that this is a behaviour everyone likes (if it’s a real benefit for us) and then you would have to contribute it to jBullet, so we can simply use their newer libs rather than keeping an own fork (This means more trouble to update everytime).

The second thing is, that I believe I heard plans to drop jBullet since it’s way behind, performance and feature wise. The Lack of a proper way to have contributions, the fact that it’s 11 Versions behind the native one etc aren’t good either.

The only thing was to ensure that the native bullet works properly on every device, which it seems to do (Android might be the only jBullet usecase)

However, if you mean “friction” as in “accelerating without getting faster” or “steering at high speeds doesn’t make my car go around corners”, then it’s simply a matter of getting the Wheels of the PhysicsVehicle and playing around with their friction values. So this is currently possible

Thanks for responding,

So it seems contributing something to Jbullet is a little bit harder than I was expecting. A little out of scope for me I would say.

I originally meant using the ‘Pacejka Magic Formula’ for tyre surface grip. (using slip ratio and slip angle) In my code I currently have slip angle working, currently trying to do slip ratio.

I did actually find that class you linked currently extending it for my car, but I didn’t know that it just passes through to Jbullet directly. This is the file that I wanted: jbullet/RaycastVehicle.java at master · bubblecloud/jbullet · GitHub (even though it might not be the offical one). Thanks for helping me find it.

And if i wanted to rewrite my own physics would i extend RaycastVehicle.java and PhysicsVehicle.java? Or is there some simpler way around that?

Once again thanks for the help,

I explained that wrong: if you wanted it to be in any jme game, you’d go that way probably.

If you use the pluggable approach though (by extending said classes), you could Post your extensions as a User project or something.

This is by far the easiest approach because if you change it directly you would have to compile jme and jbullet from scratch. Also you only need to Code a new constructor for the jme part.

And jme isn’t completely passing but wrapping it for a more javaish and jmeish approach

Thanks for letting me know, I do want to help… but its a lot of work.

I do get the wrapping classes are doing work, but none of it is actually physics simulation related. (which is what I was looking for)

Thank you.

For those interested in what im thinking of doing to get a jme vehicle with different physics:

  • Extending RaycastVehicle.java (so that I can write my own ‘public void updateVehicle(float step)’ method and more)
  • Extending PhysicsVehicle.java (so that I can add ‘vehicle = new MyRaycastVehicle’)
  • Extending VehicleControl (to make it extend my PhysicsVehicle class and just coping the code from the source with my addition).
1 Like

I hope I’m not wrong again, but I thought jme on android used natives (at least on 3.1)? Sorry in advance if I’m wrong.

1 Like