Center of mass in world coordinates

Hi there,

I'm trying to do a very simple thing… I have a DynamicPhysicsNode object that can move around my scene. Every update cycle I need to get the center of mass location to figure out how far away the DynamicPhysicsNode object is from another vector. I tried the getCenterOfMass() but it returns the location in object coordinate space, so it just returns Vector3f(0f, 0f, 0f), is there any way to convert this location to world coordinate space??



Sorry if this is a noob question.



Thanks  :slight_smile:

You can use getWorldTranslation(). While thinking about it, I came to the conclusion that center of mass might currently behave different than one expects… please check, but I think getWorldTranslation() always gives you the center of mass. If not you can compute it via localToWorld(getCenterOfMass()).

irrisor said:

You can use getWorldTranslation(). While thinking about it, I came to the conclusion that center of mass might currently behave different than one expects...

This does behave a little strangely, say I drop a cube from [x=0, y=50, z=0] and there is a floor at [0, 0, 0]. Once the cube comes to rest on the floor the getWorldTranslation() returns the center of mass as [0, -50, 0]. Shouldn't it return [0, 0, 0]? It looks like its returning the position in relation from where it started.

irrisor said:

please check, but I think getWorldTranslation() always gives you the center of mass. If not you can compute it via localToWorld(getCenterOfMass()).

The localToWorld(getCenterOfMass()) also does something strange, using the same scenario as above, the cubes center of mass after coming to rest on the floor is [0, -100, 0]?!?!

Am I just misunderstanding what these methods do, or are they returning the wrong thing?

Thanks.

Uh, center of mass might be flawed then. Please use getWorldCoordinates() (and probably an own offset) for the time being.