Get/set Center of Mass

I’ve checked JavaDoc, but didn’t found setter and getter for the center of mass for physics objects. Is it a 0,0,0 point in world space for a moment when object is created? Like if I’m creating a box of 1/1/1 size and move it along Y by -1 on create, center of mass will be exactly at the middle of the top side.

You don’t, center of mass is always at 0/0/0, you move the collision shape:

Thank you Normen!

Didn’t knew about “that” wiki.

Its for the old jme2 version of the bullet physics, I just put the explanation together there once and its quite handy in these situations :wink:

I am new to the JMonkey engine, and I had a similar question, although I don’t think this link fixes it. I’ve done the tutorials (have a few suggestions to clear up some parts) and on the final tutorial about physics, I swapped out the ball with the soldier from the earlier tutorial. So now you shoot soldiers at the wall.

This has an unusual outcome, because the soldiers hit the wall and they all ‘fall’ to the standing up position like one of those kiddy punching bags with the weighted bottoms. If the center of mass is 0,0,0 why would they all fall standing up? How do you fix this?

(on second thought, I should probably make a new post rather than comment on one that’s over a year old, but since I apparently cannot delete this comment, I’ll just wait to see if this gets answered before spamming the boards)

Where is the center of your soldier models? Often models have the center at their feet.

I used the one that came with JMonkey:

Spatial ninja = assetManager.loadModel(“Models/Ninja/Ninja.mesh.xml”);

Is the center of the object determined when creating it in Blender (or other program) or is this set manually within the JME library?

The ninja has its center at the feet yeah. The center is defined by the relative position of the meshes to the 0/0/0 position of the model. The center is always at local 0/0/0.

Thank you! I will keep that in mind when creating objects in the future.