setLocalTranslation vs setPhysicsLocation for Geometries with PhysicsControls

When using RigidBodyControls on Geometries, should I be using setLocalTranslation on the Geometry or setPhysicsLocation on the PhysicsControl? I’d like to add a few geometries to a node so that I can place and rotate the node without having to do it individually for all the sub objects, but I think I read in the wiki that I should be using setPhysicsLocation on the PhysicsControl. If I should be using setPhysicsLocation on the PhysicsControl, then I think I have to place and rotate each control individually and the Geometry update accordingly. Is that right?

From my understanding you can apply transformations to the node if the PhysicsControls are set to applyPhysicsLocal(true). Then also setPhysicsLocation on the individual PhysicsControls should move them according to the parent node. But I could be wrong :slight_smile:

ApplyPhysicsLocal has nothing to do with this. If the rigidbody is kinematic it moves with the spatial (e.g. setLocalTranslation) but is not affected by physics, if its not kinematic the spatial will move according to the physical movement of the rigidbody.

1 Like

I’m sorry but could you then explain again what applyPhysicsLocal does? I’m not really getting it form the test case “TestLocalPhysics”. Maybe you can give a concrete example, because I thought “local” means in physics movement that it depends on a parent’s movement?

@normen

So, if physics is not being used, you can add multiple children to a parent node so that using setLocalTranslation / setLocalRotation on the parent node modifies all the children nodes. If physics is being used, then setPhysicsLocation / setPhysicsRotation should be used on each control instead? If so, is there a way to group multiple physics controls to a parent so that setting the initial location / rotation of the parent affects all the child controls or is it necessary to set each control individually?



Sorry for the NOOB question, but JME3 is my first experience with JMonkey.

You should not have parent/child relations in physics anyway because the physics coordinate system is in world coordinates. So even if you give a PhysicsControl to a parent and child spatial they will basically move independent from each other. If you want physics, you have to modify the physics objects, the spatial/geometry is only the visual representation. Btw you should only place non-kinematic physics objects using setPhysicsLocation() if you want to put them to their initial position or something like that, its basically like beaming an object from a to b, so you cannot expect normal physics results to come from this, use forces on objects to move them properly. If you set your objects to kinematic mode they will affect other physics objects (e.g. push them away, block their way) but not be affected by physics, this way you can move the spatial around and the physics object will follow. Lots of this info is also in the wiki, just read through the articles instead of searching for “exact solution to my current problem” :wink: Also read the javadoc thoroughly.

Understood. Thanks for the details. I’ve been reading, but didn’t understand the difference until now. I was trying to see if there was a way to programatically create a static scene object composed of multiple native shapes and set the initial location as a whole instead of them individually. I think a better way will be to create the object offline as a model file and load it. We’re about to start converting an app we’ve been developing on android using native bullet to JME3 with native bullet.



Thanks for your prompt responces.