Let's build a scene that uses all three types of physical objects: dynamic, static, and kinematic. The static part of the scene contains a floor (a horizontal box), a slope (a rotated box), and a wall (a vertical box). Later, we add a kinematic moving platform (a cuboid box) and a dynamic ball (a sphere), and then see how they interact.
Make a copy of
Main.java
and name the classPhysicsKinematic.java
. Remember to also refactor the first line of themain()
method to the following:PhysicsKinematic app = new PhysicsKinematic();
Make this a physical game by attaching a
BulletAppState
instance.private BulletAppState bulletAppState; @Override public void simpleInitApp() { bulletAppState = new BulletAppState(); stateManager.attach(bulletAppState); … }
Re-use the materials from
PhysicsFallingBricks
, and initialize them in thesimpleInitApp()
method. As usual, add light sources.private Material brickMat, stoneMat, woodMat; public void simpleInitApp...