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
rootNode.attachChild(vehicleNode);
getPhysicsSpace().add(vehicle);
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);
not
CollisionShape carShape = CollisionShapeFactory.createDynamicMeshShape(car);
then the error appear when I’m going to hit something (wall, pillar, etc…)
java.lang.NullPointerException
at com.bulletphysics.collision.dispatch.CollisionDispatcher.freeCollisionAlgorithm(CollisionDispatcher.java:119)
at com.bulletphysics.collision.dispatch.CompoundCollisionAlgorithm.destroy(CompoundCollisionAlgorithm.java:76)
at com.bulletphysics.collision.dispatch.CollisionDispatcher.freeCollisionAlgorithm(CollisionDispatcher.java:120)
at com.bulletphysics.collision.dispatch.CompoundCollisionAlgorithm.destroy(CompoundCollisionAlgorithm.java:76)
at com.bulletphysics.collision.dispatch.CollisionDispatcher.freeCollisionAlgorithm(CollisionDispatcher.java:120)
at com.bulletphysics.collision.broadphase.HashedOverlappingPairCache.cleanOverlappingPair(HashedOverlappingPairCache.java:219)
at com.bulletphysics.collision.broadphase.HashedOverlappingPairCache.removeOverlappingPair(HashedOverlappingPairCache.java:91)
at com.bulletphysics.collision.broadphase.DbvtBroadphase.collide(DbvtBroadphase.java:145)
at com.bulletphysics.collision.broadphase.DbvtBroadphase.calculateOverlappingPairs(DbvtBroadphase.java:235)
at com.bulletphysics.collision.dispatch.CollisionWorld.performDiscreteCollisionDetection(CollisionWorld.java:139)
at com.bulletphysics.dynamics.DiscreteDynamicsWorld.internalSingleStepSimulation(DiscreteDynamicsWorld.java:378)
at com.bulletphysics.dynamics.DiscreteDynamicsWorld.stepSimulation(DiscreteDynamicsWorld.java:339)
at com.jme3.bullet.PhysicsSpace.update(PhysicsSpace.java:349)
at com.jme3.bullet.PhysicsSpace.update(PhysicsSpace.java:336)
at com.jme3.bullet.BulletAppState.render(BulletAppState.java:247)
at com.jme3.app.state.AppStateManager.render(AppStateManager.java:300)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:257)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:152)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:192)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:233)
at java.lang.Thread.run(Thread.java:745)
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.