X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fdesigner%2Fcameracontroller.h;fp=source%2Fdesigner%2Fcameracontroller.h;h=b39b3d5a59a6d0f173e69905888d17c849514510;hb=61da962442ae528bba9c66fa0c09427b53a4cbe0;hp=63ba2c13027f528f1c63a376c66bb70242c6e98d;hpb=b3a73308d67de22a2d65cc56b14edeab25537eba;p=r2c2.git diff --git a/source/designer/cameracontroller.h b/source/designer/cameracontroller.h index 63ba2c1..b39b3d5 100644 --- a/source/designer/cameracontroller.h +++ b/source/designer/cameracontroller.h @@ -11,24 +11,70 @@ Distributed under the GPL #include #include +class Designer; + +/** +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 + }; + + Designer &designer; + Msp::Graphics::EventSource &event_source; Msp::GL::Camera &camera; int move_x; int move_y; - int zoom; - int rotate; - int pitch; + int pointer_x; + int pointer_y; + DragMode drag_mode; public: - CameraController(Msp::Graphics::Window &, Msp::GL::Camera &); + CameraController(Designer &, Msp::Graphics::EventSource &, Msp::GL::Camera &); + + void top_down(); + void set_look_direction(const Msp::GL::Vector3 &); + void view_all(); + + void move(float, float); + void adjust_distance(float); + void rotate(float); + void pitch(float); void tick(float); private: + void button_press(int, int, unsigned, unsigned); + void button_release(int, int, unsigned, unsigned); + void pointer_motion(int, int); void key_press(unsigned, unsigned, wchar_t); void key_release(unsigned, unsigned); + + /** 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