/* (non-Javadoc) * @see com.jme.input.action.MouseInputAction#performAction(float) */ public void performAction(InputActionEvent evt) { shotTime += evt.getTime(); if (MouseInput.get().isButtonDown(0) && shotTime > 0.1f) { shotTime = 0; Ray ray = new Ray( camera.getLocation(), camera.getDirection()); // camera direction is already normalized PickResults results = new BoundingPickResults(); results.setCheckDistance(true); scene.findPick(ray, results); hits += results.getNumber(); hitItems = ""; if (results.getNumber() > 0) { for (int i = 0; i < results.getNumber(); i++) { hitItems += results.getPickData(i).getTargetMesh().getName() + " " + results.getPickData(i).getDistance(); if (i != results.getNumber() - 1) { hitItems += ", "; } } } shots++; results.clear(); text.print("Hits: " + hits + " Shots: " + shots + " : " + hitItems); } }
protected void simpleUpdate() { float interpolation = timer.getTimePerFrame(); if (KeyBindingManager.getKeyBindingManager().isValidCommand("g", false)) { detachLandscape(); buildLandscape(); attachLandscape(); buildPlanting(); // update render state after replacing landscape rootNode.updateRenderState(); } // We don't want the chase camera to go below the world, so always keep // it 7 units above the level. World.SurfacePoint surfacePoint = world.getSurfacePointAt(cam.getLocation()); if (cam.getLocation().y < (surfacePoint.getHeight() + 7)) { cam.getLocation().y = (surfacePoint.getHeight() + 7); } for (int i = 0; i < sheep.length; i++) { sheep[i].update(interpolation); } collisionHandling(); // Move sheep a bit closer to each other for (int i = 0; i < sheep.length; i++) { for (int j = (i + 1); j < sheep.length; j++) { Vector3f dir = sheep[j] .getBody() .getLocalTranslation() .subtract(sheep[i].getBody().getLocalTranslation()); sheep[j].getBody().getLocalTranslation().subtractLocal(dir.mult(0.01f)); sheep[i].getBody().getLocalTranslation().addLocal(dir.mult(0.01f)); } } sky.getLocalTranslation().set(cam.getLocation()); cam.update(); // Because we are changing the scene (moving the skybox and player) we need to update // the graph. rootNode.updateGeometricState(interpolation, true); scene.updateGeometricState(interpolation, true); // update audio system gameAudioSystem.updateAudio(); // sheepDebugText.print(sheep[0].toString()); }