MinGfx Toolkit  1.0
A minimal library for writing cross-platform (Windows, OSX, linux) graphics programs.
craft_cam.h
Go to the documentation of this file.
1 /*
2  This file is part of the MinGfx Project.
3 
4  Copyright (c) 2017,2018 Regents of the University of Minnesota.
5  All Rights Reserved.
6 
7  Original Author(s) of this File:
8  Dan Keefe, 2018, University of Minnesota
9 
10  Author(s) of Significant Updates/Modifications to the File:
11  ...
12  */
13 
14 #ifndef SRC_CRAFT_CAM_H_
15 #define SRC_CRAFT_CAM_H_
16 
17 #include "point2.h"
18 #include "matrix4.h"
19 #include "vector2.h"
20 
21 
22 namespace mingfx {
23 
24 
79 class CraftCam {
80 public:
81 
84 
86  CraftCam(const Matrix4 &initial_view_matrix);
87 
88  virtual ~CraftCam();
89 
90 
91  // To make the interaction work, the following set of functions need to be
92  // called from your GraphicsApp or whatever main application class you use
93  // to receive user input events and a draw callback.
94 
104  void UpdateSimulation(double dt, GLFWwindow *window_ptr);
105 
106 
125  void OnMouseMove(const Vector2 &normalized_mouse_delta);
126 
127 
138 
139 
143 
147 
148 
153  void UpdateHeight(float new_y_value);
154 
155 
156  // -------------
157 
161 
162 
168 
173  void set_translation_scale(float s);
174 
179  float rotation_scale();
180 
185  void set_rotation_scale(float s);
186 
190  float look_scale();
191 
195  void set_look_scale(float s);
196 
197 private:
198 
199  void WalkForward(double dt);
200  void WalkBackward(double dt);
201  void RotateLeft(double dt);
202  void RotateRight(double dt);
203  void LookWithMouse(const Vector2 &mouse_delta);
204 
205  float t_scale_;
206  float r_scale_;
207  float l_scale_;
208  float yaw_;
209  float pitch_;
210  Matrix4 base_head_;
211  Matrix4 added_rot_;
212 };
213 
214 
215 } // end namespace
216 
217 #endif
218 
219 
This implements a user interface for controlling the camera with the mouse.
Definition: craft_cam.h:79
void set_look_scale(float s)
This is the scale factor used to speed up / slow down looking around when moving the head with the mo...
void set_translation_scale(float s)
This is the scale factor used to speed up / slow down forward/backward translation when walking for t...
void UpdateSimulation(double dt, GLFWwindow *window_ptr)
Call this from your app's UpdateSimulation() method. This tells the camera to simulate walking based ...
Vector3 look()
Returns the look direction (i.e., -Z axis of the camera matrix) in world space coordinates.
void set_rotation_scale(float s)
This is the scale factor used to speed up / slow down left/right rotation when walking for the LEFT /...
void set_view_matrix(Matrix4 view_matrix)
This is not required, but you may use this if you wish to set an initial view matrix or reset the vie...
Point3 eye()
Returns the "eye" point (i.e., focal point) of the camera in world space coordinates.
void OnMouseMove(const Vector2 &normalized_mouse_delta)
Call this from your app's OnMouseMove() or On*MouseDrag() method. Use OnMouseMove() if you want to al...
virtual ~CraftCam()
float translation_scale()
This is the scale factor used to speed up / slow down forward/backward translation when walking for t...
float look_scale()
This is the scale factor used to speed up / slow down looking around when moving the head with the mo...
float rotation_scale()
This is the scale factor used to speed up / slow down left/right rotation when walking for the LEFT /...
CraftCam(const Matrix4 &initial_view_matrix)
Creates a CraftCam object with the supplied initial view matrix.
Matrix4 view_matrix()
Access the camera view matrix created by the CraftCam interactions via this method and use it to draw...
CraftCam()
Creates a CraftCam object with an initial view matrix = identity.
void UpdateHeight(float new_y_value)
Sets the y value of the camera (i.e., the height). If you want to set the entire view matrix,...
A 4x4 transformation matrix stored internally as an array of floats in column-major order so as to be...
Definition: matrix4.h:50
A 3D Point with floating point coordinates, used for storing vertices and all sorts of other 3D graph...
Definition: point3.h:52
A 2D Vector with floating point coordinates, used for storing 2D translations, mouse movements,...
Definition: vector2.h:28
A 3D Vector with floating point coordinates, used for storing normals and all sorts of other 3D graph...
Definition: vector3.h:62
Namespace for the MinGfx Toolkit.
Definition: aabb.h:21