Handling Physics Object with changing translations

I have found through my past experiences with physics object that they freak out if you change their local translation. they only work nice when applying forces.



Now… with the fix I have implemented to get correct calculations for long distances, this involves this node (which will be a physics Node) being translated from itself and its parent.



What would be the best way to deal with this scenario?



The two ideas that have come to my mind are:


  1. rebuild the physics object every time its translation is changed

    or
  2. make my own simple physics system using translations as force



    is there a way for the physics object to accomidate for this change of translation without the above methods?



    Thanks!

You just need to clear the forces after movong the node. Its obvious that physics gets messed up when the objects are warping around :wink:

Do you use jme3? PhysicsNodes got the setPhysicsLocation() method there, it directly modifies the physics object location instead of applying it when updateGeometric() is called. You should be able to use that and an added clearForces() call.

Chees,

Normen

I'm more than likely doing something incorrectly, but I can't seem to get the SetPhysicsLocation to work (correctly).  The following does not appear to move the PhysicsNodes:


public class TEST21 extends SimpleBulletApplication
{
    PhysicsNode pn, pn1;
    public static void main(String[] args)
       {
         TEST21 t1 = new TEST21();
         t1.start();
    }

       @Override
        public void simpleInitApp()
       {                   
           PointLight pl = new PointLight();
           pl.setColor(ColorRGBA.Blue);
           pl.setRadius(100);
           pl.setPosition(new Vector3f(0,0,50));
           this.rootNode.addLight(pl);

           Camera c1 = this.getCamera();
           c1.setLocation(Vector3f.UNIT_Z.mult(40));
          // c1.setDirection(Vector3f.UNIT_Z.mult(-1f));
         

           this.getPhysicsSpace().setGravity(Vector3f.ZERO);

            Material mat = new Material(assetManager, "Common/MatDefs/Misc/SolidColor.j3md");
            mat.setColor("m_Color", ColorRGBA.Yellow);

            Sphere s = new Sphere(10, 10, .5f);
            Geometry geom = new Geometry("S", s);
            geom.setMaterial(mat);
            pn = new PhysicsNode(geom, new SphereCollisionShape(.5f), 1 );
            //pn.setPhysicsLocation(new Vector3f(-2, 0, 0));
            pn.updatePhysicsState();
            pn.updateGeometricState();
            rootNode.attachChild(pn);
            this.getPhysicsSpace().addQueued(pn);
            pn.setPhysicsLocation(new Vector3f(-5, 0, 0));
            pn.clearForces();

            Box b1 = new Box(Vector3f.ZERO, .5f, .5f, .5f);
            Geometry geom1 = new Geometry("B", b1);
            geom1.setMaterial(mat);
            pn1 = new PhysicsNode(geom1, new BoxCollisionShape( Vector3f.UNIT_Z.mult(.5f)),1);
            //pn1.setPhysicsLocation(new Vector3f(2, 0, 0));
            pn1.updateGeometricState();
            pn1.updateModelBound();
            rootNode.attachChild(pn1);
            this.getPhysicsSpace().addQueued(pn1);
            pn1.setPhysicsLocation(new Vector3f(5, 0, 0));
            pn1.clearForces();
       }
}

It should only move them when the physicsspace is updated and then in the next updategeometric() call its applied.