Menge
Modular Pedestrian Simulation Framework for Research and Development
|
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... | |
The class for controlling the view camera: it's position, orientation field of view, projection matrix, etc.
Menge::SceneGraph::GLCamera::GLCamera | ( | const Vector3 & | p | ) |
Constructor for setting camera position.
p | The position of the camera. |
Constructor for setting camera position and target.
p | The position of the camera. |
t | The position of the camera's view target. |
Constructor for setting camera position, target, and up vector.
p | The position of the camera. |
t | The position of the camera's view target. |
u | the direction of the camera's up direction. |
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.
amount | The 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.
amount | The 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.
amount | The 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.
|
inline |
Reports the camera's current far plane distance.
|
inline |
Reports 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.
|
inline |
Return the position of the camera.
Vector3 Menge::SceneGraph::GLCamera::getRightDir | ( | ) | const |
Returns the normalized vector representing the camera's horizontal axis pointing to right.
|
inline |
Return the position of the camera's view target.
|
inline |
Return 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.
angle | The 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.
angle | The 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).
angle | The amount of pan (in radians). Positive values cause the camera to turn left, negative values turn the camera right. |
|
inline |
Sets the far plane distance.
fp | The desired far plane distance. |
|
inline |
Sets the field of view of the camera – only applicable when using the perspective projection.
fov | The horizontal field of view (in degrees). |
|
inline |
Sets the near plane distance.
np | The desired near plane distance. |
void Menge::SceneGraph::GLCamera::setOrtho | ( | float | scaleFactor = 1.f | ) |
Sets the camera to use an orthographic projection.
scaleFactor | Defines 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.
p | The desired position of the camera. |
void Menge::SceneGraph::GLCamera::setPosition | ( | float | x, |
float | y, | ||
float | z | ||
) |
Set the camera position explicitly from three values.
x | The position of the camera along the x-axis. |
y | The position of the camera along the y-axis. |
z | The 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.
w | The viewport width (in pixels). |
h | The viewport height (in pixels). |
void Menge::SceneGraph::GLCamera::setSelectMat | ( | int * | selectPoint | ) | const |
Emits the appropriate OpenGL commands for setting up a selection context.
selectPoint | A 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.
p | The 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.
x | The position of the camera's view target along the x-axis. |
y | The position of the camera's view target along the y-axis. |
z | The 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.
u | The 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.
x | The x-component of the camera's up vector. |
y | The y-component of the camera's up vector. |
z | The 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.
w | The width of the viewport (in pixels) |
h | The height of the viewport (in pixels ) |
left | The position of the left-most edge of the viewport in pixels. Defaults to zero. |
bottom | The 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.
float Menge::SceneGraph::GLCamera::targetDistance | ( | ) | const |
Camera state.
Returns distance between camera and 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).
angle | The 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).
amount | The 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.
downPositive | If 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.
downPositive | If 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.
downPositive | If 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.
amount | The amount to zoom. Positive values move forward and negative values move backward. |