ComputerGraphik TU WIEN
mouseSemantics.hpp
Go to the documentation of this file.
1 #ifndef MOUSESEMANTICS_HPP
2 #define MOUSESEMANTICS_HPP
3 
4 #include <glm/vec2.hpp>
5 #include <glm/glm.hpp>
6 #include <glm/gtx/epsilon.hpp>
7 #include <GL/glew.h>
8 #include <GLFW/glfw3.h>
9 
10 #include "sceneObject.hpp"
11 #include "shader.hpp"
12 #include "texture.hpp"
13 
14 #define MOUSE_MIN_MOVE 0.3
15 #define MOUSE_MAX_MOVE 3.5
16 #define MOUSE_CUTOFF 200
17 
19 
49 class MouseSemantics : public SceneObject {
50 private:
51  glm::vec2 latestPos;
52  int distance;
53  float M;
54  float C;
55  float m;
58  bool inWindow;
60  bool focused;
62  GLFWwindow *window;
63  GLuint vboPositions;
65 
66  float calculateScaleFactor();
67 
68 public:
69  MouseSemantics(Scene* scene, float _M, float _C, float _m, Texture* texture);
70  virtual ~MouseSemantics();
71 
72  void setShader(Shader *shader);
73  void draw();
74  void update(double deltaT);
75 
76  void cursorEnterCallBack(GLFWwindow *window, int entered);
77  void windowFocusCallBack(GLFWwindow *window, int entered);
78  void keyCallback(GLFWwindow *window, int key, int scancode, int action, int mods);
79 
80  void toggleScaleFunction();
81 
82  void updateDistanceState(unsigned int _distance);
83 
84  unsigned int getDistance() { return distance; };
85  std::string scaleFunction() { if (inverseScaleFunction) return "inverse"; else return "standard"; }
86  float getScaleFactor() { return additionalScaling; };
87  float getSpeed() { return calculateScaleFactor(); };
88  glm::ivec2 getMousePos() { return glm::ivec2(latestPos); }
89 };
90 
91 #endif //MOUSESEMANTICS_HPP
bool inWindow
Definition: mouseSemantics.hpp:58
float getScaleFactor()
Definition: mouseSemantics.hpp:86
glm::vec2 latestPos
Definition: mouseSemantics.hpp:51
void setShader(Shader *shader)
Definition: mouseSemantics.cpp:43
Texture * texture
Definition: mouseSemantics.hpp:64
bool firstTimeInWindow
Definition: mouseSemantics.hpp:59
bool scaleLinear
Definition: mouseSemantics.hpp:57
MouseSemantics(Scene *scene, float _M, float _C, float _m, Texture *texture)
Definition: mouseSemantics.cpp:13
bool inverseScaleFunction
Definition: mouseSemantics.hpp:61
float calculateScaleFactor()
Definition: mouseSemantics.cpp:148
void cursorEnterCallBack(GLFWwindow *window, int entered)
Definition: mouseSemantics.cpp:68
GLFWwindow * window
Definition: mouseSemantics.hpp:62
float C
Definition: mouseSemantics.hpp:54
float M
Definition: mouseSemantics.hpp:53
std::string scaleFunction()
Definition: mouseSemantics.hpp:85
glm::ivec2 getMousePos()
Definition: mouseSemantics.hpp:88
virtual ~MouseSemantics()
Definition: mouseSemantics.cpp:30
Encapsulates the Rendering Engine, holds a complete scene and it's assets.
Definition: scene.hpp:71
Scene * scene
Definition: sceneObject.hpp:68
float additionalScaling
Definition: mouseSemantics.hpp:56
int distance
Definition: mouseSemantics.hpp:52
void updateDistanceState(unsigned int _distance)
Definition: mouseSemantics.cpp:39
Encapsulates a texture in the GPU.
Definition: texture.hpp:10
unsigned int getDistance()
Definition: mouseSemantics.hpp:84
Encapsulates a shader program.
Definition: shader.hpp:9
void update(double deltaT)
Definition: mouseSemantics.cpp:100
GLuint vboPositions
Definition: mouseSemantics.hpp:63
void keyCallback(GLFWwindow *window, int key, int scancode, int action, int mods)
Definition: mouseSemantics.cpp:88
float getSpeed()
Definition: mouseSemantics.hpp:87
bool focused
Definition: mouseSemantics.hpp:60
The base class of the objects which are rendered.
Definition: sceneObject.hpp:30
void windowFocusCallBack(GLFWwindow *window, int entered)
Definition: mouseSemantics.cpp:79
Shader * shader
Definition: sceneObject.hpp:70
The class which handles the drawing of the cursor as well as the semantic scaling function that trans...
Definition: mouseSemantics.hpp:49
void draw()
Definition: mouseSemantics.cpp:166
void toggleScaleFunction()
Definition: mouseSemantics.cpp:35
float m
Definition: mouseSemantics.hpp:55