I honestly think I’m starting to lose my mind here.
So I made a nice class a bit ago that had the node and physics stuff wrapped up into a class that extends a node.
I wanted to make a split in that logic and have a node class that has the part you see and a physics class that handles ship movement. This seems logical to me but again I may have lost my mind.
Here’s the class as I have it now:
public class ShipPhysics extends RigidBodyControl implements PhysicsTickListener {
private final Geometry colShape;
ShipPhysics(Geometry collisionGeometry) {
this.colShape = collisionGeometry;
initPhysics();
}
private void initPhysics() {
this.setCollisionShape(CollisionShapeFactory.createBoxShape(colShape));
this.setMass(2f);
this.setKinematic(false);
this.setGravity(new Vector3f(0,0,0));
this.setDamping(0.9f, 0.9f);
this.setFriction(0.9f);
}
@Override
public void update(float tpf) {
System.out.println(this.getPhysicsLocation().toString());
}
@Override
public void prePhysicsTick(PhysicsSpace space, float tpf) {
System.out.println("Pre Tick");
//throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void physicsTick(PhysicsSpace space, float tpf) {
System.out.println("Tick");
//throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}
The class that calls this does this:
shipPhy = new ShipPhysics(shipNode.getCollisionGeometry());
bas.getPhysicsSpace().add(shipPhy);
bas is the BulletAppState and shipNode is the class that returns the ship geometry to use for the collision shape.
The issues that I’m having is… well… a few…
- Setting gravity in my class via this.setGravity or super.setGravity to a new Vector3f(0,0,0) doesn’t appear to change anything gravity wise. During the update loop the position just continues to fall endlessly.
- The pre and post ticks don’t tick.
I went through the tutorial regarding physics listeners but clearly I’ve either overlooked something or I’m thick (probably the later).