Search code examples
javagame-physicsbulletphysicsjmonkeyengine

jMonkeyEngine enabling relative gravity via mass


I'm not sure if I'm wording this correctly, but I want to set up a space-like physics system in jme3. I have the BulletAppState setup and several RigidBodyControl enabled spheres.

    // Setting up BulletAppState
    physics = new BulletAppState();     
    getStateManager().attach(physics);
    physics.getPhysicsSpace().setGravity(Vector3f.ZERO);

    // In each sphere Geometry object I call:
    public void setPhysics(BulletAppState state, float mass) {
        rigidBodyControl = new RigidBodyControl(mass);
        addControl(rigidBodyControl);
        rigidBodyControl.setKinematic(true);
        state.getPhysicsSpace().add(this);
    }

I'd like to have these objects attract each other (like planets) based on their mass. Is this already implemented in jme's jBullet library?


Solution

  • Judging from the lack of responses and further searching the jme API and the web, this is not implemented in either jme or jBullet, and I'll have to write my own implementation. Not sure if I'm up to that.. not to good at maths or physicses O_O

    For anyone interested, I found a similar question with some good code snippet here.