The center (origin) of the rigid body is the same as the center of mass and therefor an important property for the physics simulation. You could "move" this center using a btCompoundShape
if you like, but this will also influence the physics simulation and therefore probably won't give you satisfying results.
Alternatively, you could compensate for the difference of physics origin and visual origin in your btMotionState
. For example by setting ModelInstance#transform
to the provided worldTransform
multiplied by the a Matrix4
instance which contains the offset (use Matrix4#translate
for example).
However, this is probably just making it more complex than it needs to be. You could say that the real question is why you want offset the center of model compared to the body? For example, in you second image the center of the model appears to be same as the in the first image. You only moved the Node
, basically indicating that you want to provide an initial value for the ModelInstance#transform
member. You can achieve this by instantiating the ModelInstance
as follows:
modelInstance = new ModelInstance(model, "coneNode", true);
Replace "coneNode"
with the name of the node as created it in your modeling application. The last (true
) argument tells the ModelInstance to set its transform
member to the transformation you've given it in the modeling application. If needed, you can call modelInstance.transform.translate(x, y, z);
or modelInstance.transform.trn(x, y, z);
to move the modelInstance relative to this transformation.
A more in-depth explanation of this can be found here: http://blog.xoppa.com/loading-a-scene-with-libgdx/
Note that this only works if you're using .g3db
or .g3dj
files (e.g. using fbx-conv
) created from a file format that supports node transformations (e.g. .fbx
, but not .obj
)