Generating Collision Shape

I made car, picture bellow, and when a try to make collision shape of it I found a problem.

The car is made in Blender then exported in ogre and imported to jME, in jME automaticaly converted to .j3o and then loaded it in game using Spatial car = assetManager.loadModel("Models/Car.j3o");

Collision is made by CollisionShape carShape = CollisionShapeFactory.createDynamicMeshShape(car);

But how you can see in the picture Collision Shape Factory jump some vertices and doesn’t create the collision shape that I want (the pink lines on top of car).

I haven’t got any more idea how to fix it, I tried some methods but it doesn’t work. Do anybody know how can I fix it?

Actually you can have 3 types of collision shape: (please correct me if I am wrong)
1- Use the car mesh itself as collision shape : (it is precise but adds a lot of load on cpu and not recommended for non-simple meshes) so forget this one ! :stuck_out_tongue_winking_eye:

2-Use that collisionshapefactory to create simple mesh from the main mesh which you used in your example. It uses some algorithm to create a simple mesh and may not be as you wish!
3-You can create your own collision mesh in blender for your car model. and one way would be to use blender Decimate modifier: (It has a lot of improvement in blender 2.77 )

1 Like

Okay, so, let’s look at it:

car is only how the car looks, spatial, let’s say it’s only body of the car, the red things in the picture

carShape is DYNAMIC MeshShape collision which shape is created from car, the pink lines,

vehicle is new VehicleControl made from carShape and mass,

vehicleNode is node where are everything attached, wheels…

then here are
vehicleNode.addControl(vehicle) and vehicleNode.addWheel(...)

So, car is only spatial from Blender 2.77 and carShape take only some of it’s vertices to create DynamicMeshShape then I create vehicleNode, after that vehicle is created from carShape and some mass. Then wheels are added to vehicleNode and finally


That’s how I have created the car.
But today I find out, that I need to say to CollisionShapeFactory I don’t want a DYNAMIC MeshShape collision but I want only MeshShape collision, I don’t know how you name it, it’s MeshShape I’m looking for. BUT if the code be

CollisionShape carShape = CollisionShapeFactory.createMeshShape(car);


CollisionShape carShape = CollisionShapeFactory.createDynamicMeshShape(car);

then the error appear when I’m going to hit something (wall, pillar, etc…)

	at com.bulletphysics.collision.dispatch.CollisionDispatcher.freeCollisionAlgorithm(
	at com.bulletphysics.collision.dispatch.CompoundCollisionAlgorithm.destroy(
	at com.bulletphysics.collision.dispatch.CollisionDispatcher.freeCollisionAlgorithm(
	at com.bulletphysics.collision.dispatch.CompoundCollisionAlgorithm.destroy(
	at com.bulletphysics.collision.dispatch.CollisionDispatcher.freeCollisionAlgorithm(
	at com.bulletphysics.collision.broadphase.HashedOverlappingPairCache.cleanOverlappingPair(
	at com.bulletphysics.collision.broadphase.HashedOverlappingPairCache.removeOverlappingPair(
	at com.bulletphysics.collision.broadphase.DbvtBroadphase.collide(
	at com.bulletphysics.collision.broadphase.DbvtBroadphase.calculateOverlappingPairs(
	at com.bulletphysics.collision.dispatch.CollisionWorld.performDiscreteCollisionDetection(
	at com.bulletphysics.dynamics.DiscreteDynamicsWorld.internalSingleStepSimulation(
	at com.bulletphysics.dynamics.DiscreteDynamicsWorld.stepSimulation(
	at com.jme3.bullet.PhysicsSpace.update(
	at com.jme3.bullet.PhysicsSpace.update(
	at com.jme3.bullet.BulletAppState.render(
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(
	at com.jme3.system.lwjgl.LwjglDisplay.runLoop(

AL lib: (EE) alc_cleanup: 1 device not closed

Exception: java.lang.NullPointerException thrown from the UncaughtExceptionHandler in thread "jME3 Main"
BUILD SUCCESSFUL (total time: 17 seconds)

How can I catch or fix this?
Sorry for that but I still haven’t got any idea.

do not use this (like ever for games)

is not for moving objects, do not move them ever.

The thing you need to understand is that you can only really move convex shapes in real time, concave shapes cause too much overhead. So a “dynamic mesh” is a convex hull shape which is probably what you don’t like. You could make for example the top and bottom of your car two separate hull shapes and combine them in a compound shape to model the car more closely while still having only two convex shape checks.