Waterflow
Visualize water in terrain
Camera Class Reference

Pretty general camera class. More...

#include <camera.h>

List of all members.

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.
DataHandlerterrain
 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".

Detailed Description

Pretty general camera class.

Definition at line 31 of file camera.h.


Constructor & Destructor Documentation

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.

Parameters:
startPosStarting camera position.
initScreenWPointer to the initial screen width.
initScreenHPointer to the initial screen height.
tHTerrain height.
tWTerrain width.
xzLDistance to the bounding box in the xz-plane outside the terrain model.
yLLFloor of the camera bounding box.
yLHCeiling of the camera bounding box.
terrPointer to the terrain.

Definition at line 16 of file camera.cpp.


Member Function Documentation

void Camera::changeLookAtPos ( int  xrel,
int  yrel 
)

Changes the position the camera is looking at when the mouse is moved.

Parameters:
xrelRelative mouse motion along the x axis.
yrelRelative mouse motion along the y axis.

Definition at line 166 of file camera.cpp.

void Camera::forward ( GLfloat  d)

Moves the camera forward.

Parameters:
dAmount to move the camera forward.

Definition at line 119 of file camera.cpp.

glm::vec3 * Camera::getPos ( )

Getter for the camera position.

Returns:
camera position.

Definition at line 193 of file camera.cpp.

GLfloat Camera::getRotSpeed ( )

Getter for the camera rotation speed.

Returns:
camera rotation speed.

Definition at line 202 of file camera.cpp.

GLfloat * Camera::getRotSpeedPtr ( )

Getter for the pointer to the camera rotation speed.

Returns:
pointer to the camera rotation speed.

Definition at line 205 of file camera.cpp.

GLfloat Camera::getSpeed ( )

Getter for the camera movement speed.

Returns:
camera movement speed.

Definition at line 196 of file camera.cpp.

GLfloat * Camera::getSpeedPtr ( )

Getter for the pointer to the camera movement speed.

Returns:
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.

Returns:
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.

Returns:
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.

Parameters:
transVecVector corresponding to the translation attempted.
xzBoolean that decides if a check for xz or y should be made.
Returns:
false if tested movement would move the camera outside of it's bounding box, otherwise true.

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.

Parameters:
dAmount to move the camera up.

Definition at line 135 of file camera.cpp.

void Camera::rotate ( char  direction,
GLfloat  angle 
)

Rotates the camera.

Parameters:
directionAxis to rotate around.
angleAngle to rotate.

Definition at line 73 of file camera.cpp.

void Camera::strafe ( GLfloat  d)

Moves the camera left or right.

Parameters:
dAmount 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.

Parameters:
dxAmount to move the camera along the x axis.
dyAmount to move the camera along the y axis.
dzAmount 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.

Parameters:
programShader program to upload the camera information to.

Definition at line 154 of file camera.cpp.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Enumerations