Gearbox implementation?

Hi Everyone,

I’m doing some research on AI vehicle control, and I want the AI to be able to select options which would improve fuel efficiency.

At the moment, the jme vehicles just have a linear speed (implemented against jme 1.0!) but to get any sensible results, I need to get some RPM and torque measurements in there. My engineering is probably OK enough to model something based on engine rpm (from pressure 0-1 on accelerations pedal), to engine torque out, fed into a gearbox, which depending on gear selected gives an output torque to wheels.

But, if someone has seen this done anywhere already, it would save me alot of time!!


I haven’t seen anything like this pop up in the forum yet. But as you say, its probably not that hard to do and you also probably have an easier time integrating your own code into your project than somebody else’s :slight_smile:

This could be a very interesting little project, especially if you find some API or something that could provide the specs of production cars.

Or maybe I’m just a dreamer who likes driving too much :slight_smile:

Car Physics helped me a lot many years ago, may be of some use now (has a chapter on Fuel Saving Speed which may be applicable).

From my limited experience with this kind of car physics, in a game environment I have found you are way better of faking it with simple approximate formulas than trying to run an accurate simulation - otherwise you inevatably end up lost in complicated physics and when it will have a nightmare of balancing the system.

1 Like

EDIT : * otherwise you inevitably end up lost in complicated physics and will have a nightmare of a time when trying to balance the system.

(sorry, edit button wasn’t working so needed to add a pos, loaded a broken page - correct headers, no content under main topic “gearbox implimentation”)

@thetoucher I think you’re referring to a known issue. This should be fixed in BP 1.5.1 which is already released; we just gotta figure out a plugin incompatibility.

I have attempted this. I’ll post some code later today. It’s not well written, but it works. It uses hingejoint to model each wheel, but in most cases you are better off with raycast vehicle.

1 Like


was thinking about it today… im inclined to agree with thetoucher, as fuel consumption is the thing im interested in, it might be easier to fudge it. i.e. an ‘automatic’ gearbox (i realised modelling the clutch would be a nightmare), where if rpm>6000 & !6th gear then change up gear, if rpm < 4000rpm & !1st gear then change down a gear, then factor out the drive to the suspension by some combo of gear and current rpm.

nagging feeling that i don’t want to get drowned in physics modelling… i thought someone might have made a java vehicle simulator with some realism on this side, and could include that java into the jme sim i’ve got going… but struggling to find much

Just use the raycast vehicle, you only need to care about how much acceleration you apply basically, decide a bit about the tyre friction and off you go. Should not be too hard to check the selected gear, current force applied and vehicle speed to get at least some feeling of a gearbox.

See if you can use this for something:

No guaranties regarding code quality or vehicle simulation correctness.

EDIT: It broke, i have to debug a little. I’ll post when it’s fixed.

EDIT2: Finally works. It was synching issues with scenegraph and phsyicsSpace.

1 Like

I made a google code project for it:

If anyone would be interested in improving the code, I can send credentials via PM.

problem me being dimmer than usual, but i’m getting java.lang.NoClassDefFoundError: ShapeUtilities error? I’ve added the lib you mentioned in the readme to the path… still no joy. Downloaded jme3 (as i’ve built against jme1-ish) and tried from there but still no joy…

figured you might know where that dependency is quicker than me trying to find it!

other plan is that i’ve now got pretty close to normen’s suggestion, just need to figure in some fuel consumption. your code looks alot more indepth so would give me a better solution i think


Ignore the readme file, it’s a left over from another project (TerrainSurface), as is the java.lang.NoClassDefFoundError: ShapeUtilities error. Are you otherwise having any issues?

I’ll change this in SVN, thanx :slight_smile:

Edit: Fixed. Also added a lot of javaDoc and altered scope on variables

works a treat! just looking at how to incorporate it…