Some trials with hull and vehicle physics

Hello monkeys, was just sitting down today having a mess with a vehicle. And I’m not sure what I’m missing when it comes to HullCollision shapes, I can’t seems to add it to a model Spatial or Node.

Here is my attempt at something based off testPhysicsCar. The wheel can be ignored, as in basically just trying to get the truck mesh setup for the hull collision shape. ( My apologies for being a general java / jME rookie ). Just mainly looking to see if Im close to heading in the right direction here.


private void buildTruck() {

matWire = new Material(assetManager, “Common/MatDefs/Misc/WireColor.j3md”);

matWire.setColor(“Color”, ColorRGBA.Red);

Vector3f startLocation = new Vector3f(0, 50, 0);

Vector3f truckGravity = new Vector3f(0, 50, 0);

Node truckNode;

truckNode = (Node) assetManager.loadModel(“Models/Vehicles/Test_Truck.j3o”);

HullCollisionShape truckHull = new HullCollisionShape();


truck = new VehicleControl(truckHull, 1);







//setting suspension values for wheels, this can be a bit tricky

//see also

float stiffness = 60.0f;//200=f1 car

float compValue = .3f; //(should be lower than damp)

float dampValue = .4f;

truck.setSuspensionCompression(compValue * 2.0f * FastMath.sqrt(stiffness));

truck.setSuspensionDamping(dampValue * 2.0f * FastMath.sqrt(stiffness));



//Create four wheels and add them at their locations

Vector3f wheelDirection = new Vector3f(0, -1, 0); // was 0, -1, 0

Vector3f wheelAxle = new Vector3f(-1, 0, 0); // was -1, 0, 0

float radius = 0.5f;

float restLength = 0.3f;

float yOff = 0.5f;

float xOff = 1f;

float zOff = 2f;

Node wNode_1 = new Node(“wNode_1”);

HullCollisionShape wFLHull = new HullCollisionShape();

Node wheelMesh_F_1;

wheelMesh_F_1 = (Node) assetManager.loadModel(“Models/Wheels/Front_L_1.j3o”);


wheelMesh_F_1.rotate(0, FastMath.HALF_PI, 0);


truck.addWheel(wheelMesh_F_1, new Vector3f(-xOff, yOff, zOff),

wheelDirection, wheelAxle, restLength, radius, true);



camNode = new Node(“camNode”);





The empty constructor will never create a valid CollisionShape. Use the CollisionShapeFactory to create a hull shape of all contained geometries with createDynamicMeshShape() or use the constructor HullCollisionShape(Mesh mesh)

normen said:
or use the constructor HullCollisionShape(Mesh mesh)

How would I use this with the above code? I don't really see how to via the wiki.

Just like to add. i’m not trying to build an MMO here, basically just trying to build a physics vehicle with custom made objects for the vehicle. And just running the testPhysicsCar within jMP, I cannot see the wheel shape geometry. And If I can get something accomplished i’ll surly share it with the community. nor could I see the cylinder shapes in the real time render of testPhysicsCar.

Look at the tests, TestQ3 and TestFancyCar use these methods.

I have looked at each. TestFancyCar seems to use a scene for the vehicle. And I haven’t had a lot of practice with the scene editor. I did however test out the vehicle editor via a scene file. Have a question though. Is it standard for a new jME scene to be .j3o file?

I was able to make the truck into a physics vehicle, but I did experience a lot of render artifacts. How I built the vehicle was like this:

made a new scene, linked in the truck body, and made it a hull shape, then added each wheel. tagged front wheels for front.

seemed to work for the most part, but the render had alot of artifacts, and was hard to get a good camera angle on the vehicle.

And even with saving the scene for the vehicle I wouldn’t know how to add this vehicle into jME code wise.

I guess I could just consider myself a jME/P tester lol :slight_smile:

Just some of my observations from today. /cheers

.scene format has nothing to do with “scene” as used in jME3, its an OgreXML term.

Thanks for the info, now i’m seeing testFancyCar with a new perspective, and things are starting to work!