I am making a LibGDX game using 3D physics. I enabled the Bullet extension when generating the project. For the 3D physics, I was following the tutorial here: https://xoppa.github.io/blog/using-the-libgdx-3d-physics-bullet-wrapper-part1/
However, when I got to gravity, the collision didn't work. Here's my code:
btDefaultCollisionConfiguration collisionConfig = new btDefaultCollisionConfiguration();
world = new btDiscreteDynamicsWorld(new btCollisionDispatcher(collisionConfig), new btSimpleBroadphase(), new btSequentialImpulseConstraintSolver(), collisionConfig);
world.setGravity(new Vector3(0, -10f, 0));
object = new btRigidBody(0, new btDefaultMotionState(), Bullet.obtainStaticNodeShape(model.nodes));
object.setWorldTransform(model.transform);
object.setCollisionFlags(object.getCollisionFlags() | btCollisionObject.CollisionFlags.CF_KINEMATIC_OBJECT);
world.addRigidBody(object);
object.setContactCallbackFlag(1 << 8);
object.setContactCallbackFilter(0);
object.setActivationState(Collision.DISABLE_DEACTIVATION);
world.addRigidBody(Player.collisionObject);
Player.collisionObject.setContactCallbackFlag(1 << 9);
Player.collisionObject.setContactCallbackFilter(1 << 8);
And here's the Player class:
model = new ModelInstance(new ModelBuilder().createSphere(1, 1, 1, 10, 10, new Material(ColorAttribute.createDiffuse(Color.GREEN)), VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal));
btSphereShape shape = new btSphereShape(0.5f);
shape.calculateLocalInertia(1f, new Vector3(0, 0, 0));
collisionObject = new btRigidBody(new btRigidBody.btRigidBodyConstructionInfo(1f, null, shape, new Vector3(0, 0, 0)));
model.transform = new Matrix4().translate(pos);
collisionObject.proceedToTransform(model.transform);
collisionObject.setCollisionFlags(Player.collisionObject.getCollisionFlags() | btCollisionObject.CollisionFlags.CF_CUSTOM_MATERIAL_CALLBACK);
collisionObject.setUserValue(1);