June 2013
Beginner
352 pages
9h 5m
English
Let's add a dynamic object to the scene to see what happens when it falls onto the platform. You already know how to create a nicely textured sphere and turn it into a physical ball.
Open PhysicsKinematic.java again and add the following method:
private RigidBodyControl ballPhy; private static final String BALL = "Ball"; public void dropBall() { Sphere ballMesh = new Sphere(32, 32, .75f, true, false); ballMesh.setTextureMode(TextureMode.Projected); TangentBinormalGenerator.generate(ballMesh); Geometry ballGeo = new Geometry(BALL, ballMesh); ballGeo.setMaterial(stoneMat); rootNode.attachChild(ballGeo); /** Create physical ball and add to physics space. */ ballPhy = new RigidBodyControl(5f); ballGeo.addControl(ballPhy); ...Read now
Unlock full access