Menge
Modular Pedestrian Simulation Framework for Research and Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | List of all members
Menge::SceneGraph::GLCamera Class Reference

The class for controlling the view camera: it's position, orientation field of view, projection matrix, etc. More...

#include <GLCamera.h>

Public Types

enum  CamEnum { ORTHO, PERSP }
 Determines the projection matrix of the 3D camera.
 

Public Member Functions

 GLCamera ()
 Default constructor.
 
 GLCamera (const Vector3 &p)
 Constructor for setting camera position. More...
 
 GLCamera (const Vector3 &p, const Vector3 &t)
 Constructor for setting camera position and target. More...
 
 GLCamera (const Vector3 &p, const Vector3 &t, const Vector3 &u)
 Constructor for setting camera position, target, and up vector. More...
 
void setOrtho (float scaleFactor=1.f)
 Sets the camera to use an orthographic projection. More...
 
void setPersp ()
 Sets the camera to use a perspective projection.
 
void setActive ()
 Called the first time a camera is put into use. Failing to call this may lead to unexpected camera settings until the camera is manipulated.
 
Vector3 getPosition () const
 Return the position of the camera. More...
 
void setPosition (const Vector3 &p)
 Set the camera position explicitly from a Vector3. More...
 
void setPosition (float x, float y, float z)
 Set the camera position explicitly from three values. More...
 
Vector3 getTarget () const
 Return the position of the camera's view target. More...
 
void setTarget (const Vector3 &p)
 Set the position of the camera's view target explicitly from a Vector3. More...
 
void setTarget (float x, float y, float z)
 Set the position of the camera's view target explicitly from three values. More...
 
Vector3 getUp () const
 Return the orientation of the camera's up direction. More...
 
void setUp (const Vector3 &u)
 Set the orientation of the camera's up vector from a Vector3. More...
 
void setUp (float x, float y, float z)
 Set the orientation of the camera's up vector from three values. More...
 
void setFOV (float fov)
 Sets the field of view of the camera – only applicable when using the perspective projection. More...
 
float getFOV () const
 Returns the current horizontal field of view (in degrees).
 
void setFarPlane (float fp)
 Sets the far plane distance. More...
 
float getFarPlane () const
 Reports the camera's current far plane distance. More...
 
void setNearPlane (float np)
 Sets the near plane distance. More...
 
float getNearPlane () const
 Reports the camera's current near plane distance. More...
 
float getOrthoScaleFactor () const
 Reports the orthographic scale factor for this camera. More...
 
void setViewport (int w, int h, int left=0, int bottom=0)
 Sets the camera's viewport to a view with the given width and height dimensions. More...
 
void setProjMat (int w, int h) const
 Create OpenGL commands. More...
 
void setSelectMat (int *selectPoint) const
 Emits the appropriate OpenGL commands for setting up a selection context. More...
 
void setGLView () const
 Emits the appropriate OpenGL commands for setting up the view for this camera.
 
void viewXAxis (bool downPositive=true)
 Sets the camera to look along the world's x-axis. More...
 
void viewYAxis (bool downPositive=true)
 Sets the camera to look along the world's y-axis. More...
 
void viewZAxis (bool downPositive=true)
 Sets the camera to look along the world's z-axis. More...
 
void pan (float angle)
 Causes the camera to "pan" the given angle. More...
 
void tilt (float angle)
 Causes the camera to "tilt" the given angle. More...
 
void truck (float amount)
 Causes the camera to "truck" the given amount. More...
 
void crane (float amount)
 Causes the camera to "crane" the given amount. More...
 
void dolly (float amount)
 Causes the camera to "dolly" in and out. More...
 
void dollyPlane (float amount)
 Causes the camera to "dolly" along a plane. More...
 
void zoom (float amount)
 Causes the camera to "zoom" toward its target. More...
 
void orbitVerticalAxis (float angle)
 Causes the camera to rotate an axis, parallel with the world vertical axis centered on the camera's target. More...
 
void orbitHorizontalAxis (float angle)
 Camera rotates, at distance, around target on axis parallel to camera's horizontal axis. More...
 
float targetDistance () const
 Camera state. More...
 
Vector3 targetDir () const
 Returns the unit-length vector indicating direction FROM camera to TARGET. More...
 
Vector3 getActualUpDir () const
 Returns the ACTUAL up dir – as opposed to the desired up. More...
 
Vector3 getRightDir () const
 Returns the normalized vector representing the camera's horizontal axis pointing to right. More...
 
void outputState () const
 Outputs the state of the camera to the console. More...
 

Detailed Description

The class for controlling the view camera: it's position, orientation field of view, projection matrix, etc.

Constructor & Destructor Documentation

Menge::SceneGraph::GLCamera::GLCamera ( const Vector3 p)

Constructor for setting camera position.

Parameters
pThe position of the camera.
Menge::SceneGraph::GLCamera::GLCamera ( const Vector3 p,
const Vector3 t 
)

Constructor for setting camera position and target.

Parameters
pThe position of the camera.
tThe position of the camera's view target.
Menge::SceneGraph::GLCamera::GLCamera ( const Vector3 p,
const Vector3 t,
const Vector3 u 
)

Constructor for setting camera position, target, and up vector.

Parameters
pThe position of the camera.
tThe position of the camera's view target.
uthe direction of the camera's up direction.

Member Function Documentation

void Menge::SceneGraph::GLCamera::crane ( float  amount)

Causes the camera to "crane" the given amount.

A camera "cranes" by moving along its own vertical axis. This causes the camera to rise and lower in its view. The actual movement in the WORLD coordinate system depends on the camera's orientation.

Parameters
amountThe amount to move. Postive values move the camera up and negative values move down.
void Menge::SceneGraph::GLCamera::dolly ( float  amount)

Causes the camera to "dolly" in and out.

Dollying a camera moves it forward and backward in the camera's facing direction (i.e., moving in the direction of the target). The target moves with the camera.

Parameters
amountThe amount to move. Positive values move forward and negative values move backward.
void Menge::SceneGraph::GLCamera::dollyPlane ( float  amount)

Causes the camera to "dolly" along a plane.

In this case, the elevation (in world space) does not change. The camera moves parallel with the ground plane based on the projeciton of the camera's facing direction on that plane.

Parameters
amountThe amount to move. Positive values move forward and negative values move backward.
Vector3 Menge::SceneGraph::GLCamera::getActualUpDir ( ) const

Returns the ACTUAL up dir – as opposed to the desired up.

Essentially, the cross product of the camera's horizontal direction with its facing direction.

Returns
Camera's current, local up vector in world space.
float Menge::SceneGraph::GLCamera::getFarPlane ( ) const
inline

Reports the camera's current far plane distance.

Returns
The camera's current far plane distance.
float Menge::SceneGraph::GLCamera::getNearPlane ( ) const
inline

Reports the camera's current near plane distance.

Returns
The camera's current near plane distance.
float Menge::SceneGraph::GLCamera::getOrthoScaleFactor ( ) const

Reports the orthographic scale factor for this camera.

The orthographic scale factor is the value which determines how "zoomed in" an orthographic camera is. It is the ratio of the distance between camera and target and the width of the viewable region in orthographic.

Returns
The orthographic scale
Vector3 Menge::SceneGraph::GLCamera::getPosition ( ) const
inline

Return the position of the camera.

Returns
The position fo the camera in 3D space.
Vector3 Menge::SceneGraph::GLCamera::getRightDir ( ) const

Returns the normalized vector representing the camera's horizontal axis pointing to right.

Returns
The direction of the camera's right in world space.
Vector3 Menge::SceneGraph::GLCamera::getTarget ( ) const
inline

Return the position of the camera's view target.

Returns
The position of the camera's view target.
Vector3 Menge::SceneGraph::GLCamera::getUp ( ) const
inline

Return the orientation of the camera's up direction.

Returns
The orientation of the camera's up direction.
void Menge::SceneGraph::GLCamera::orbitHorizontalAxis ( float  angle)

Camera rotates, at distance, around target on axis parallel to camera's horizontal axis.

Parameters
angleThe angle of rotation (in radians). Positive values move the camera in its upward direction, negative to its downward.
void Menge::SceneGraph::GLCamera::orbitVerticalAxis ( float  angle)

Causes the camera to rotate an axis, parallel with the world vertical axis centered on the camera's target.

Parameters
angleThe angle of rotation (in radians). Positive values move the camera to its right, negative to its left.
void Menge::SceneGraph::GLCamera::outputState ( ) const

Outputs the state of the camera to the console.

The format can be cut-and-pasted into a view configuration file.

void Menge::SceneGraph::GLCamera::pan ( float  angle)

Causes the camera to "pan" the given angle.

The camera "pans" by rotating around its own center along the world's vertical axis (i.e., turning left and right).

Parameters
angleThe amount of pan (in radians). Positive values cause the camera to turn left, negative values turn the camera right.
void Menge::SceneGraph::GLCamera::setFarPlane ( float  fp)
inline

Sets the far plane distance.

Parameters
fpThe desired far plane distance.
void Menge::SceneGraph::GLCamera::setFOV ( float  fov)
inline

Sets the field of view of the camera – only applicable when using the perspective projection.

Parameters
fovThe horizontal field of view (in degrees).
void Menge::SceneGraph::GLCamera::setNearPlane ( float  np)
inline

Sets the near plane distance.

Parameters
npThe desired near plane distance.
void Menge::SceneGraph::GLCamera::setOrtho ( float  scaleFactor = 1.f)

Sets the camera to use an orthographic projection.

Parameters
scaleFactorDefines the horizontal span of the orthographic view as a function of the distance to target. This "zooms" the orthographic camera closer.
void Menge::SceneGraph::GLCamera::setPosition ( const Vector3 p)

Set the camera position explicitly from a Vector3.

Parameters
pThe desired position of the camera.
void Menge::SceneGraph::GLCamera::setPosition ( float  x,
float  y,
float  z 
)

Set the camera position explicitly from three values.

Parameters
xThe position of the camera along the x-axis.
yThe position of the camera along the y-axis.
zThe position of the camera along the z-axis.
void Menge::SceneGraph::GLCamera::setProjMat ( int  w,
int  h 
) const

Create OpenGL commands.

Emits the appropriate OpenGL commands for setting up a projection matrix.

Parameters
wThe viewport width (in pixels).
hThe viewport height (in pixels).
void Menge::SceneGraph::GLCamera::setSelectMat ( int *  selectPoint) const

Emits the appropriate OpenGL commands for setting up a selection context.

Parameters
selectPointA pointer to an array of two floats interpreted as the x- and y-positions of the selection point, in screen space.
void Menge::SceneGraph::GLCamera::setTarget ( const Vector3 p)

Set the position of the camera's view target explicitly from a Vector3.

Parameters
pThe desired position of the camera's view target.
void Menge::SceneGraph::GLCamera::setTarget ( float  x,
float  y,
float  z 
)

Set the position of the camera's view target explicitly from three values.

Parameters
xThe position of the camera's view target along the x-axis.
yThe position of the camera's view target along the y-axis.
zThe position of the camera's view target along the z-axis.
void Menge::SceneGraph::GLCamera::setUp ( const Vector3 u)

Set the orientation of the camera's up vector from a Vector3.

Parameters
uThe desired direction of the camera's up direction. It is assumed to be of normal length.
void Menge::SceneGraph::GLCamera::setUp ( float  x,
float  y,
float  z 
)

Set the orientation of the camera's up vector from three values.

Parameters
xThe x-component of the camera's up vector.
yThe y-component of the camera's up vector.
zThe z-component of the camera's up vector.
void Menge::SceneGraph::GLCamera::setViewport ( int  w,
int  h,
int  left = 0,
int  bottom = 0 
)

Sets the camera's viewport to a view with the given width and height dimensions.

Parameters
wThe width of the viewport (in pixels)
hThe height of the viewport (in pixels )
leftThe position of the left-most edge of the viewport in pixels. Defaults to zero.
bottomThe position of the bottom-most edge of the viewport in pixels. Defaults to zero.
Vector3 Menge::SceneGraph::GLCamera::targetDir ( ) const

Returns the unit-length vector indicating direction FROM camera to TARGET.

Returns
Direction to target in world space.
float Menge::SceneGraph::GLCamera::targetDistance ( ) const

Camera state.

Returns distance between camera and target

Returns
The distance between camera and its target.
void Menge::SceneGraph::GLCamera::tilt ( float  angle)

Causes the camera to "tilt" the given angle.

The camera "tilts" by rotating around its own center along the its own horizontal axis (i.e., looking up and down).

Parameters
angleThe amount of pan (in radians). Postive values rotates the camera down, negative rotates up.
void Menge::SceneGraph::GLCamera::truck ( float  amount)

Causes the camera to "truck" the given amount.

"Trucking" is moving the camera side to side on its own horizontal axis (i.e., "strafe" left and right).

Parameters
amountThe amount to move. Postive values move the camera to its right and negative values move left.
void Menge::SceneGraph::GLCamera::viewXAxis ( bool  downPositive = true)

Sets the camera to look along the world's x-axis.

The camera's distance from the origin is the same as its previous displacement from the origin along the x-axis.

Parameters
downPositiveIf true, the camera looks along the positive x-axis direction. If false, it looks in the negative direction.
void Menge::SceneGraph::GLCamera::viewYAxis ( bool  downPositive = true)

Sets the camera to look along the world's y-axis.

The camera's distance from the origin is the same as its previous displacement from the origin along the y-axis.

Parameters
downPositiveIf true, the camera looks along the positive y-axis direction. If false, it looks in the negative direction.
void Menge::SceneGraph::GLCamera::viewZAxis ( bool  downPositive = true)

Sets the camera to look along the world's z-axis.

The camera's distance from the origin is the same as its previous displacement from the origin along the z-axis.

Parameters
downPositiveIf true, the camera looks along the positive z-axis direction. If false, it looks in the negative direction.
void Menge::SceneGraph::GLCamera::zoom ( float  amount)

Causes the camera to "zoom" toward its target.

This is not a zoom in the sense that the lens focal length changes. This merely moves the camera along its facing direction while holding the target stationary.

Parameters
amountThe amount to zoom. Positive values move forward and negative values move backward.

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