- Fixed bug where if you set minDistance that is higher than the current distance, the camera view would still remain at the old distance.

- Same as above but for maxDistance.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9680 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
dan..om 13 years ago
parent c842eefb90
commit 133bd21ab9
  1. 38
      engine/src/core/com/jme3/input/ChaseCamera.java

@ -134,7 +134,7 @@ public class ChaseCamera implements ActionListener, AnalogListener, Control {
* Constructs the chase camera, and registers inputs * Constructs the chase camera, and registers inputs
* if you use this constructor you have to attach the cam later to a spatial * if you use this constructor you have to attach the cam later to a spatial
* doing spatial.addControl(chaseCamera); * doing spatial.addControl(chaseCamera);
* @param cam the application camera * @param cam the application camera
* @param inputManager the inputManager of the application to register inputs * @param inputManager the inputManager of the application to register inputs
*/ */
public ChaseCamera(Camera cam, InputManager inputManager) { public ChaseCamera(Camera cam, InputManager inputManager) {
@ -167,7 +167,7 @@ public class ChaseCamera implements ActionListener, AnalogListener, Control {
} }
} }
public void onAnalog(String name, float value, float tpf) { public void onAnalog(String name, float value, float tpf) {
if (name.equals(ChaseCamMoveLeft)) { if (name.equals(ChaseCamMoveLeft)) {
@ -370,7 +370,7 @@ public class ChaseCamera implements ActionListener, AnalogListener, Control {
if (canRotate) { if (canRotate) {
//reseting the trailing lerp factor //reseting the trailing lerp factor
trailingLerpFactor = 0; trailingLerpFactor = 0;
//stop trailing user has the control //stop trailing user has the control
trailing = false; trailing = false;
} }
@ -466,7 +466,7 @@ public class ChaseCamera implements ActionListener, AnalogListener, Control {
//keeping track on the previous position of the target //keeping track on the previous position of the target
prevPos.set(targetLocation); prevPos.set(targetLocation);
//the cam looks at the target //the cam looks at the target
cam.lookAt(targetLocation, initialUpVec); cam.lookAt(targetLocation, initialUpVec);
} }
@ -505,6 +505,9 @@ public class ChaseCamera implements ActionListener, AnalogListener, Control {
*/ */
public void setMaxDistance(float maxDistance) { public void setMaxDistance(float maxDistance) {
this.maxDistance = maxDistance; this.maxDistance = maxDistance;
if (maxDistance < distance) {
zoomCamera(maxDistance - distance);
}
} }
/** /**
@ -521,6 +524,9 @@ public class ChaseCamera implements ActionListener, AnalogListener, Control {
*/ */
public void setMinDistance(float minDistance) { public void setMinDistance(float minDistance) {
this.minDistance = minDistance; this.minDistance = minDistance;
if (minDistance > distance) {
zoomCamera(distance - minDistance);
}
} }
/** /**
@ -604,7 +610,7 @@ public class ChaseCamera implements ActionListener, AnalogListener, Control {
} }
/** /**
* *
* @return The minimal vertical rotation angle in radian of the camera around the target * @return The minimal vertical rotation angle in radian of the camera around the target
*/ */
public float getMinVerticalRotation() { public float getMinVerticalRotation() {
@ -643,7 +649,7 @@ public class ChaseCamera implements ActionListener, AnalogListener, Control {
} }
/** /**
* *
* Sets the chasing sensitivity, the lower the value the slower the camera will follow the target when it moves * Sets the chasing sensitivity, the lower the value the slower the camera will follow the target when it moves
* default is 5 * default is 5
* Only has an effect if smoothMotion is set to true and trailing is enabled * Only has an effect if smoothMotion is set to true and trailing is enabled
@ -665,7 +671,7 @@ public class ChaseCamera implements ActionListener, AnalogListener, Control {
* Sets the rotation sensitivity, the lower the value the slower the camera will rotates around the target when draging with the mouse * Sets the rotation sensitivity, the lower the value the slower the camera will rotates around the target when draging with the mouse
* default is 5, values over 5 should have no effect. * default is 5, values over 5 should have no effect.
* If you want a significant slow down try values below 1. * If you want a significant slow down try values below 1.
* Only has an effect if smoothMotion is set to true * Only has an effect if smoothMotion is set to true
* @param rotationSensitivity * @param rotationSensitivity
*/ */
public void setRotationSensitivity(float rotationSensitivity) { public void setRotationSensitivity(float rotationSensitivity) {
@ -682,7 +688,7 @@ public class ChaseCamera implements ActionListener, AnalogListener, Control {
/** /**
* Enable the camera trailing : The camera smoothly go in the targets trail when it moves. * Enable the camera trailing : The camera smoothly go in the targets trail when it moves.
* Only has an effect if smoothMotion is set to true * Only has an effect if smoothMotion is set to true
* @param trailingEnabled * @param trailingEnabled
*/ */
public void setTrailingEnabled(boolean trailingEnabled) { public void setTrailingEnabled(boolean trailingEnabled) {
@ -690,7 +696,7 @@ public class ChaseCamera implements ActionListener, AnalogListener, Control {
} }
/** /**
* *
* returns the trailing rotation inertia * returns the trailing rotation inertia
* @return * @return
*/ */
@ -793,7 +799,7 @@ public class ChaseCamera implements ActionListener, AnalogListener, Control {
} }
/** /**
* @param rotateOnlyWhenClose When this flag is set to false the chase * @param rotateOnlyWhenClose When this flag is set to false the chase
* camera will always rotate around its spatial independently of their * camera will always rotate around its spatial independently of their
* distance to one another. If set to true, the chase camera will only * distance to one another. If set to true, the chase camera will only
* be allowed to rotated below the "horizon" when the distance is smaller * be allowed to rotated below the "horizon" when the distance is smaller
@ -804,8 +810,8 @@ public class ChaseCamera implements ActionListener, AnalogListener, Control {
} }
/** /**
* @return True if rotation below the vertical plane of the spatial tied * @return True if rotation below the vertical plane of the spatial tied
* to the camera is allowed only when zoomed in at minDistance + 1.0f. * to the camera is allowed only when zoomed in at minDistance + 1.0f.
* False if vertical rotation is always allowed. * False if vertical rotation is always allowed.
*/ */
public boolean getDownRotateOnCloseViewOnly() { public boolean getDownRotateOnCloseViewOnly() {
@ -851,18 +857,18 @@ public class ChaseCamera implements ActionListener, AnalogListener, Control {
public void setLookAtOffset(Vector3f lookAtOffset) { public void setLookAtOffset(Vector3f lookAtOffset) {
this.lookAtOffset = lookAtOffset; this.lookAtOffset = lookAtOffset;
} }
/** /**
* Sets the up vector of the camera used for the lookAt on the target * Sets the up vector of the camera used for the lookAt on the target
* @param up * @param up
*/ */
public void setUpVector(Vector3f up){ public void setUpVector(Vector3f up){
initialUpVec=up; initialUpVec=up;
} }
/** /**
* Returns the up vector of the camera used for the lookAt on the target * Returns the up vector of the camera used for the lookAt on the target
* @return * @return
*/ */
public Vector3f getUpVector(){ public Vector3f getUpVector(){
return initialUpVec; return initialUpVec;

Loading…
Cancel
Save