@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(); }