ComputerGraphik TU WIEN
Public Member Functions | Private Member Functions | Private Attributes | List of all members
MouseSemantics Class Reference

The class which handles the drawing of the cursor as well as the semantic scaling function that translates the movement from motor space to visual space. More...

#include <mouseSemantics.hpp>

Inheritance diagram for MouseSemantics:
SceneObject

Public Member Functions

 MouseSemantics (Scene *scene, float _M, float _C, float _m, Texture *texture)
 
virtual ~MouseSemantics ()
 
void setShader (Shader *shader)
 
void draw ()
 
void update (double deltaT)
 
void cursorEnterCallBack (GLFWwindow *window, int entered)
 
void windowFocusCallBack (GLFWwindow *window, int entered)
 
void keyCallback (GLFWwindow *window, int key, int scancode, int action, int mods)
 
void toggleScaleFunction ()
 
void updateDistanceState (unsigned int _distance)
 
unsigned int getDistance ()
 
std::string scaleFunction ()
 
float getScaleFactor ()
 
float getSpeed ()
 
glm::ivec2 getMousePos ()
 
- Public Member Functions inherited from SceneObject
 SceneObject (std::shared_ptr< SceneObject > &effectParent, const glm::mat4 &modelMatrix=glm::mat4(1))
 
 SceneObject (const std::string &name, Scene *scene=0, Model *model=0, const glm::mat4 &modelMatrix=glm::mat4(1))
 
virtual ~SceneObject ()
 
ModelgetModel () const
 
ShadergetShader () const
 
glm::mat4 getModelMatrix () const
 
glm::mat4 getGlobalModelMatrix () const
 
std::string getName () const
 
std::shared_ptr< SceneObjectgetParent () const
 
void setAnimationTime (double time)
 
bool setAnimation (const Animation &anim)
 
bool delChild (size_t idx)
 
bool getChild (size_t idx, std::shared_ptr< SceneObject > &child) const
 
bool addChild (std::shared_ptr< SceneObject > &child)
 
bool remEffect (const std::string &name)
 
SceneObjectgetEffect (const std::string &name) const
 
bool addEffect (const std::string &name, std::unique_ptr< SceneObject > &effect)
 
bool doNotRender ()
 
bool getIsVolSun ()
 
virtual void reset ()
 
virtual void draw () const
 
virtual bool animate (double time)
 

Private Member Functions

float calculateScaleFactor ()
 

Private Attributes

glm::vec2 latestPos
 
int distance
 
float M
 
float C
 
float m
 
float additionalScaling
 
bool scaleLinear
 
bool inWindow
 
bool firstTimeInWindow
 
bool focused
 
bool inverseScaleFunction
 
GLFWwindow * window
 
GLuint vboPositions
 
Texturetexture
 

Additional Inherited Members

- Public Types inherited from SceneObject
typedef std::vector< std::pair< double, glm::mat4 > > Animation
 
- Protected Attributes inherited from SceneObject
GLuint vao
 
Scenescene
 
Modelmodel
 
Shadershader
 
glm::mat4 modelMatrix
 
std::string name
 
std::weak_ptr< SceneObjectparent
 
std::vector< std::shared_ptr< SceneObject > > childs
 
std::map< std::string, std::unique_ptr< SceneObject > > effectChilds
 
size_t animIDX
 
Animation animation
 
bool norender
 
bool isVolSun
 

Detailed Description

The class which handles the drawing of the cursor as well as the semantic scaling function that translates the movement from motor space to visual space.

The purpose of the class MouseSemantics is to

  1. draw a mouse cursor and scale its appearance and
  2. scale the movement according to the distance of the nearest object.

The draw method uses point sprites to render the picture of a mouse pointer onto the screen. The size of the cursor is then directly coupled to the distance of the nearest pickable object. The bigger the distance, the bigger the mouse will be rendered.

In addition to rendering, this class also implements the 2 scale functions which are presented in the paper. Important parameters are:

Standard scale function: (M - m) * (C / D) + M

Inverse scale function: (m - M) / (D + 1)^S + M where D is the actual distance to the nearest object and S is an empirically derived constant (0.1 in our case).

Using F10 one can toggle between the inverse and the standard scale function. Using J and K one can slow down or speed up the overall mouse speed.

The scale functions are depicted as follows:

linearscale.png
linear scale function
inversescale.png
inverse scale function
Author
Felix Koenig

Constructor & Destructor Documentation

MouseSemantics::MouseSemantics ( Scene scene,
float  _M,
float  _C,
float  _m,
Texture texture 
)
MouseSemantics::~MouseSemantics ( )
virtual

Member Function Documentation

float MouseSemantics::calculateScaleFactor ( )
private
void MouseSemantics::cursorEnterCallBack ( GLFWwindow *  window,
int  entered 
)
void MouseSemantics::draw ( )
unsigned int MouseSemantics::getDistance ( )
inline
glm::ivec2 MouseSemantics::getMousePos ( )
inline
float MouseSemantics::getScaleFactor ( )
inline
float MouseSemantics::getSpeed ( )
inline
void MouseSemantics::keyCallback ( GLFWwindow *  window,
int  key,
int  scancode,
int  action,
int  mods 
)
std::string MouseSemantics::scaleFunction ( )
inline
void MouseSemantics::setShader ( Shader shader)
virtual

Reimplemented from SceneObject.

void MouseSemantics::toggleScaleFunction ( )
void MouseSemantics::update ( double  deltaT)
virtual

Reimplemented from SceneObject.

void MouseSemantics::updateDistanceState ( unsigned int  _distance)
void MouseSemantics::windowFocusCallBack ( GLFWwindow *  window,
int  entered 
)

Member Data Documentation

float MouseSemantics::additionalScaling
private
float MouseSemantics::C
private
int MouseSemantics::distance
private
bool MouseSemantics::firstTimeInWindow
private
bool MouseSemantics::focused
private
bool MouseSemantics::inverseScaleFunction
private
bool MouseSemantics::inWindow
private
glm::vec2 MouseSemantics::latestPos
private
float MouseSemantics::M
private
float MouseSemantics::m
private
bool MouseSemantics::scaleLinear
private
Texture* MouseSemantics::texture
private
GLuint MouseSemantics::vboPositions
private
GLFWwindow* MouseSemantics::window
private

The documentation for this class was generated from the following files: