@Override protected void updateShadowCams(Camera viewCam) { if (light == null) { logger.warning("The light can't be null for a " + getClass().getName()); return; } //bottom shadowCams[0].setAxes(Vector3f.UNIT_X.mult(-1f), Vector3f.UNIT_Z.mult(-1f), Vector3f.UNIT_Y.mult(-1f)); //top shadowCams[1].setAxes(Vector3f.UNIT_X.mult(-1f), Vector3f.UNIT_Z, Vector3f.UNIT_Y); //forward shadowCams[2].setAxes(Vector3f.UNIT_X.mult(-1f), Vector3f.UNIT_Y, Vector3f.UNIT_Z.mult(-1f)); //backward shadowCams[3].setAxes(Vector3f.UNIT_X, Vector3f.UNIT_Y, Vector3f.UNIT_Z); //left shadowCams[4].setAxes(Vector3f.UNIT_Z, Vector3f.UNIT_Y, Vector3f.UNIT_X.mult(-1f)); //right shadowCams[5].setAxes(Vector3f.UNIT_Z.mult(-1f), Vector3f.UNIT_Y, Vector3f.UNIT_X); for (int i = 0; i < CAM_NUMBER; i++) { shadowCams[i].setFrustumPerspective(90f, 1f, 0.1f, light.getRadius()); shadowCams[i].setLocation(light.getPosition()); shadowCams[i].update(); shadowCams[i].updateViewProjection(); } }
/** * Creates an off camera * * @param mapSize the size * @param worldPos the position * @param axisX the x axis * @param axisY the y axis * @param axisZ tha z axis * @return */ protected Camera createOffCamera(final int mapSize, final Vector3f worldPos, final Vector3f axisX, final Vector3f axisY, final Vector3f axisZ) { final Camera offCamera = new Camera(mapSize, mapSize); offCamera.setLocation(worldPos); offCamera.setAxes(axisX, axisY, axisZ); offCamera.setFrustumPerspective(90f, 1f, 0.1f, 1000); offCamera.setLocation(position); return offCamera; }
q.normalizeLocal(); cam.setAxes(q);
reflectLeft.subtractLocal(camLoc); reflectionCam.setAxes(reflectLeft, reflectUp, reflectDirection);
@Override protected void updateShadowCams(Camera viewCam) { if (light == null) { logger.warning("The light can't be null for a " + getClass().getName()); return; } //bottom shadowCams[0].setAxes(Vector3f.UNIT_X.mult(-1f), Vector3f.UNIT_Z.mult(-1f), Vector3f.UNIT_Y.mult(-1f)); //top shadowCams[1].setAxes(Vector3f.UNIT_X.mult(-1f), Vector3f.UNIT_Z, Vector3f.UNIT_Y); //forward shadowCams[2].setAxes(Vector3f.UNIT_X.mult(-1f), Vector3f.UNIT_Y, Vector3f.UNIT_Z.mult(-1f)); //backward shadowCams[3].setAxes(Vector3f.UNIT_X, Vector3f.UNIT_Y, Vector3f.UNIT_Z); //left shadowCams[4].setAxes(Vector3f.UNIT_Z, Vector3f.UNIT_Y, Vector3f.UNIT_X.mult(-1f)); //right shadowCams[5].setAxes(Vector3f.UNIT_Z.mult(-1f), Vector3f.UNIT_Y, Vector3f.UNIT_X); for (int i = 0; i < CAM_NUMBER; i++) { shadowCams[i].setFrustumPerspective(90f, 1f, 0.1f, light.getRadius()); shadowCams[i].setLocation(light.getPosition()); shadowCams[i].update(); shadowCams[i].updateViewProjection(); } }
/** * Creates an off camera * * @param mapSize the size * @param worldPos the position * @param axisX the x axis * @param axisY the y axis * @param axisZ tha z axis * @return */ protected Camera createOffCamera(final int mapSize, final Vector3f worldPos, final Vector3f axisX, final Vector3f axisY, final Vector3f axisZ) { final Camera offCamera = new Camera(mapSize, mapSize); offCamera.setLocation(worldPos); offCamera.setAxes(axisX, axisY, axisZ); offCamera.setFrustumPerspective(90f, 1f, 1, 1000); offCamera.setLocation(position); return offCamera; }
/** * Load the initial camera position */ private void loadCameraStartLocation() { Point p = target.getCreatureCoordinates(); Vector3f startLocation = new Vector3f(p.x, target.getHeight(), p.y); Camera cam = app.getCamera(); cam.setLocation(startLocation.addLocal(0, creature.getAttributes().getEyeHeight(), 0)); //cam.setFrustumPerspective(45, cam.getWidth() / cam.getHeight(), 0.1f, creature.getDistanceCanSee() * 10); cam.setAxes(Vector3f.UNIT_X, Vector3f.UNIT_Y, Vector3f.UNIT_Z); }
private void rotate(float value, Vector3f axis) { Matrix3f mat = new Matrix3f(); mat.fromAngleNormalAxis(value, axis); Vector3f up = cam.getUp(); Vector3f left = cam.getLeft(); Vector3f dir = cam.getDirection(); mat.mult(up, up); mat.mult(left, left); mat.mult(dir, dir); Quaternion q = new Quaternion(); q.fromAxes(left, up, dir); cam.setAxes(q); }
public void rotateCamera(float value, Vector3f axis){ if (dragToRotate){ if (canRotate){ // value = -value; }else{ return; } } Matrix3f mat = new Matrix3f(); mat.fromAngleNormalAxis(rotationSpeed * value, axis); Vector3f up = cam.getUp(); Vector3f left = cam.getLeft(); Vector3f dir = cam.getDirection(); mat.mult(up, up); mat.mult(left, left); mat.mult(dir, dir); Quaternion q = new Quaternion(); q.fromAxes(left, up, dir); q.normalizeLocal(); cam.setAxes(q); }
protected void rotateCamera(float value, Vector3f axis){ if (dragToRotate){ if (canRotate){ // value = -value; }else{ return; } } Matrix3f mat = new Matrix3f(); mat.fromAngleNormalAxis(rotationSpeed * value, axis); Vector3f up = cam.getUp(); Vector3f left = cam.getLeft(); Vector3f dir = cam.getDirection(); mat.mult(up, up); mat.mult(left, left); mat.mult(dir, dir); Quaternion q = new Quaternion(); q.fromAxes(left, up, dir); q.normalizeLocal(); cam.setAxes(q); }
public void rotateCamera(float value, Vector3f axis){ if (dragToRotate){ if (canRotate){ // value = -value; }else{ return; } } Matrix3f mat = new Matrix3f(); mat.fromAngleNormalAxis(rotationSpeed * value, axis); Vector3f up = cam.getUp(); Vector3f left = cam.getLeft(); Vector3f dir = cam.getDirection(); mat.mult(up, up); mat.mult(left, left); mat.mult(dir, dir); Quaternion q = new Quaternion(); q.fromAxes(left, up, dir); q.normalizeLocal(); cam.setAxes(q); }
q.normalizeLocal(); cam.setAxes(q);
protected void rotate(float value, boolean sideways) { Matrix3f mat = new Matrix3f(); if (sideways) { mat.fromAngleNormalAxis(ROTATION_SPEED * value, Vector3f.UNIT_Y.clone()); } else { mat.fromAngleNormalAxis(ROTATION_SPEED * value, camera.getLeft().clone()); } Vector3f up = camera.getUp(); Vector3f left = camera.getLeft(); Vector3f dir = camera.getDirection(); mat.mult(up, up); mat.mult(left, left); mat.mult(dir, dir); if (dir.y < -Y_ANGLE_MAX || dir.y > Y_ANGLE_MAX) { return; } Quaternion q = new Quaternion(); q.fromAxes(left, up, dir); q.normalizeLocal(); camera.setAxes(q); }
/** * Rotating is circling around the camera look at point, or similar * * @param value */ public void rotateAround(float value) { Matrix3f mat = new Matrix3f(); mat.fromAngleNormalAxis(value, Vector3f.UNIT_Y.clone()); Vector3f up = cam.getUp(); Vector3f left = cam.getLeft(); Vector3f dir = cam.getDirection(); Vector3f pos = cam.getLocation(); Vector3f look = getLookAt(); pos.subtractLocal(look); mat.mult(up, up); mat.mult(left, left); mat.mult(dir, dir); mat.mult(pos, pos); Quaternion q = new Quaternion(); q.fromAxes(left, up, dir); q.normalizeLocal(); cam.setLocation(look.addLocal(pos)); cam.setAxes(q); }
public void initCam() { /** Configure cam to look at scene */ cam.setLocation(new Vector3f(appSize / 2, 0, appSize / 2)); cam.lookAt(new Vector3f(appSize / 2, 0, appSize / 2), Vector3f.UNIT_Y); cam.setFrustumNear(1f); cam.setFrustumFar(appSize * 5); app.getFlyByCamera().setEnabled(false); this.isoCam = new IsoCamera(cam, inputManager, app); camNode = isoCam.getCamNode(); rootNode.attachChild(camNode); cam_map = new Camera(150, 150); cam_map.setAxes(new Vector3f(1, 0, 0), new Vector3f(0, 1, 0), new Vector3f(0, 0, 0)); cam_map.setFrustumNear(1f); cam_map.setFrustumFar(appSize * 5); cam_map.setFrustumPerspective(45f, 1, 1, appSize * 5); cam_map.setLocation(new Vector3f(appSize / 2, appSize / 1.5f, appSize / 2f)); cam_map.lookAt(new Vector3f(appSize / 2, 0, appSize / 2), Vector3f.UNIT_Y); ViewPort view_map = this.app.getRenderManager().createMainView("MapView", cam_map); view_map.setEnabled(true); view_map.setClearFlags(true, true, true); view_map.attachScene(rootNode); view_map.setBackgroundColor(ColorRGBA.White); cam_map.update(); }
reflectLeft.subtractLocal(camLoc); reflectionCam.setAxes(reflectLeft, reflectUp, reflectDirection);
reflectLeft.subtractLocal(camLoc); reflectionCam.setAxes(reflectLeft, reflectUp, reflectDirection);
reflectionCam.setAxes(reflectionCam.getLeft().negateLocal(), reflectionCam.getUp(), reflectionCam.getDirection().negateLocal());
reflectionCam.setAxes(reflectionCam.getLeft().negateLocal(), reflectionCam.getUp(), reflectionCam.getDirection().negateLocal());