Please understand that this is a work in progress and is updated as my time allows. I made this for fun. It is released as open-source for those that wish to develop a car game and would like to see some kind of demonstration of how to go about developing a car in jMonkeyEngine. Contributions are welcome!
I have some questions. Feel free to redirect me to the code or documentation. I’m partly asking them in case there are easy answers or it leads to further discussion… but mostly just so I don’t forget to look up the answers myself if I have to.
I assume that you are not using bullet’s vehicle control and this is custom.
Do you know if it works with jbullet or only native bullet? (I had problems with jbullet in my world with the car not moving at all… even though jbullet works fine in the TestFancyCar.) Edit: the reason I ask is because I would really prefer to use jbullet for ‘reasons’.
What is the licensing on these with respect to commercial use?
I take this to mean that acceleration and braking does not factor into grip? But the code is there… If it works that would be good as I think it’s pretty important with respect to braking/acceleration on turns, front wheel vs rear wheel, etc…
Random comments after watching the video in the first post… so excuse me if these are fixed in later versions. (I will look deeper into all of this hopefully later tonight.)
I agree with grizeldi regarding shadows. Adding the directional light shadow renderer and setting the cast/receive would really make this pop. In my own prototype, it was crucial for knowing when the car is/isn’t on the ground. Yours look like they are floating until they leave the cool tire tracks.
Also, you might consider altering your grid texture to have more variation between the levels of grid lines. Like, really dark on the LARGE grid and a medium level and the smallest being almost invisible. The only reason I saw this is because in the video it just ends up strobing and it’s hard to tell if the car is moving forwards or backwards at some points.
I had this same issue with my bullet character demo. Jaime looked like he was running around backwards until I increased the grid size.
But these are really minor nits on the demo. The tech itself looks super cool.
It uses the Bullet PhysicsVehicle. Its extends its functionailty. For example the PhysicsVehicle provides an accelerate function and I pass it through a graph to determine how much power it delivers at x revs. That’s pretty much how each “extension” of the PhysicsVehicle works.
It works with native bullet, jbullet and the minie library by @sgold .
I got them from sketchfab. If you find a vehicle you like in particular with a license that fits what you want I don’t mind adding it for you.
In order to use both lat and long forces the developer also has to include a “friction circle” - which I did begin to implement, but kind of ran out ot time and entheusiasm, and must admit I did struggle a little trying to provide the feedback the formulas require.
It takes a lot of tweaking. I could spend more time on getting them working. I guess the more interest the library has - the more interest I’ll have in continuing its development.
To actually add a car to a game, you just need to add the CarSelectorState to the stateManager (or just look at the setVehicle method in that class):
stateManager.attach(new VehicleSelectorState(scene, physicsSpace));
Car tourer = new GrandTourer(app);
tourer.getVehicleControl().setPhysicsLocation(new Vector3f(x, y, z));
Note that the scene you pass is the one the car will be added to, and usually has a lightprobe affecting it. I create my scenes with my intelliJ plugin and generate/save a lightprobe in the scene - which is faster than generating one at runtime - so it’s not necesarrily always “rootNode” that you pass as the scene.
I’ve added the shadows and SSAO. Took me a short while to realise the skybox was stopping the shadows working. Had to set it to shadow-mode off.
Fixed the 3rd person camera. Just use the mouse to drag rotate.
Tweaked the Nismo car. The wheels are positioned better and the suspension is more in-key with how it’s supposed to work.
Did a bunch of bug fixes, mainly related to debug data not working when you changed car.
I’ll push a new release in a few days when I’ve tweaked the tourer and added another vehicle. I’m most likely going to replace all the simple models with professional ones, and maybe more variety (bus, monster truck, etc).
I’ve begun to implement longitudinal forces. You will notice now that if you accelerate through a corner you are more likely to skid if you are at high speed and/or rear-wheel. I still need to include braking in these factors, but you can powerslide and recover and not accelerate around corners to avoid sliding, so it’s definitely on its way.
I’ve added the ability to specify wheel models, so each car can use any wheel - they are not model-specific anymore. This basically means that you can swap/upgrade wheels on the fly.
I changed the grid texture to a marble tile instead. The grid was hurting my eyes after a while.
The skid marks now have an alpha value, so light skids make light marks and heavy skids make darker marks. Notice now how they “fade off” instead of abruptly starting and stopping. Pretty cool.
Thanks, man. There’s still a lot to do but it’s definitely fun. The vehicles wheelspin but the gearbox changes when it redlines, so they change instantly. I think it will feel a lot nicer when I fix that so it changes at the right speed and you can tell it’s wheelspinning. Damage would be cool. I guess it never ends
From what I could tell on discord, Riccardo was questioning the hosting costs with Jayfella again. From reading other forum threads it looks like Jayfella has been looking to exit the community because of the lack of growth in jME and that whole discussion prompted him to throw up his hands and he transferred all the server admin stuff over to Riccardo and dropped all his repos from github. He removed all his repos last time this happened so I’m not sure if you should expect them back.
I’m disappointed about the SDK he was working on. I had my particle system running inside of it and was just working on the curve editor. The existing SDK has been a pain to try to create a plugin for so I was hoping for something easier.