@Override public void update(float interval, MouseInput mouseInput) { // Update camera position camera.movePosition(cameraInc.x * CAMERA_POS_STEP, cameraInc.y * CAMERA_POS_STEP, cameraInc.z * CAMERA_POS_STEP); // Update camera based on mouse if (mouseInput.isRightButtonPressed()) { Vector2f rotVec = mouseInput.getDisplVec(); camera.moveRotation(rotVec.x * MOUSE_SENSITIVITY, rotVec.y * MOUSE_SENSITIVITY, 0); } }
@Override public void update(float interval, MouseInput mouseInput) { // Update camera position camera.movePosition(cameraInc.x * CAMERA_POS_STEP, cameraInc.y * CAMERA_POS_STEP, cameraInc.z * CAMERA_POS_STEP); // Update camera based on mouse if (mouseInput.isRightButtonPressed()) { Vector2f rotVec = mouseInput.getDisplVec(); camera.moveRotation(rotVec.x * MOUSE_SENSITIVITY, rotVec.y * MOUSE_SENSITIVITY, 0); } }
@Override public void update(float interval, MouseInput mouseInput) { // Update camera position camera.movePosition(cameraInc.x * CAMERA_POS_STEP, cameraInc.y * CAMERA_POS_STEP, cameraInc.z * CAMERA_POS_STEP); // Update camera based on mouse if (mouseInput.isRightButtonPressed()) { Vector2f rotVec = mouseInput.getDisplVec(); camera.moveRotation(rotVec.x * MOUSE_SENSITIVITY, rotVec.y * MOUSE_SENSITIVITY, 0); } }
@Override public void update(float interval, MouseInput mouseInput, Window window) { if (mouseInput.isRightButtonPressed()) { // Update camera based on mouse Vector2f rotVec = mouseInput.getDisplVec(); camera.moveRotation(rotVec.x * MOUSE_SENSITIVITY, rotVec.y * MOUSE_SENSITIVITY, 0); sceneChanged = true; } // Update camera position camera.movePosition(cameraInc.x * CAMERA_POS_STEP, cameraInc.y * CAMERA_POS_STEP, cameraInc.z * CAMERA_POS_STEP); lightAngle += angleInc; if (lightAngle < 0) { lightAngle = 0; } else if (lightAngle > 180) { lightAngle = 180; } float zValue = (float) Math.cos(Math.toRadians(lightAngle)); float yValue = (float) Math.sin(Math.toRadians(lightAngle)); Vector3f lightDirection = this.scene.getSceneLight().getDirectionalLight().getDirection(); lightDirection.x = 0; lightDirection.y = yValue; lightDirection.z = zValue; lightDirection.normalize(); // Update view matrix camera.updateViewMatrix(); }
@Override public void update(float interval, MouseInput mouseInput, Window window) { if (mouseInput.isRightButtonPressed()) { // Update camera based on mouse Vector2f rotVec = mouseInput.getDisplVec(); camera.moveRotation(rotVec.x * MOUSE_SENSITIVITY, rotVec.y * MOUSE_SENSITIVITY, 0); sceneChanged = true; } // Update camera position camera.movePosition(cameraInc.x * CAMERA_POS_STEP, cameraInc.y * CAMERA_POS_STEP, cameraInc.z * CAMERA_POS_STEP); lightAngle += angleInc; if (lightAngle < 0) { lightAngle = 0; } else if (lightAngle > 180) { lightAngle = 180; } float zValue = (float) Math.cos(Math.toRadians(lightAngle)); float yValue = (float) Math.sin(Math.toRadians(lightAngle)); Vector3f lightDirection = this.scene.getSceneLight().getDirectionalLight().getDirection(); lightDirection.x = 0; lightDirection.y = yValue; lightDirection.z = zValue; lightDirection.normalize(); // Update view matrix camera.updateViewMatrix(); }
@Override public void update(float interval, MouseInput mouseInput, Window window) { if (mouseInput.isRightButtonPressed()) { // Update camera based on mouse Vector2f rotVec = mouseInput.getDisplVec(); camera.moveRotation(rotVec.x * MOUSE_SENSITIVITY, rotVec.y * MOUSE_SENSITIVITY, 0); sceneChanged = true; } // Update camera position camera.movePosition(cameraInc.x * CAMERA_POS_STEP, cameraInc.y * CAMERA_POS_STEP, cameraInc.z * CAMERA_POS_STEP); lightAngle += angleInc; if (lightAngle < 0) { lightAngle = 0; } else if (lightAngle > 180) { lightAngle = 180; } float zValue = (float) Math.cos(Math.toRadians(lightAngle)); float yValue = (float) Math.sin(Math.toRadians(lightAngle)); Vector3f lightDirection = this.scene.getSceneLight().getDirectionalLight().getDirection(); lightDirection.x = 0; lightDirection.y = yValue; lightDirection.z = zValue; lightDirection.normalize(); // Update view matrix camera.updateViewMatrix(); }
if (mouseInput.isRightButtonPressed()) { Vector2f rotVec = mouseInput.getDisplVec(); camera.moveRotation(rotVec.x * MOUSE_SENSITIVITY, rotVec.y * MOUSE_SENSITIVITY, 0);
@Override public void update(float interval, MouseInput mouseInput) { // Update camera based on mouse if (mouseInput.isRightButtonPressed()) { Vector2f rotVec = mouseInput.getDisplVec(); camera.moveRotation(rotVec.x * MOUSE_SENSITIVITY, rotVec.y * MOUSE_SENSITIVITY, 0); } // Update camera position Vector3f prevPos = new Vector3f(camera.getPosition()); camera.movePosition(cameraInc.x * CAMERA_POS_STEP, cameraInc.y * CAMERA_POS_STEP, cameraInc.z * CAMERA_POS_STEP); // Check if there has been a collision. If true, set the y position to // the maximum height float height = terrain != null ? terrain.getHeight(camera.getPosition()) : -Float.MAX_VALUE; if (camera.getPosition().y <= height) { camera.setPosition(prevPos.x, prevPos.y, prevPos.z); } lightAngle += angleInc; if (lightAngle < 0) { lightAngle = 0; } else if (lightAngle > 180) { lightAngle = 180; } float zValue = (float) Math.cos(Math.toRadians(lightAngle)); float yValue = (float) Math.sin(Math.toRadians(lightAngle)); Vector3f lightDirection = this.scene.getSceneLight().getDirectionalLight().getDirection(); lightDirection.x = 0; lightDirection.y = yValue; lightDirection.z = zValue; lightDirection.normalize(); }
@Override public void update(float interval, MouseInput mouseInput) { if (mouseInput.isRightButtonPressed()) { Vector2f rotVec = mouseInput.getDisplVec(); camera.moveRotation(rotVec.x * MOUSE_SENSITIVITY, rotVec.y * MOUSE_SENSITIVITY, 0);
@Override public void update(float interval, MouseInput mouseInput) { if (mouseInput.isRightButtonPressed()) { Vector2f rotVec = mouseInput.getDisplVec(); camera.moveRotation(rotVec.x * MOUSE_SENSITIVITY, rotVec.y * MOUSE_SENSITIVITY, 0);
@Override public void update(float interval, MouseInput mouseInput) { // Update camera based on mouse if (mouseInput.isRightButtonPressed()) { Vector2f rotVec = mouseInput.getDisplVec(); camera.moveRotation(rotVec.x * MOUSE_SENSITIVITY, rotVec.y * MOUSE_SENSITIVITY, 0); } // Update camera position Vector3f prevPos = new Vector3f(camera.getPosition()); camera.movePosition(cameraInc.x * CAMERA_POS_STEP, cameraInc.y * CAMERA_POS_STEP, cameraInc.z * CAMERA_POS_STEP); // Check if there has been a collision. If true, set the y position to // the maximum height float height = terrain != null ? terrain.getHeight(camera.getPosition()) : -Float.MAX_VALUE; if (camera.getPosition().y <= height) { camera.setPosition(prevPos.x, prevPos.y, prevPos.z); } lightAngle += angleInc; if (lightAngle < 0) { lightAngle = 0; } else if (lightAngle > 180) { lightAngle = 180; } float zValue = (float) Math.cos(Math.toRadians(lightAngle)); float yValue = (float) Math.sin(Math.toRadians(lightAngle)); Vector3f lightDirection = this.scene.getSceneLight().getDirectionalLight().getDirection(); lightDirection.x = 0; lightDirection.y = yValue; lightDirection.z = zValue; lightDirection.normalize(); }
@Override public void update(float interval, MouseInput mouseInput) { // Update camera based on mouse if (mouseInput.isRightButtonPressed()) { Vector2f rotVec = mouseInput.getDisplVec(); camera.moveRotation(rotVec.x * MOUSE_SENSITIVITY, rotVec.y * MOUSE_SENSITIVITY, 0); } // Update camera position Vector3f prevPos = new Vector3f(camera.getPosition()); camera.movePosition(cameraInc.x * CAMERA_POS_STEP, cameraInc.y * CAMERA_POS_STEP, cameraInc.z * CAMERA_POS_STEP); // Check if there has been a collision. If true, set the y position to // the maximum height float height = terrain != null ? terrain.getHeight(camera.getPosition()) : -Float.MAX_VALUE; if (camera.getPosition().y <= height) { camera.setPosition(prevPos.x, prevPos.y, prevPos.z); } lightAngle += angleInc; if (lightAngle < 0) { lightAngle = 0; } else if (lightAngle > 180) { lightAngle = 180; } float zValue = (float) Math.cos(Math.toRadians(lightAngle)); float yValue = (float) Math.sin(Math.toRadians(lightAngle)); Vector3f lightDirection = this.scene.getSceneLight().getDirectionalLight().getDirection(); lightDirection.x = 0; lightDirection.y = yValue; lightDirection.z = zValue; lightDirection.normalize(); }
@Override public void update(float interval, MouseInput mouseInput) { // Update camera based on mouse if (mouseInput.isRightButtonPressed()) { Vector2f rotVec = mouseInput.getDisplVec(); camera.moveRotation(rotVec.x * MOUSE_SENSITIVITY, rotVec.y * MOUSE_SENSITIVITY, 0); } // Update camera position Vector3f prevPos = new Vector3f(camera.getPosition()); camera.movePosition(cameraInc.x * CAMERA_POS_STEP, cameraInc.y * CAMERA_POS_STEP, cameraInc.z * CAMERA_POS_STEP); // Check if there has been a collision. If true, set the y position to // the maximum height float height = terrain != null ? terrain.getHeight(camera.getPosition()) : -Float.MAX_VALUE; if (camera.getPosition().y <= height) { camera.setPosition(prevPos.x, prevPos.y, prevPos.z); } lightAngle += angleInc; if (lightAngle < 0) { lightAngle = 0; } else if (lightAngle > 180) { lightAngle = 180; } float zValue = (float) Math.cos(Math.toRadians(lightAngle)); float yValue = (float) Math.sin(Math.toRadians(lightAngle)); Vector3f lightDirection = this.scene.getSceneLight().getDirectionalLight().getDirection(); lightDirection.x = 0; lightDirection.y = yValue; lightDirection.z = zValue; lightDirection.normalize(); }
@Override public void update(float interval, MouseInput mouseInput) { // Update camera based on mouse if (mouseInput.isRightButtonPressed()) { Vector2f rotVec = mouseInput.getDisplVec(); camera.moveRotation(rotVec.x * MOUSE_SENSITIVITY, rotVec.y * MOUSE_SENSITIVITY, 0); } // Update camera position Vector3f prevPos = new Vector3f(camera.getPosition()); camera.movePosition(cameraInc.x * CAMERA_POS_STEP, cameraInc.y * CAMERA_POS_STEP, cameraInc.z * CAMERA_POS_STEP); // Check if there has been a collision. If true, set the y position to // the maximum height float height = terrain != null ? terrain.getHeight(camera.getPosition()) : -Float.MAX_VALUE; if (camera.getPosition().y <= height) { camera.setPosition(prevPos.x, prevPos.y, prevPos.z); } // Update directional light direction, intensity and colour SceneLight sceneLight = scene.getSceneLight(); DirectionalLight directionalLight = sceneLight.getDirectionalLight(); double angRad = Math.toRadians(lightAngle); directionalLight.getDirection().x = (float) Math.sin(angRad); directionalLight.getDirection().y = (float) Math.cos(angRad); }
@Override public void update(float interval, MouseInput mouseInput) { if (mouseInput.isRightButtonPressed()) { Vector2f rotVec = mouseInput.getDisplVec(); camera.moveRotation(rotVec.x * MOUSE_SENSITIVITY, rotVec.y * MOUSE_SENSITIVITY, 0);
@Override public void update(float interval, MouseInput mouseInput) { if (mouseInput.isRightButtonPressed()) { Vector2f rotVec = mouseInput.getDisplVec(); camera.moveRotation(rotVec.x * MOUSE_SENSITIVITY, rotVec.y * MOUSE_SENSITIVITY, 0);
@Override public void update(float interval, MouseInput mouseInput) { if (mouseInput.isRightButtonPressed()) { Vector2f rotVec = mouseInput.getDisplVec(); camera.moveRotation(rotVec.x * MOUSE_SENSITIVITY, rotVec.y * MOUSE_SENSITIVITY, 0);
@Override public void update(float interval, MouseInput mouseInput) { if (mouseInput.isRightButtonPressed()) { Vector2f rotVec = mouseInput.getDisplVec(); camera.moveRotation(rotVec.x * MOUSE_SENSITIVITY, rotVec.y * MOUSE_SENSITIVITY, 0);
@Override public void update(float interval, MouseInput mouseInput, Window window) { if (mouseInput.isRightButtonPressed()) {
@Override public void update(float interval, MouseInput mouseInput, Window window) { if (mouseInput.isRightButtonPressed()) {