Jelajahi Sumber

Add methods to control FlyByCamera zooming speed.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9759 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
iwg..ic 13 tahun lalu
induk
melakukan
8daa039ecc
1 mengubah file dengan 19 tambahan dan 1 penghapusan
  1. 19 1
      engine/src/core/com/jme3/input/FlyByCamera.java

+ 19 - 1
engine/src/core/com/jme3/input/FlyByCamera.java

@@ -76,6 +76,7 @@ public class FlyByCamera implements AnalogListener, ActionListener {
     protected Vector3f initialUpVec;
     protected float rotationSpeed = 1f;
     protected float moveSpeed = 3f;
+    protected float zoomSpeed = 1f;
     protected MotionAllowedListener motionAllowed = null;
     protected boolean enabled = true;
     protected boolean dragToRotate = false;
@@ -134,6 +135,23 @@ public class FlyByCamera implements AnalogListener, ActionListener {
     public float getRotationSpeed(){
         return rotationSpeed;
     }
+    
+    /**
+     * Sets the zoom speed.
+     * @param zoomSpeed 
+     */
+    public void setZoomSpeed(float zoomSpeed) {
+        this.zoomSpeed = zoomSpeed;
+    }
+    
+    /**
+     * Gets the zoom speed.  The speed is a multiplier to increase/decrease
+     * the zoom rate.
+     * @return zoomSpeed
+     */
+    public float getZoomSpeed() {
+        return zoomSpeed;
+    }
 
     /**
      * @param enable If false, the camera will ignore input.
@@ -294,7 +312,7 @@ public class FlyByCamera implements AnalogListener, ActionListener {
 
         float fovY = FastMath.atan(h / near)
                   / (FastMath.DEG_TO_RAD * .5f);
-        fovY += value * 0.1f;
+        fovY += value * 0.1f * zoomSpeed;
 
         h = FastMath.tan( fovY * FastMath.DEG_TO_RAD * .5f) * near;
         w = h * aspect;