package lecture14; import com.jme3.app.SimpleApplication; import com.jme3.light.DirectionalLight; import com.jme3.material.Material; import com.jme3.math.ColorRGBA; import com.jme3.math.Vector3f; import com.jme3.scene.Geometry; import com.jme3.scene.shape.Box; import com.jme3.scene.shape.Sphere; public class HelloAiming extends SimpleApplication { Geometry ag; Vector3f velocity = new Vector3f(0, 0, 0); Vector3f acceleration = new Vector3f(0, 0, 0); Vector3f gravity = new Vector3f(0, -9.8f, 0); public void simpleInitApp() { DirectionalLight sun = new DirectionalLight(); sun.setDirection(new Vector3f(1, 0, -2).normalize()); sun.setColor(ColorRGBA.White); rootNode.addLight(sun); Material redMat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md"); redMat.setBoolean("UseMaterialColors", true); redMat.setColor("Ambient", ColorRGBA.Blue); redMat.setColor("Diffuse", ColorRGBA.Blue); Sphere s = new Sphere(60, 60, 1.5f); ag = new Geometry("Sphere", s); ag.setMaterial(redMat); rootNode.attachChild(ag); cam.setLocation(new Vector3f(0, 0, 60)); reset(); } protected void reset() { velocity = new Vector3f(10, 10, 0); ag.setLocalTranslation(-8, 0, 0); } @Override public void simpleUpdate(float tpf) { if (ag.getLocalTranslation().getY() < -15f) { reset(); } acceleration = gravity; velocity = velocity.add(acceleration.mult(tpf)); ag.move(velocity.mult(tpf)); } public static void main(String[] args) { HelloAiming app = new HelloAiming(); app.start(); } }