|
Waterflow
Visualize water in terrain
|
Pretty general camera class. More...
#include <camera.h>
Public Member Functions | |
| Camera (glm::vec3 startPos, int *initScreenW, int *initScreenH, int tH, int tW, int xzL, int yLL, int yLH, DataHandler *terr) | |
| Constructor to create the camera. | |
| void | changeLookAtPos (int xrel, int yrel) |
| Changes the position the camera is looking at when the mouse is moved. | |
| void | forward (GLfloat d) |
| Moves the camera forward. | |
| glm::vec3 * | getPos () |
| Getter for the camera position. | |
| GLfloat | getRotSpeed () |
| Getter for the camera rotation speed. | |
| GLfloat * | getRotSpeedPtr () |
| Getter for the pointer to the camera rotation speed. | |
| GLfloat | getSpeed () |
| Getter for the camera movement speed. | |
| GLfloat * | getSpeedPtr () |
| Getter for the pointer to the camera movement speed. | |
| glm::mat4 * | getVTP () |
| Getter for the VTP matrix of the camera. | |
| glm::mat4 * | getWTV () |
| Getter for the WTV matrix of the camera. | |
| void | jump (GLfloat d) |
| Moves the camera up. | |
| void | rotate (char direction, GLfloat angle) |
| Rotates the camera. | |
| void | strafe (GLfloat d) |
| Moves the camera left or right. | |
| void | toggleFrozen () |
| Switches camera movement on/off. | |
| void | translate (GLfloat dx, GLfloat dy, GLfloat dz) |
| Translates the camera position. | |
| void | unlock () |
| Unlocks the camera from it's bounding box. | |
| void | updateVTP () |
| Updates the VTP matrix. | |
| void | updateWTV () |
| Updates the WTV matrix. | |
| void | uploadCamData (GLuint program) |
| Uploads the camera data to the specified shader. | |
Private Member Functions | |
| bool | isInCollisionBox (glm::vec3 transVec, bool xz) |
| Checks whether movement moves the camera outside of the permitted bounding box. | |
Private Attributes | |
| GLfloat | drawDistance |
| Draw distance. | |
| float | fi |
| Camera horizontal rotation angle. | |
| bool | isFrozen |
| Boolean to switch camera movement on/off. | |
| glm::vec3 | lookAtPos |
| The position the camera looks at. | |
| glm::vec3 | position |
| Camera position. | |
| float | rotSpeed |
| Camera rotation speed. | |
| int * | screenH |
| Pointer to screen height. | |
| int * | screenW |
| Pointer to screen width. | |
| GLfloat | speed |
| Camera movement speed. | |
| DataHandler * | terrain |
| Pointer to the terrain data. | |
| int | terrH |
| Terrain data height. | |
| int | terrW |
| Terrain data width. | |
| float | theta |
| Camera vertical rotation angle. | |
| bool | unlocked |
| Boolean to switch bounding box mode on/off. | |
| glm::vec3 | up |
| The up vector. | |
| glm::mat4 | VTPMatrix |
| View-to-projection matrix. | |
| glm::mat4 | WTVMatrix |
| World-to-view matrix. | |
| int | x |
| Used so mouse will not get stuck at window edges. | |
| int | xzLim |
| Distance to camera limiting borders around the terrain, world "walls". | |
| int | yLimHi |
| World "ceiling". | |
| int | yLimLo |
| World "floor". | |
| Camera::Camera | ( | glm::vec3 | startPos, |
| int * | initScreenW, | ||
| int * | initScreenH, | ||
| int | tH, | ||
| int | tW, | ||
| int | xzL, | ||
| int | yLL, | ||
| int | yLH, | ||
| DataHandler * | terr | ||
| ) |
Constructor to create the camera.
| startPos | Starting camera position. |
| initScreenW | Pointer to the initial screen width. |
| initScreenH | Pointer to the initial screen height. |
| tH | Terrain height. |
| tW | Terrain width. |
| xzL | Distance to the bounding box in the xz-plane outside the terrain model. |
| yLL | Floor of the camera bounding box. |
| yLH | Ceiling of the camera bounding box. |
| terr | Pointer to the terrain. |
Definition at line 16 of file camera.cpp.
| void Camera::changeLookAtPos | ( | int | xrel, |
| int | yrel | ||
| ) |
Changes the position the camera is looking at when the mouse is moved.
| xrel | Relative mouse motion along the x axis. |
| yrel | Relative mouse motion along the y axis. |
Definition at line 166 of file camera.cpp.
| void Camera::forward | ( | GLfloat | d | ) |
Moves the camera forward.
| d | Amount to move the camera forward. |
Definition at line 119 of file camera.cpp.
| glm::vec3 * Camera::getPos | ( | ) |
| GLfloat Camera::getRotSpeed | ( | ) |
Getter for the camera rotation speed.
Definition at line 202 of file camera.cpp.
| GLfloat * Camera::getRotSpeedPtr | ( | ) |
Getter for the pointer to the camera rotation speed.
Definition at line 205 of file camera.cpp.
| GLfloat Camera::getSpeed | ( | ) |
Getter for the camera movement speed.
Definition at line 196 of file camera.cpp.
| GLfloat * Camera::getSpeedPtr | ( | ) |
Getter for the pointer to the camera movement speed.
Definition at line 199 of file camera.cpp.
| glm::mat4 * Camera::getVTP | ( | ) |
Getter for the VTP matrix of the camera.
Definition at line 190 of file camera.cpp.
| glm::mat4 * Camera::getWTV | ( | ) |
Getter for the WTV matrix of the camera.
Definition at line 187 of file camera.cpp.
| bool Camera::isInCollisionBox | ( | glm::vec3 | transVec, |
| bool | xz | ||
| ) | [private] |
Checks whether movement moves the camera outside of the permitted bounding box.
The bounding box is decided by terrW, terrH, xzLim, yLimLo and yLimHi.
| transVec | Vector corresponding to the translation attempted. |
| xz | Boolean that decides if a check for xz or y should be made. |
Definition at line 47 of file camera.cpp.
| void Camera::jump | ( | GLfloat | d | ) |
Moves the camera up.
Note that up here means according to the camera view direction, not necessarily in world coordinates.
| d | Amount to move the camera up. |
Definition at line 135 of file camera.cpp.
| void Camera::rotate | ( | char | direction, |
| GLfloat | angle | ||
| ) |
Rotates the camera.
| direction | Axis to rotate around. |
| angle | Angle to rotate. |
Definition at line 73 of file camera.cpp.
| void Camera::strafe | ( | GLfloat | d | ) |
Moves the camera left or right.
| d | Amount to move the camera to the left (negative moves it to the right). |
Definition at line 126 of file camera.cpp.
| void Camera::translate | ( | GLfloat | dx, |
| GLfloat | dy, | ||
| GLfloat | dz | ||
| ) |
Translates the camera position.
| dx | Amount to move the camera along the x axis. |
| dy | Amount to move the camera along the y axis. |
| dz | Amount to move the camera along the z axis. |
Definition at line 90 of file camera.cpp.
| void Camera::uploadCamData | ( | GLuint | program | ) |
Uploads the camera data to the specified shader.
| program | Shader program to upload the camera information to. |
Definition at line 154 of file camera.cpp.