I’ve made application with vehicle control like FancyCar
Code of car creation:
Spatial carNode = assetManager.loadModel(SCENE_LOCATION);
carNode.setMaterial(mat);
carNode.setShadowMode(ShadowMode.Cast);
CollisionShape carHull = CollisionShapeFactory.createDynamicMeshShape((Node)carNode);
vehicleControl = new VehicleControl(carHull, vehicleWeight);
vehicleControl.setSuspensionCompression(compValue * 2.0f * FastMath.sqrt(stiffness));
vehicleControl.setSuspensionDamping(dampValue * 2.0f * FastMath.sqrt(stiffness));
vehicleControl.setSuspensionStiffness(stiffness);
vehicleControl.setMaxSuspensionForce(10000);
addWheels(carNode);
vehicle.setVehicleControl(vehicleControl);
rootNode.attachChild(carNode);
bulletAppState.getPhysicsSpace().add(vehicleControl);
and have problem with center of mass (it’s very hight).
Example says it must be lower than vehicle. I’ve tried to move pivot point in 3dMax lover but it seems have no effect.
Is there are any manual how to set center of mass programmatically?
p.s. I found many topics in forum, but links there seems to be broken
Center of mass by default
When i try to make center of mass like in TestPhysicsCar.java
CompoundCollisionShape compoundShape = new CompoundCollisionShape();
CollisionShape carHull = CollisionShapeFactory.createDynamicMeshShape((Node)carNode);
compoundShape.addChildShape(carHull, new Vector3f(0, 1, 0));
vehicleControl = new VehicleControl(compoundShape, vehicleWeight);
I’ve got error:
java.lang.IllegalArgumentException
at com.jme3.scene.Geometry.setMesh(Geometry.java:193)
at com.jme3.bullet.util.DebugShapeFactory.createDebugShape(DebugShapeFactory.java:116)
at com.jme3.bullet.util.DebugShapeFactory.getDebugShape(DebugShapeFactory.java:85)
at com.jme3.bullet.debug.BulletRigidBodyDebugControl.(BulletRigidBodyDebugControl.java:60)
at com.jme3.bullet.debug.BulletDebugAppState.updateRigidBodies(BulletDebugAppState.java:175)
at com.jme3.bullet.debug.BulletDebugAppState.update(BulletDebugAppState.java:118)
at com.jme3.app.state.AppStateManager.update(AppStateManager.java:287)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:239)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:228)
at java.lang.Thread.run(Unknown Source)
any help?
thank you
p.s. It seems that mesh is null