#include <camera.h>
Public Types | |
enum | CameraMovement { ELEVATE, FORWARD, STRAFE, ZOOM, YAW, PITCH, ROLL } |
Public Member Functions | |
Camera () | |
The constructor of the camera class. | |
~Camera () | |
The destructor of the camera class. | |
void | SetState (GLfloat x, GLfloat y, GLfloat z, GLfloat yaw, GLfloat pitch, GLfloat roll, GLfloat fovY, GLfloat fovRatio, GLfloat zNear, GLfloat zFar, GLfloat zoomFactor) |
Sets the state of the camera. | |
void | SetRange (GLfloat zNear, GLfloat zFar) |
Sets the viewing range of the camera. | |
void | Move (CameraMovement m, GLfloat step) |
Moves the camera. | |
void | Draw () |
Draws the camera frustum. | |
void | Look () |
Adjusts the viewing transformation according to the camera. | |
void | Perspective (GLint width, GLint height) |
Adjusts the viewing frustum according to the camera. | |
void | FrustumView (bool frustumView) |
Sets the member m_frustumView and calls Perspective(). | |
void | GetCameraVariables (GLfloat *pos, GLfloat *dir, GLfloat *up, GLfloat &zoomFactor, GLfloat &fovY, GLfloat &fovRatio, GLfloat &zNear, GLfloat &zFar) |
Update camera variables. | |
Private Member Functions | |
GLfloat | m_DegreesToRadians (GLfloat degrees) |
Converts an angle from degrees to radians. | |
void | m_Elevate (GLfloat step) |
Moves the camera up/down. | |
void | m_Forward (GLfloat step) |
Moves the camera forward/backwards. | |
void | m_Strafe (GLfloat step) |
Moves the camera right/left. | |
void | m_Zoom (GLfloat zoomFactor) |
Zooms the camera. | |
void | m_Yaw (GLfloat angle) |
Rotates the camera around the up vector. | |
void | m_Pitch (GLfloat angle) |
Rotates the camera around the right vector. | |
void | m_Roll (GLfloat angle) |
Rotates the camera around the view vector. | |
Private Attributes | |
Vec3f | m_pos |
Vec3f | m_up |
Vec3f | m_viewDir |
Vec3f | m_viewPt |
Vec3f | m_right |
GLfloat | m_yaw |
GLfloat | m_pitch |
GLfloat | m_roll |
GLfloat | m_fovY |
GLfloat | m_fovX |
GLfloat | m_fovRatio |
GLfloat | m_zNear |
GLfloat | m_zFar |
GLfloat | m_zoomFactor |
bool | m_frustumView |
int | m_windowWidth |
int | m_windowHeight |
Functionality includes elevating, moving, strafing, zooming, panning, yawing, pitching, rolling. The camera frustum can be rendered.
Camera::Camera | ( | ) |
The constructor of the camera class.
Initializes all variables.
Camera::~Camera | ( | ) |
The destructor of the camera class.
void Camera::SetState | ( | GLfloat | x, | |
GLfloat | y, | |||
GLfloat | z, | |||
GLfloat | yaw, | |||
GLfloat | pitch, | |||
GLfloat | roll, | |||
GLfloat | fovY, | |||
GLfloat | fovRatio, | |||
GLfloat | zNear, | |||
GLfloat | zFar, | |||
GLfloat | zoomFactor | |||
) |
Sets the state of the camera.
Sets the position, yaw, pitch, roll, FOV in the Y-direction, FOV-ratio, as well as the distance to the near clip plane and the far clip plane.
x | the x position of the camera. | |
y | the y position of the camera. | |
z | the z position of the camera. | |
yaw | the amount of yaw in degrees. | |
pitch | the amount of pitch in degrees. | |
roll | the amount of roll in degrees. | |
fovY | the angle of the FOV in degrees. | |
fovRatio | the ratio of the FOV (fovX/fovY). | |
zNear | the distance from the camera to the near clip plane. | |
zFar | the distance from the camera to the far clip plane. | |
zoomFactor | Zoomfactor, 1.0 means no zoom. |
void Camera::SetRange | ( | GLfloat | zNear, | |
GLfloat | zFar | |||
) |
Sets the viewing range of the camera.
Sets the near and far clip plane.
zNear | the distance from the camera to the near clip plane. | |
zFar | the distance from the camera to the far clip plane. |
void Camera::Move | ( | CameraMovement | m, | |
GLfloat | step | |||
) |
Moves the camera.
Moves the camera according to the a specific action and a specific step.
m | the type of movement. | |
amount | the step. |
void Camera::Draw | ( | ) |
Draws the camera frustum.
Draws a wireframe model of the cameras frustum.
void Camera::Look | ( | ) |
Adjusts the viewing transformation according to the camera.
Sets the modelview matrix according to the camera position the view point and the up vector. If member m_frustumView is TRUE, the modelview matrix will be set up to show the camera and it's frustum.
void Camera::Perspective | ( | GLint | width, | |
GLint | height | |||
) |
Adjusts the viewing frustum according to the camera.
Sets the projection matrix according to the FOV Y angle, the zoom factor, the FOV ratio and the near and far clip planes.
width | the width of the view port. | |
height | the height of the view port. |
void Camera::FrustumView | ( | bool | frustumView | ) |
Sets the member m_frustumView and calls Perspective().
This function is called every time that the global variable frustumView changes its state. FrustumView updates the member m_frustumView and calls Perspective() in order to draw/hide the cameras frustum.
frustumView | Boolean which is TRUE if the frustum shall be drawn. |
void Camera::GetCameraVariables | ( | GLfloat * | pos, | |
GLfloat * | dir, | |||
GLfloat * | up, | |||
GLfloat & | zoomFactor, | |||
GLfloat & | fovY, | |||
GLfloat & | fovRatio, | |||
GLfloat & | zNear, | |||
GLfloat & | zFar | |||
) |
Update camera variables.
Update camera variables for use in the testshell.
pos | storage for camera position. | |
dir | storage for view direction. | |
up | storage for up vector. |
GLfloat Camera::m_DegreesToRadians | ( | GLfloat | degrees | ) | [private] |
Converts an angle from degrees to radians.
Converts an angle from degrees to radians.
degrees | the angle in degrees. |
void Camera::m_Elevate | ( | GLfloat | step | ) | [private] |
Moves the camera up/down.
Moves the camera up or down in the "up" direction.
step | the elevation step. |
void Camera::m_Forward | ( | GLfloat | step | ) | [private] |
Moves the camera forward/backwards.
Moves the camera forwards or backwards in the viewing direction.
step | the forward/backwards step. |
void Camera::m_Strafe | ( | GLfloat | step | ) | [private] |
Moves the camera right/left.
Moves the camera in the right/left direction.
step | the strafe step. |
void Camera::m_Zoom | ( | GLfloat | zoomFactor | ) | [private] |
Zooms the camera.
Adjusts the zoom factor which is used in the cameras perspective function.
zoomFactor | the change of zoom factor. |
void Camera::m_Yaw | ( | GLfloat | angle | ) | [private] |
Rotates the camera around the up vector.
Rotates the camera around the up vector (yaw).
angle | the change of yaw angle (degrees). |
void Camera::m_Pitch | ( | GLfloat | angle | ) | [private] |
Rotates the camera around the right vector.
Rotates the camera around the right vector (pitch).
angle | the change of pitch angle (degrees). |
void Camera::m_Roll | ( | GLfloat | angle | ) | [private] |
Rotates the camera around the view vector.
Rotates the camera around the view vector (roll).
angle | the change of roll angle (degrees). |
Vec3f Camera::m_pos [private] |
The position of the camera
Vec3f Camera::m_up [private] |
The up direction
Vec3f Camera::m_viewDir [private] |
The view direction
Vec3f Camera::m_viewPt [private] |
The viewpoint
Vec3f Camera::m_right [private] |
The right direction
GLfloat Camera::m_yaw [private] |
The yaw angle
GLfloat Camera::m_pitch [private] |
The pitch angle
GLfloat Camera::m_roll [private] |
The roll angle
GLfloat Camera::m_fovY [private] |
The field-of-view angle in the y direction
GLfloat Camera::m_fovX [private] |
The field-of-view angle in the x direction
GLfloat Camera::m_fovRatio [private] |
The aspect ratio of the field of view (x/y)
GLfloat Camera::m_zNear [private] |
The distance from the camera to the near clipping plane
GLfloat Camera::m_zFar [private] |
The distance from the camera to the far clipping plane
GLfloat Camera::m_zoomFactor [private] |
The amount of zooming
bool Camera::m_frustumView [private] |
Whether the camera shall view its frustum.
int Camera::m_windowWidth [private] |
Glut window width
int Camera::m_windowHeight [private] |
Glut window height