I’ve been following forum posts and using TestFancyCar + TestPhysicsCar, but I can’t get the wheels to work / vehicle to move properly / models to load with collision detection at all times.
Also, I want to program an aircraft, but don’t know where to start. The physics doesn’t have to be great, just needs acceleration.
Any examples I can use for inspiration for aircrafts & vehicles?
1 Like
sgold
May 16, 2021, 6:58am
2
Not a game, but should be helpful:
Yes (and I should have specified) but I’d like to use the native physics libraries & i dont want to use any extra classes – above is good but uses alot of extra classes
1 Like
sgold
May 16, 2021, 7:02am
4
jme-vehicles uses native physics. Why don’t you want extra classes?
I don’t have alot of time to learn how the classes work (because there is a deadline I have to meet)-- I would love to use more but I’ve already studied VehicleControl + javadoc and so it would be alot easier for me to implement something with those
1 Like
This is all you need for a fully working vehicles library wrapping the bullet classes:
dependencies {
implementation 'com.github.stephengold:MaVehicles:0.6.1+for33'
implementation 'com.github.stephengold:Minie:4.1.0+for33'
}
It’s just the core library, not a whole game to learn. I use it in my project. works extremely well and easy to use.
2 Likes
Regarding the aircraft, maybe just setting the RigidBodyControl’s linear velocity in the forward direction will be enough for you:
float velocity=5.0f;
RigidBodyControl ctl = [find your RigidBodyControl];
Vector3f forward = [your node containing the above RigidBodyControl].getLocalRotation().mult(Vector3f.UNIT_Z);
ctl.setLinearVelocity(forward.mult(velocity.floatValue()));
1 Like
sgold
May 16, 2021, 4:10pm
8
What are you doing differently from TestFancyCar?
sgold
May 16, 2021, 4:21pm
9
For flight simulation, see
1 Like
I am using a different model.
Also @sgold is there a .jar file for MavCommon (the one with the examples)?
I cannot use gradle for my project.
Pavl_G
May 17, 2021, 12:03am
11
TheCyberTrotter:
vehicles
Vehicles using jme base classes (Minie) + Nitros + jump forces :
Main code :
private void addEnvLightProbe(){
EnvironmentCamera envCam=new EnvironmentCamera();
stateManager.attach(envCam);
envCam.initialize(stateManager,this);
LightProbe lightProbe=LightProbeFactory.makeProbe(envCam,rootNode);
lightProbe.getArea().setRadius(500);
lightProbe.setPosition(new Vector3f(0,20,0));
rootNode.addLight(lightProbe);
}
private void buildPlayer() {
cam.setFrustumFar(500f);
Material mat = new Material(getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
mat.getAdditionalRenderState().setWireframe(false);
mat.setColor("Color", ColorRGBA.Black);
//create a compound shape and attach the BoxCollisionShape for the car body at 0,1,0
//this shifts the effective center of mass of the BoxCollisionShape to 0,-1,0
CompoundCollisionShape compoundShape = new CompoundCollisionShape();
BoxCollisionShape box = new BoxCollisionShape(new Vector3f(4.2f, 0.8f, 4.5f));
Linear Nitro :
ControlButtonsView controlButtonsView=appCompatActivity.findViewById(R.id.gamePadbtns);
controlButtonsView.addControlButton("X",ControlButtonsView.GAMEPAD_BUTTON_X,ControlButtonsView.DEFAULT_BUTTONS,ControlButtonsView.X_BUTTON_ALPHA)
.setOnClickListener(v -> appCompatActivity.startActivity(new Intent(appCompatActivity.getApplicationContext(), LanLogic.class)));
controlButtonsView.addControlButton("Y",ControlButtonsView.GAMEPAD_BUTTON_Y,ControlButtonsView.DEFAULT_BUTTONS,ControlButtonsView.Y_BUTTON_ALPHA);
controlButtonsView.addControlButton("A",ControlButtonsView.GAMEPAD_BUTTON_A,ControlButtonsView.DEFAULT_BUTTONS,ControlButtonsView.A_BUTTON_ALPHA)
.setOnClickListener(v -> {
vehicle.applyCentralImpulse(jumpForce);
});
controlButtonsView.addControlButton("B",ControlButtonsView.GAMEPAD_BUTTON_B,ControlButtonsView.DEFAULT_BUTTONS,ControlButtonsView.B_BUTTON_ALPHA)
.setOnClickListener(v -> {
vehicle.applyCentralImpulse(vehicle.getLinearVelocity().mult(150));
Node nitroNode=((Node)((Node) chassis).getChild("nitro"));
NitroState nitroState=new NitroState(assetManager,nitroNode,Vector3f.UNIT_Z.negate(),"nitroEffect",new ColorRGBA(0f, 1f, 1f, 0.8f),new ColorRGBA(251f / 255f, 130f / 255f, 0f, 0.1f));
nitroState.setViewPort(viewPort);
stateManager.attach(nitroState);
});
}
@Override
public void destroy() {
// /* deInitializeSensor Service on app exit , to be used with other apps */
Effect :
You can do both of them in the same class
Please donot copy those classes, use them as a reference because there are android parts embedded at the top, you will get red lines if you do on jme SDK.
Pavl_G
May 17, 2021, 12:06am
12
Let us know what are the specifications you want to add to your vehicles…other than aircrafts…
sgold
May 17, 2021, 5:44am
13
There’s no MavCommon JAR available for download, but you could easily build one, by cloning the repo and executing the Gradle wrapper:
sgold:~/Git/jme-vehicles$ ./gradlew :MavCommon:jar
Starting a Gradle Daemon (subsequent builds will be faster)
BUILD SUCCESSFUL in 29s
4 actionable tasks: 4 executed
sgold:~/Git/jme-vehicles$ ls MavCommon/build/libs
MavCommon.jar
sgold:~/Git/jme-vehicles$
Thank you @sgold @Pavl_G . Sorry for the late reply.
I will implement this in my project. Are there any projects of vehicle control / simple projects (no extra libraries) that can drive vehicles?
Thanks!
1 Like
sgold
May 26, 2021, 12:25pm
15
The jme3-examples project includes 4 very simple applications involving vehicles: TestAttachDriver
, TestFancyCar
, TestPhysicsCar
, and TestHoveringTank
.
https://github.com/jMonkeyEngine/jmonkeyengine/tree/master/jme3-examples/src/main/java/jme3test/bullet