I’ve released version 1.1.0 of More Advanced Vehicles: Release Release v1.1.0 · stephengold/jme-vehicles · GitHub
I’m getting comfortable with the project. The next release will have a prettier 3-D model for the pickup truck and will include @adi.barda 's racetrack environment to drive in:
Looks really neat… makes me want to try it.
A small thing but I wonder why the track pieces don’t line up quite right. (I only noticed that after looking for a while.)
Yeah, I noticed that too.
If someone with mad GIS skills would point me in the right direction, I’d love to love to create heightmap environments based on real places … maybe Pikes Peak in Colorado …
Adjusting the track pieces in the corners is a little bit tricky with Assets Forge software. I’ll try to fix that when I have time and update the model in github
Yeah, I’d just expect the Asset Forge models to already want to line up since that’s what they are designed for. So I wondered if it was a coding problem somewhere.
I’ve released version 1.2.0 of More Advanced Vehicles: https://github.com/stephengold/jme-vehicles/releases/tag/v1.2.0
At this point, constructive feedback would be welcome.
Screenshots are coming soon to a topic near you!
Thank you Stephen! Amazing work. I’m going to integrate the new version ASAP.
One question though - What is the best way to change the key mapping? currently I’m inheriting BasicVehicleInputState and send to the constructor the desired key mapping in a HashMap<> but that requires me to change all the FunctionId’s accessors (in BasicVehicleInputState) to Public so I’m not sure what I’m doing is best practice…
Here the custom VehicleInputState code:
public class SceneMaxVehicleInputState extends BasicVehicleInputState {
private final HashMap<String, Integer> inputSource;
public SceneMaxVehicleInputState(Vehicle vehicle, HashMap<String, Integer> inputSource) {
super(vehicle);
this.inputSource=inputSource;
}
private int getControlKey(String funcName, int defaultKey) {
if(inputSource.containsKey(funcName)) {
return inputSource.get(funcName);
}
return defaultKey;
}
@Override
protected void initialize(Application app) {
inputMapper = GuiGlobals.getInstance().getInputMapper();
inputMapper.map( F_START_ENGINE, getControlKey("start", KeyInput.KEY_Y) );
inputMapper.map( F_MOVE, getControlKey("move", KeyInput.KEY_W) );
inputMapper.map( F_MOVE, InputState.Negative, getControlKey("stop", KeyInput.KEY_S) );
inputMapper.map( F_TURN, getControlKey("left", KeyInput.KEY_A) );
inputMapper.map( F_TURN, InputState.Negative, getControlKey("right", KeyInput.KEY_D) );
inputMapper.map( F_REVERSE, getControlKey("reverse", KeyInput.KEY_E) );
inputMapper.map( F_HANDBRAKE, getControlKey("handbrake", KeyInput.KEY_Q) );
inputMapper.map( F_RESET, getControlKey("reset", KeyInput.KEY_R) );
inputMapper.map( F_CAMVIEW, KeyInput.KEY_F5);
inputMapper.map( F_HORN, getControlKey("horn", KeyInput.KEY_H) );
inputMapper.addStateListener(this,
F_START_ENGINE, F_MOVE, F_TURN, F_REVERSE, F_HANDBRAKE, F_RESET, //F_LEAVE,
F_HORN,
F_CAMVIEW
);
}
}
The way the original author setup this code makes it a little harder to reconfigure… but it is possible.
Note: that it’s fine for a function to have multiple mappings.
If you want to completely replace the existing mappings without access to where they are setup, you can remove the existing ones:
http://jmonkeyengine-contributions.github.io/Lemur/javadoc/Lemur/com/simsilica/lemur/input/InputMapper.html#getMappings-com.simsilica.lemur.input.FunctionId-
http://jmonkeyengine-contributions.github.io/Lemur/javadoc/Lemur/com/simsilica/lemur/input/InputMapper.html#removeMapping-com.simsilica.lemur.input.InputMapper.Mapping-
…and then just set your own, replace only the one you are interested in, or whatever.
An aside: one practice I’ve adopted in some of my own newer code is to check to see if there is an existing mapping before adding a default. In that case, you could have just made sure to map your own first.
Adi:
It seems you have a fork of this project which I hadn’t known about.
At this moment, the easiest way to change key mappings is simply to edit the source code. (It’s open-source, so feel free.)
I should be able to add methods to customize the key mappings. Let’s see what I come up with…
I think I’m using the latest Jayfella version, I will update to your version soon.
Thanks!
I’m curious about your modifications: were they simply to localize the application to non-US keyboards, or were there other changes as well?
I almost didn’t modify anything, Just disabled the camera and allowed different mapping. Actually I’m not using most of the capabilities of the application just the car entity / physics & gauges. My goal is to enable 10 years old kids to write their own car racing game and this library makes it simple.
You may find v1.2.0 difficult to reuse in that way, because I envisioned More Advanced Vehicle as a complete application, not a library.
I understand. I think its best to have in that complete application a set of independent loosely coupled core components that the community can consume for their own applications. It’s good for JME to have a solid starting point for car games.
Yes, a solid starting point is definitely the goal.
However, this project has a way to go before it reaches that goal. A solid starting point would definitely handle multiple vehicles in a single world. It would handle motorcycles as well as cars. It could be played using a joystick or a game controller—and maybe over a network.
While working, I keep a lookout for code that might be reusable in future projects. There are some candidates (AnimatedMenu, DriverHud, Expander, InputMode, Loadable, Suspension), but overall I think the project’s too immature to package them up as a library.
I’ll incorporate that update. Thank you!
As suspected, it was a JMonkeyEngine issue. Issue 1459, to be precise.
Updated racetrack model and updated screenshots are still on the to-do list…
After much procrastination, I’ve created a walkthru video … or perhaps I should call it a “drivethru video” It’s less than 10 minutes long and available from YouTube. Please watch it and send me your reactions.
PS: I added subtitles (CC) in English (in case my narration is difficult to understand).