|
|
|
@ -55,61 +55,61 @@ import java.io.IOException; |
|
|
|
|
*/ |
|
|
|
|
public class ChaseCamera implements ActionListener, AnalogListener, Control { |
|
|
|
|
|
|
|
|
|
private Spatial target = null; |
|
|
|
|
private float minVerticalRotation = 0.00f; |
|
|
|
|
private float maxVerticalRotation = FastMath.PI / 2; |
|
|
|
|
private float minDistance = 1.0f; |
|
|
|
|
private float maxDistance = 40.0f; |
|
|
|
|
private float distance = 20; |
|
|
|
|
private float zoomSpeed = 2f; |
|
|
|
|
private float rotationSpeed = 1.0f; |
|
|
|
|
private float rotation = 0; |
|
|
|
|
private float trailingRotationInertia = 0.05f; |
|
|
|
|
private float zoomSensitivity = 5f; |
|
|
|
|
private float rotationSensitivity = 5f; |
|
|
|
|
private float chasingSensitivity = 5f; |
|
|
|
|
private float trailingSensitivity = 0.5f; |
|
|
|
|
private float vRotation = FastMath.PI / 6; |
|
|
|
|
private boolean smoothMotion = false; |
|
|
|
|
private boolean trailingEnabled = true; |
|
|
|
|
private float rotationLerpFactor = 0; |
|
|
|
|
private float trailingLerpFactor = 0; |
|
|
|
|
private boolean rotating = false; |
|
|
|
|
private boolean vRotating = false; |
|
|
|
|
private float targetRotation = rotation; |
|
|
|
|
private InputManager inputManager; |
|
|
|
|
private Vector3f initialUpVec; |
|
|
|
|
private float targetVRotation = vRotation; |
|
|
|
|
private float vRotationLerpFactor = 0; |
|
|
|
|
private float targetDistance = distance; |
|
|
|
|
private float distanceLerpFactor = 0; |
|
|
|
|
private boolean zooming = false; |
|
|
|
|
private boolean trailing = false; |
|
|
|
|
private boolean chasing = false; |
|
|
|
|
private boolean canRotate; |
|
|
|
|
private float offsetDistance = 0.002f; |
|
|
|
|
private Vector3f prevPos; |
|
|
|
|
private boolean targetMoves = false; |
|
|
|
|
private boolean enabled = true; |
|
|
|
|
private Camera cam = null; |
|
|
|
|
private final Vector3f targetDir = new Vector3f(); |
|
|
|
|
private float previousTargetRotation; |
|
|
|
|
private final Vector3f pos = new Vector3f(); |
|
|
|
|
protected Spatial target = null; |
|
|
|
|
protected float minVerticalRotation = 0.00f; |
|
|
|
|
protected float maxVerticalRotation = FastMath.PI / 2; |
|
|
|
|
protected float minDistance = 1.0f; |
|
|
|
|
protected float maxDistance = 40.0f; |
|
|
|
|
protected float distance = 20; |
|
|
|
|
protected float zoomSpeed = 2f; |
|
|
|
|
protected float rotationSpeed = 1.0f; |
|
|
|
|
protected float rotation = 0; |
|
|
|
|
protected float trailingRotationInertia = 0.05f; |
|
|
|
|
protected float zoomSensitivity = 5f; |
|
|
|
|
protected float rotationSensitivity = 5f; |
|
|
|
|
protected float chasingSensitivity = 5f; |
|
|
|
|
protected float trailingSensitivity = 0.5f; |
|
|
|
|
protected float vRotation = FastMath.PI / 6; |
|
|
|
|
protected boolean smoothMotion = false; |
|
|
|
|
protected boolean trailingEnabled = true; |
|
|
|
|
protected float rotationLerpFactor = 0; |
|
|
|
|
protected float trailingLerpFactor = 0; |
|
|
|
|
protected boolean rotating = false; |
|
|
|
|
protected boolean vRotating = false; |
|
|
|
|
protected float targetRotation = rotation; |
|
|
|
|
protected InputManager inputManager; |
|
|
|
|
protected Vector3f initialUpVec; |
|
|
|
|
protected float targetVRotation = vRotation; |
|
|
|
|
protected float vRotationLerpFactor = 0; |
|
|
|
|
protected float targetDistance = distance; |
|
|
|
|
protected float distanceLerpFactor = 0; |
|
|
|
|
protected boolean zooming = false; |
|
|
|
|
protected boolean trailing = false; |
|
|
|
|
protected boolean chasing = false; |
|
|
|
|
protected boolean canRotate; |
|
|
|
|
protected float offsetDistance = 0.002f; |
|
|
|
|
protected Vector3f prevPos; |
|
|
|
|
protected boolean targetMoves = false; |
|
|
|
|
protected boolean enabled = true; |
|
|
|
|
protected Camera cam = null; |
|
|
|
|
protected final Vector3f targetDir = new Vector3f(); |
|
|
|
|
protected float previousTargetRotation; |
|
|
|
|
protected final Vector3f pos = new Vector3f(); |
|
|
|
|
protected Vector3f targetLocation = new Vector3f(0, 0, 0); |
|
|
|
|
protected boolean dragToRotate = true; |
|
|
|
|
protected Vector3f lookAtOffset = new Vector3f(0, 0, 0); |
|
|
|
|
protected boolean leftClickRotate = true; |
|
|
|
|
protected boolean rightClickRotate = true; |
|
|
|
|
private Vector3f temp = new Vector3f(0, 0, 0); |
|
|
|
|
protected Vector3f temp = new Vector3f(0, 0, 0); |
|
|
|
|
protected boolean invertYaxis = false; |
|
|
|
|
protected boolean invertXaxis = false; |
|
|
|
|
private final static String ChaseCamDown = "ChaseCamDown"; |
|
|
|
|
private final static String ChaseCamUp = "ChaseCamUp"; |
|
|
|
|
private final static String ChaseCamZoomIn = "ChaseCamZoomIn"; |
|
|
|
|
private final static String ChaseCamZoomOut = "ChaseCamZoomOut"; |
|
|
|
|
private final static String ChaseCamMoveLeft = "ChaseCamMoveLeft"; |
|
|
|
|
private final static String ChaseCamMoveRight = "ChaseCamMoveRight"; |
|
|
|
|
private final static String ChaseCamToggleRotate = "ChaseCamToggleRotate"; |
|
|
|
|
protected final static String ChaseCamDown = "ChaseCamDown"; |
|
|
|
|
protected final static String ChaseCamUp = "ChaseCamUp"; |
|
|
|
|
protected final static String ChaseCamZoomIn = "ChaseCamZoomIn"; |
|
|
|
|
protected final static String ChaseCamZoomOut = "ChaseCamZoomOut"; |
|
|
|
|
protected final static String ChaseCamMoveLeft = "ChaseCamMoveLeft"; |
|
|
|
|
protected final static String ChaseCamMoveRight = "ChaseCamMoveRight"; |
|
|
|
|
protected final static String ChaseCamToggleRotate = "ChaseCamToggleRotate"; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Constructs the chase camera |
|
|
|
|