]> git.tdb.fi Git - r2c2.git/blobdiff - source/designer/cameracontroller.h
Also check if the clock is stopped
[r2c2.git] / source / designer / cameracontroller.h
index 63ba2c13027f528f1c63a376c66bb70242c6e98d..5b6c3155314c74b2eb5b705aa90eabbeab67eee2 100644 (file)
@@ -1,34 +1,78 @@
-/* $Id$
-
-This file is part of the MSP Märklin suite
-Copyright © 2010 Mikkosoft Productions, Mikko Rasa
-Distributed under the GPL
-*/
-
 #ifndef CAMERACONTROLLER_H_
 #define CAMERACONTROLLER_H_
 
-#include <msp/gbase/window.h>
+#include <msp/graphics/window.h>
 #include <msp/gl/camera.h>
+#include <msp/input/keyboard.h>
+#include <msp/input/mouse.h>
+#include "3d/view.h"
 
+/**
+Moves the camera based on keyboard and mouse events.  Controls are as follows:
+
+Arrow keys  - pan
+Home        - view all
+Insert      - view from top down
+Wheel       - adjust viewing distance
+RMB         - rotate
+MMB         - pan
+Shift + RMB - pan
+Shift + MMB - rotate
+Ctrl + RMB  - adjust viewing distance
+Ctrl + MMB  - adjust viewing distance
+*/
 class CameraController
 {
 private:
-       Msp::Graphics::Window &window;
+       enum DragMode
+       {
+               NONE,
+               PAN,
+               ROTATE,
+               DISTANCE
+       };
+
+       R2C2::View3D &view;
+       Msp::Input::Keyboard &keyboard;
+       Msp::Input::Mouse &mouse;
        Msp::GL::Camera &camera;
        int move_x;
        int move_y;
-       int zoom;
-       int rotate;
-       int pitch;
+       int pointer_x;
+       int pointer_y;
+       bool shift_pressed;
+       bool ctrl_pressed;
+       DragMode drag_mode;
 
 public:
-       CameraController(Msp::Graphics::Window &, Msp::GL::Camera &);
+       CameraController(R2C2::View3D &, Msp::Input::Keyboard &, Msp::Input::Mouse &);
+
+       void top_down();
+       void set_look_direction(const Msp::GL::Vector3 &);
+       void view_all();
+
+       void move(float, float);
+       void adjust_distance(float);
+       void rotate(const R2C2::Angle &);
+       void pitch(const R2C2::Angle &);
 
        void tick(float);
 private:
-       void key_press(unsigned, unsigned, wchar_t);
-       void key_release(unsigned, unsigned);
+       void button_press(unsigned);
+       void button_release(unsigned);
+       void axis_motion(unsigned, float, float);
+       void key_press(unsigned);
+       void key_release(unsigned);
+
+public:
+       /** Return the focus point, i.e. where the look ray intersects with ground. */
+       Msp::GL::Vector3 get_focus() const;
+
+       /** Return distance from the focus point. */
+       float get_distance() const;
+
+       /** Return the viewport height at focus distance. */
+       float get_view_scale() const;
 };
 
 #endif