CameraController.hpp 2.42 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#pragma once

#include "Camera.hpp"
#include "vkcv/Window.hpp"

namespace vkcv {

    /**
     * @brief Used as a base class for defining camera controller classes with different behaviors, e.g. the
     * #PilotCameraController.
     */
    class CameraController {
    protected:
        Camera* m_camera;
        Window* m_window;
        double m_lastX;
        double m_lastY;

    public:

        /**
         * @brief The constructor of the #CameraController (default behavior).
         */
        CameraController() = default;

        /**
         * @brief Gets the camera object.
         * @return The camera object.
         */
        Camera& getCamera();

        /**
         * @brief Sets @p camera as the new camera object.
         * @param camera The new camera object.
         */
        virtual void setCamera(Camera &camera);

        /**
         * @brief Sets @p window as the new window object.
         * @param window The new window object.
         */
        void setWindow(Window &window);

        /**
         * @brief Updates the camera object in respect to @p deltaTime.
         * @param deltaTime The time that has passed since last update.
         */
        virtual void updateCamera(double deltaTime);

        /**
         * @brief A callback function for key events.
         * @param[in] key The keyboard key.
         * @param[in] scancode The platform-specific scancode.
         * @param[in] action The key action.
         * @param[in] mods The modifier bits.
         */
        virtual void keyCallback(int key, int scancode, int action, int mods);

        /**
         * @brief A callback function for mouse scrolling events.
         * @param[in] offsetX The offset in horizontal direction.
         * @param[in] offsetY The offset in vertical direction.
         */
        virtual void scrollCallback( double offsetX, double offsetY);

        /**
         * @brief A callback function for mouse movement events.
         * @param[in] x The horizontal mouse position.
         * @param[in] y The vertical mouse position.
         */
        virtual void mouseMoveCallback(double offsetX, double offsetY);

        /**
         * @brief A callback function for mouse button events.
         * @param[in] button The mouse button.
         * @param[in] action The button action.
         * @param[in] mods The modifier bits.
         */
        virtual void mouseButtonCallback(int button, int action, int mods);
    };

}