Need help with gravity in a planet model

hello all,



i am trying to make a planet model that runs physics. my big issue atm is that when i run my program, the "planet" (just a sphere atm) drops off into nothing…



i tried using Quaternions and doing a purely mathematical program, but i couldnt find a way (or just dont know JME well enough…) to get it to continue rotating more than one time. thus, i decided to try physics. the only issue i see is that gravity is ALWAYS there, which is great except the gravity should be pulling towards the planet and not downward towards nothing…



i cant just make the sphere a static node because it is going to be rotating…



also, i cant just make a floor and have it rotate on that because of the camera system i am using… (well, unless i make the floor transparent… can i do that?)



code:

      Sphere bound = new Sphere("Camera Sphere",75,75,565f);
      bound.setModelBound(new BoundingSphere());
      bound.updateModelBound();

      Sphere planet = new Sphere("Planet",50,50,200f);
      planet.setModelBound(new BoundingSphere());
      planet.updateModelBound();
      planet.setRenderState(ts);
      planet.updateRenderState();

      DynamicPhysicsNode pivot = getPhysicsSpace().createDynamicNode();
      pivot.addTorque(new Vector3f(10,0,0));
      pivot.attachChild(planet);
      
      rootNode.attachChild(bound);
      rootNode.attachChild(pivot);

If you are using JMEPhysics, use:



dynamicNode…setAffectedByGravity(false);


that works, thanks!

I would say use a controller, then get a quatenion that represents a litte rotation and sertlocalroation (getlocalrotation.add(myrotaionquaternion)).

Just that you know quaternions are not kummultative (a+b!=b+a)if you wonder why it rotats in the wrong direction ^^



Also my apologies for my bath grammar, but it#s 5 pm and I#m just taking a short break from learning for my studium :wink: (cause i can#t concentrate currently)



Your curent aproach has the problem, that your planet could be bumped away from heavy/fast objects