Sfoglia il codice sorgente

- Added zooming feature to the orthograpic view by using the mousewheel.

- Refined some coding.
weinand 9 anni fa
parent
commit
e5bf316179
1 ha cambiato i file con 25 aggiunte e 18 eliminazioni
  1. 25 18
      Source/AtomicEditor/Editors/SceneEditor3D/SceneView3D.cpp

+ 25 - 18
Source/AtomicEditor/Editors/SceneEditor3D/SceneView3D.cpp

@@ -211,6 +211,19 @@ void SceneView3D::MoveCamera(float timeStep)
     bool zooming = GetZooming();
     bool changingCameraSpeed = GetChangingCameraSpeed();
 
+    // Movement speed as world units per second
+    float MOVE_SPEED = 20.0f;
+    // Mouse sensitivity as degrees per pixel
+    const float MOUSE_SENSITIVITY = 0.2f;
+
+    // Orthographic zoom settings
+    float currCameraZoom = camera_->GetZoom();
+    const float ZOOM_INCREMENT = 0.1f;
+    const float DEFAULT_ZOOM = 1.0f;
+
+    if (shiftDown)
+        MOVE_SPEED *= 3.0f;
+
     // Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch between -90 and 90 degrees
     if ((mouseInView && input->GetMouseButtonDown(MOUSEB_RIGHT)) || orbitting)
     {
@@ -323,6 +336,16 @@ void SceneView3D::MoveCamera(float timeStep)
         cameraNode_->SetWorldPosition(pos);
 
     }
+
+    if (camera_->IsOrthographic() && mouseInView && !orbitting)
+    {
+        if (input->GetMouseMoveWheel() > 0)
+            camera_->SetZoom(currCameraZoom + ZOOM_INCREMENT);
+        if (input->GetMouseMoveWheel() < 0)
+            camera_->SetZoom(currCameraZoom - ZOOM_INCREMENT);
+    }
+    else
+        camera_->SetZoom(DEFAULT_ZOOM);
 }
 
 void SceneView3D::SnapCameraToView(int snapView)
@@ -385,35 +408,19 @@ void SceneView3D::SelectView()
     if (MouseInView())
     {
         if (input->GetKeyPress(KEY_1))
-        {
             snapView = 1;
-            SetPerspectiveCameraPosition();
-        }
         if (input->GetKeyPress(KEY_2))
-        {
             snapView = 2;
-            SetPerspectiveCameraPosition();
-        }
         if (input->GetKeyPress(KEY_3))
-        {
             snapView = 3;
-            SetPerspectiveCameraPosition();
-        }
         if (input->GetKeyPress(KEY_4))
-        {
             snapView = 4;
-            SetPerspectiveCameraPosition();
-        }
         if (input->GetKeyPress(KEY_5))
-        {
             snapView = 5;
-            SetPerspectiveCameraPosition();
-        }
         if (input->GetKeyPress(KEY_6))
-        {
             snapView = 6;
-            SetPerspectiveCameraPosition();
-        }
+
+        SetPerspectiveCameraPosition();
 
         if (input->GetKeyPress(KEY_P))
         {