I've started using jMonkey engine recently, which is very nice. But I got stuck trying to implement relative gravity.
I want to make planets orbiting around each other (not necessarily in perfectly circular orbit, depends on velocity). So every object should affect other objects.
What I have right now:
turning off global gravity
bulletAppState.getPhysicsSpace().setGravity(Vector3f.ZERO);
initializing spheres and adding to physics space
Sphere sphere = new Sphere(50, 50, 5);
Geometry sun = new Geometry("Sun", sphere);
sun.setMaterial(stone_mat);
rootNode.attachChild(sun);
sun.setLocalTranslation(0, 0, 0);
sunPhysics = new RigidBodyControl((float) (50*Math.pow(10, 5)));
sun.addControl(sunPhysics);
bulletAppState.getPhysicsSpace().add(sunPhysics);
Geometry mercury = new Geometry("Mercury", sphere);
mercury.setMaterial(stone_mat);
rootNode.attachChild(mercury);
mercury.setLocalTranslation(15f, 0, 0);
mercuryPhysics = new RigidBodyControl((float) (5));
mercury.addControl(mercuryPhysics);
bulletAppState.getPhysicsSpace().add(mercuryPhysics);
I noticed that there is method setGravity in RigidBodyControl class, but it just sets the direction. So object goes that way until it disappears.
I am really looking forward for answers.