Vehicle Creator testing

Hello, Ok I had to try it with a rough vehicle object, my first attempt at loading in a .j3o vehicle in jME gives me this:







I’m not sure if it’s possibly something I did wrong in the vehicle setup / scene setup.

Well that code was not supposed to be just pasted into some BasicGame project xD To use physics you have to create a physics app state: https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:beginner:hello_physics

This BasicGame is using the bullet app state.



[java]

public void simpleInitApp() {

bulletAppState = new BulletAppState();

stateManager.attach(bulletAppState);



setupKeys();

createTerrain();



buildTruck();

createChaseCamera();



//Ambient Light

AmbientLight al=new AmbientLight();

al.setColor(new ColorRGBA(1.8f,1.8f,1.8f,1.0f));

rootNode.addLight(al);



//used for shadow projections with ambient lighting.

//Vector3f lightDir = new Vector3f(-0.1f, -0.5f, -1.0f).normalizeLocal();

}

[/java]

Then just replace physicsSpace with bulletAppState.getPhysicsSpace() in my example…

Thanks again normen! :slight_smile: I think at this point I just need to get the cam and controls configured :slight_smile:

After getting a bit further, I’m not seeing a way to create a target for a chase cam. I can see the wheels rotating with the key presses, but not sure how to add a node for a chaseCam at this point.



The current project looks like this:



[java]



public class Truckin extends SimpleApplication implements ActionListener{



private BulletAppState bulletAppState;

private VehicleControl truck;

Spatial camSpatial;

private float steeringValue = 0;

private float accelerationValue = 0;



//Terrain

TerrainQuad startTerrain;

RigidBodyControl terrainPhysicsNode;



Material matRock;

Material matWire;



// chaseCam

ChaseCamera chaseCam;



public static void main(String[] args) {

Truckin app = new Truckin();

app.start();

}





@Override

public void simpleInitApp() {



bulletAppState = new BulletAppState();

stateManager.attach(bulletAppState);



setupKeys();

createTerrain();



buildTruck();

//createChaseCamera();



//Ambient Light

AmbientLight al=new AmbientLight();

al.setColor(new ColorRGBA(1.8f,1.8f,1.8f,1.0f));

rootNode.addLight(al);



//used for shadow projections with ambient lighting.

//Vector3f lightDir = new Vector3f(-0.1f, -0.5f, -1.0f).normalizeLocal();

}

private PhysicsSpace getPhysicsSpace(){

return bulletAppState.getPhysicsSpace();

}

/*

private void createChaseCamera() {

flyCam.setEnabled(false);



chaseCam = new ChaseCamera(cam, camSpatial, inputManager);

}

*/

private void buildTruck() {





//load vehicle and access VehicleControl

Spatial car = assetManager.loadModel(“Scenes/Truck1.j3o”);



truck = car.getControl(VehicleControl.class);



rootNode.attachChild(car);



bulletAppState.getPhysicsSpace().add(truck);



//then use the control to control the vehicle:

truck.setPhysicsLocation(new Vector3f(10,2,10));

truck.accelerate(100);



//camSpatial.lookAt().car;

}



private void setupKeys() {

inputManager.addMapping(“Lefts”, new KeyTrigger(KeyInput.KEY_A));

inputManager.addMapping(“Rights”, new KeyTrigger(KeyInput.KEY_D));

inputManager.addMapping(“Ups”, new KeyTrigger(KeyInput.KEY_W));

inputManager.addMapping(“Downs”, new KeyTrigger(KeyInput.KEY_S));

inputManager.addMapping(“Space”, new KeyTrigger(KeyInput.KEY_SPACE));

//inputManager.addMapping(“Reset”, new KeyTrigger(KeyInput.KEY_RETURN));

inputManager.addListener(this, “Lefts”);

inputManager.addListener(this, “Rights”);

inputManager.addListener(this, “Ups”);

inputManager.addListener(this, “Downs”);

inputManager.addListener(this, “Space”);

//inputManager.addListener(this, “Reset”);

}



public void onAction(String binding, boolean value, float tpf) {

if (binding.equals(“Lefts”)) {

if (value) {

steeringValue += .5f;

} else {

steeringValue += -.5f;

}

truck.steer(steeringValue);

} else if (binding.equals(“Rights”)) {

if (value) {

steeringValue += -.5f;

} else {

steeringValue += .5f;

}

truck.steer(steeringValue);

} //note that our fancy car actually goes backwards…

else if (binding.equals(“Ups”)) {

if (value) {

accelerationValue -= 800;

} else {

accelerationValue += 800;

}

truck.accelerate(accelerationValue);

} else if (binding.equals(“Downs”)) {

if (value) {

truck.brake(40f);

} else {

truck.brake(0f);

}

} else if (binding.equals(“Reset”)) {

if (value) {

System.out.println(“Reset”);

truck.setPhysicsLocation(Vector3f.ZERO);

truck.setPhysicsRotation(new Matrix3f());

truck.setLinearVelocity(Vector3f.ZERO);

truck.setAngularVelocity(Vector3f.ZERO);

truck.resetSuspension();

} else {

}

}

}



private void createTerrain() {

***

}

[/java]

You don’t need a node, you need a spatial, basically use the car chassis geometry…

:slight_smile: Vehicle creator working! I ended up setting up the chase cam using car.center :slight_smile: . Now I just need to make another version with the vehicle facing the right direction. Atm it’s running backwards.



Test driving.



Video sample of the created vehicle :slight_smile:



Video here

1 Like

Heh, cool, always love to see stuff done with jME / jMP :smiley:

Updated Video after some tweaking:



Video → Link.



Source files for whoever wants to play around :slight_smile:



Source files → Source files.



Still tweaking settings and scale.

1 Like

Cannot accelerate, steer or control the vehicle using WASD in vehicle test mode.
Do I need to create a custom control for configuring key listeners?

Hm, it should have them attached, make sure the OpenGL window is selected and frontmost.

I’ve attached the wheels geometries and the chasis geometry as hull (They are inverted when the model is updated or when hitting test vehicle)
The Vehicle Creator netbeans topComponent is at topmost selected. Hit any of W, S, A, D and every other key in the keyboard and nothing.
I have a Mac but also installed the SDK in a PC and got the same result.
Am I missing something or there is a bug? I can’t find videos from anyone using the Vehicle Creator and testing the vehicle.

Thanks

In our demo video you can see it in action, it does (or did) work. Did you try clicking the OpenGL window to make it get the focus as I asked you to?

Thanks for your help.

If you are talking about the window titled “Vehicle creator”, I did. And try in many ways by clicking inside the 3d view, the header tab, topComponent toolbar, etc. with no avail. Should I look for a window titled OpenGL?
Plus, when I update the vehicle after assigning the wheels and the hull, the wheel get flipped 180 degrees. After saving it and opening again, the wheel’s face that is supposed to look to the outside, faces to the inside and the wheels are all moved together to the the center below the hull or to the top. All fused together. It is noticeable when the car is imported into the Scene composer.

Would you give me the link to that video of vehicle testing?

Thanks very much for your support.

Sorry for adding to an old thread, but I see that it had been updated within the last two weeks by someone who is having the exact same issue as me …

I have created a simple go-kart model in blender (v 2.6.5) and exported it using blender2ogre (v 0.5.9) which results in: kart.scene, kart.material, and five pairs of files (XYZ.mesh / XYZ.mesh.xml) one for the body mesh and one for each of the four wheels. I converted the kart.scene file to kart.j3o and opened this in the Vehicle Creator. Next I selected the body and clicked “create hull shape from selected” and then selecting each of the four wheels in turn I clicked “make selected spatial wheel” (ticking “front wheel” for the appropriate two). When I press “test vehicle” my kart is seen to drop a short distance before connecting with the tarmac and when it does there is an appropriate ‘springyness’ between the wheels and body to suggest that the suspension is being modelled correctly, but pressing W,A,S,D has no effect. I have double-checked that the Vehicle Creator opengl window has focus (I can click and drag to rotate the view around my kart while the test runs) but there is no steering or acceleration effect when I press the controls. I have tried increasing the default acceleration force from 800 to 80,000 but my kart still remains stationary when I hold W.

I am using jMonkeyEngine 3.0RC2 and I have run ‘Help -> Check for Updates’ until no more are available.

In the Scene Explorer window, each Wheel looks like this:

Wheel_[location]-WheelNode - Wheel_[location] - Wheel_[location]-entity - Wheel_[location]-ogremesh - Kart - Mesh
... And in the properties inspector, the first four entries for each wheel (i.e. those starting "Wheel_"...) show as Spatials, Kart shows as a Spatial with a Geometry, and Mesh shows as a Mesh. Selecting the Wheel_[location]-WheelNode shows a blue bounding box around the wheel but if I select the Kart Spatial/Geometry which is nested four sub-levels within I see a blue wireframe mesh which perfectly follows the curves of the wheel mesh (i.e. not a bounding box). Is this the correct behaviour?

Thanks for any help or advice you can offer on what I could try next.