Objects keep rotating

For our game, we use cars modelled in 3DS-Max, exported to OGRE XML, which does seem to work (basically). However, as soon as we use models that are built from more than 1 part, the corresponding object in the game (controlled by com.jme3.bullet.control.VehicleControl) starts rotating about one axis uncontrollably.

Most of the times, the different parts of the object are also not in alignment to each other – although they are when viewed in the jME model viewer.

Has anyone else seen such an effect? Any hints on how to debug this behaviour?

I had something similar in my ship simulation (uses a RigidBodyControl). As long as the ship was in the world-origin (0,0,0), there was no problem, but as soon as the ship went from the world-origin, it started to spin. To move the ship on the waves, I have six points on which I apply force individually (direction of the force depends on above or below water of each control-point).

I believe the problem has to do with the fact that the control-points are children of the ships node and the physics body does not use the same co-ordinate system.

Below the code I use to apply the force on one of the control-points:

[java]ship_phy.applyForce(new Vector3f(0, (waveBSB-shipBSB)*waveForceBow, 0), new Vector3f(ship.getChild(“buoyBSB”).getWorldTranslation().x-ship_phy.getPhysicsLocation().x, ship.getChild(“buoyBSB”).getWorldTranslation().y-ship_phy.getPhysicsLocation().y, ship.getChild(“buoyBSB”).getWorldTranslation().z-ship_phy.getPhysicsLocation().z));[/java]

“buoyBSB” is the control-point. I get the WorldTranslation of it and just subtract the PhysicsLocation of the RigidBodyControl (“ship_phy”).

Doing this for x, y and z co-ordinates solved my problem. I have no idea whether this is the same issue as you have, but maybe it will point you in the right direction?

the center of the object is where the center of mass is so if you create a collision shape with a mesh thats off then you got your reason. use the physics space debug view and put objects at the center of your models, then you’ll probably see whats the issue. also make sure you use the latest stable version of the engine, the collision shape factory has been improved in beta and creates its offset from the model.