3Depict
|
A perspective camera that looks at a specific location. More...
#include <cameras.h>
Public Member Functions | |
CameraLookAt () | |
Constructor. More... | |
Camera * | clone () const |
clone function More... | |
virtual | ~CameraLookAt () |
Destructor. More... | |
void | setOrigin (const Point3D &) |
Set the look at target. More... | |
void | setTarget (const Point3D &) |
Set the look at target. More... | |
Point3D | getTarget () const |
Get the look at target. More... | |
float | getFOV () const |
Get the camera's FOV angle (full angle across) More... | |
float | getNearPlane () const |
void | apply (float outAspect, const BoundCube &boundCube, bool loadIdentity=true) const |
Applies the view transform. More... | |
void | lookAt () const |
Only apply the look-at opengl transform. More... | |
void | forwardsDolly (float dollyAmount) |
Do a forwards "dolly",where the camera moves along its viewing axis. More... | |
void | move (float leftRightAmount, float UpDownAmount) |
Move the camera origin. More... | |
void | pivot (float lrRad, float udRad) |
Simulate pivot of camera. More... | |
void | translate (float lrTrans, float udTrans) |
Move the camera origin. More... | |
void | roll (float rollRad) |
Roll around the view direction. More... | |
void | recomputeUpDirection () |
Ensure that up direction is perpendicular to view direction. More... | |
void | repositionAroundTarget (unsigned int direction) |
virtual void | ensureVisible (const BoundCube &b, unsigned int face=3) |
Ensure that the box is visible. More... | |
void | getProperties (CameraProperties &p) const |
Return the user-settable properties of the camera. More... | |
bool | setProperty (unsigned int key, const std::string &value) |
Set the camera property from a key & string pair. More... | |
bool | writeState (std::ostream &f, unsigned int format, unsigned int tabs=0) const |
Write the state of the camera. More... | |
bool | readState (xmlNodePtr nodePtr) |
Read the state of the camera. More... | |
float | getViewWidth (float depth) const |
void | setFrustumDistort (float offset) |
![]() | |
Camera () | |
constructor More... | |
virtual | ~Camera () |
Destructor. More... | |
Point3D | getOrigin () const |
Return the origin of the camera. More... | |
Point3D | getViewDirection () const |
Return the view direction for the camera. More... | |
Point3D | getUpDirection () const |
Return the up direction for the camera. More... | |
unsigned int | getProjectionMode () const |
return the projection mode More... | |
float | getOrthoScale () const |
void | setViewDirection (const Point3D &) |
set the direction that the camera looks towards More... | |
void | setUpDirection (const Point3D &) |
set the direction that the camera considers "up" More... | |
void | setUserString (const std::string &newString) |
Set the user string. More... | |
std::string | getUserString () const |
Get the user string. More... | |
unsigned int | type () const |
Protected Member Functions | |
void | recomputeViewDirection () |
Protected Attributes | |
Point3D | target |
Location for camera to look at. More... | |
float | fovAngle |
Perspective FOV. More... | |
float | nearPlane |
Near clipping plane distance. More... | |
float | farPlane |
Far plane is computed on-the-fly. cannot be set directly. Oh no! mutable. gross! More... | |
float | frustumDistortion |
Distort to the viewing frustum. (eg for stero) ( a frustum is a rectangular pyramid with the top cut off) More... | |
![]() | |
bool | lock |
Point3D | origin |
Camera location. More... | |
Point3D | viewDirection |
Direction camera is looking in. More... | |
Point3D | upDirection |
Up direction for camera (required to work out "roll") More... | |
unsigned int | projectionMode |
Projection mode (otho, perspective...)_. More... | |
float | orthoScale |
The current orthographic scaling. More... | |
unsigned int | typeNum |
Type number. More... | |
std::string | userString |
user string, e.g. camera name More... | |
Friends | |
std::ostream & | operator<< (std::ostream &stream, const CameraLookAt &) |
Streaming output operator, presents human readable text. More... | |
A perspective camera that looks at a specific location.
CameraLookAt::CameraLookAt | ( | ) |
Constructor.
References CAM_LOOKAT, Camera::origin, PROJECTION_MODE_PERSPECTIVE, Camera::projectionMode, Camera::typeNum, Camera::upDirection, and Camera::viewDirection.
Referenced by clone().
|
virtual |
Destructor.
|
virtual |
Applies the view transform.
Implements Camera.
References ASSERT, farPlane, fovAngle, BoundCube::getMaxDistanceToBox(), lookAt(), nearPlane, Camera::origin, Camera::orthoScale, PROJECTION_MODE_ORTHOGONAL, PROJECTION_MODE_PERSPECTIVE, Camera::projectionMode, Point3D::sqrDist(), and target.
|
virtual |
clone function
Implements Camera.
References CameraLookAt(), farPlane, fovAngle, Camera::lock, nearPlane, Camera::origin, Camera::orthoScale, Camera::projectionMode, target, Camera::typeNum, Camera::upDirection, Camera::userString, and Camera::viewDirection.
|
virtual |
Ensure that the box is visible.
Face is set by cube net 0 1 2 3 4 5 2 is the face directed to the +ve x axis, with the "up"" vector on the 3 aligned to z, so "0" is perpendicular to the Z axis and is "visible"
Implements Camera.
References ASSERT, CAMERA_DIR_XMINUS, CAMERA_DIR_XPLUS, CAMERA_DIR_YMINUS, CAMERA_DIR_YPLUS, CAMERA_DIR_ZMINUS, CAMERA_DIR_ZPLUS, fovAngle, BoundCube::getCentroid(), BoundCube::getSize(), Camera::lock, M_PI, nearPlane, Camera::origin, Camera::orthoScale, PROJECTION_MODE_PERSPECTIVE, Camera::projectionMode, recomputeUpDirection(), recomputeViewDirection(), Point3D::sqrDist(), target, and Camera::upDirection.
|
virtual |
Do a forwards "dolly",where the camera moves along its viewing axis.
Reimplemented from Camera.
References Camera::lock, Camera::origin, ORTHO_SPEED_HACK, Camera::orthoScale, PROJECTION_MODE_PERSPECTIVE, Camera::projectionMode, Point3D::sqrDist(), target, and Camera::viewDirection.
|
inline |
Get the camera's FOV angle (full angle across)
Referenced by BasicGLPane::saveImage().
|
inline |
References CameraProperty::key, and tabs().
Referenced by BasicGLPane::saveImage().
|
virtual |
Return the user-settable properties of the camera.
Implements Camera.
References CameraProperties::addEntry(), CameraProperties::addGroup(), ASSERT, boolStrEnc(), CAMERA_KEY_LOOKAT_FOV, CAMERA_KEY_LOOKAT_LOCK, CAMERA_KEY_LOOKAT_ORIGIN, CAMERA_KEY_LOOKAT_ORTHOSCALE, CAMERA_KEY_LOOKAT_PROJECTIONMODE, CAMERA_KEY_LOOKAT_TARGET, CAMERA_KEY_LOOKAT_UPDIRECTION, choiceString(), CameraProperties::clear(), CameraProperty::data, fovAngle, CameraProperty::key, Camera::lock, CameraProperty::name, Camera::origin, Camera::orthoScale, PROJECTION_MODE_ORTHOGONAL, PROJECTION_MODE_PERSPECTIVE, Camera::projectionMode, PROPERTY_TYPE_BOOL, PROPERTY_TYPE_CHOICE, PROPERTY_TYPE_POINT3D, PROPERTY_TYPE_REAL, stream_cast(), target, TRANS, CameraProperty::type, and Camera::upDirection.
float CameraLookAt::getViewWidth | ( | float | depth | ) | const |
References ASSERT, fovAngle, M_PI, Camera::orthoScale, PROJECTION_MODE_ORTHOGONAL, PROJECTION_MODE_PERSPECTIVE, and Camera::projectionMode.
void CameraLookAt::lookAt | ( | ) | const |
Only apply the look-at opengl transform.
References ASSERT, Camera::origin, target, and Camera::upDirection.
Referenced by apply().
|
virtual |
Move the camera origin.
Reimplemented from Camera.
References Point3D::crossProd(), Point3f::fx, Point3f::fy, Point3f::fz, Camera::lock, Point3D::normalise(), Camera::origin, quat_rot(), recomputeViewDirection(), target, Camera::upDirection, and Camera::viewDirection.
|
virtual |
Simulate pivot of camera.
Reimplemented from Camera.
References Point3D::crossProd(), Point3f::fx, Point3f::fy, Point3f::fz, Camera::lock, Point3D::normalise(), Camera::origin, quat_rot(), recomputeUpDirection(), recomputeViewDirection(), target, Camera::upDirection, and Camera::viewDirection.
|
virtual |
Read the state of the camera.
Implements Camera.
References fovAngle, Camera::lock, nearPlane, Camera::origin, Camera::orthoScale, PROJECTION_MODE_ENUM_END, Camera::projectionMode, recomputeViewDirection(), stream_cast(), target, Camera::upDirection, Camera::userString, XMLGetNextElemAttrib(), and XMLHelpFwdToElem().
void CameraLookAt::recomputeUpDirection | ( | ) |
Ensure that up direction is perpendicular to view direction.
References Point3D::crossProd(), Point3D::normalise(), Camera::upDirection, and Camera::viewDirection.
Referenced by ensureVisible(), pivot(), roll(), and setProperty().
|
protected |
References Point3D::normalise(), Camera::origin, target, and Camera::viewDirection.
Referenced by ensureVisible(), move(), pivot(), readState(), setOrigin(), and setTarget().
void CameraLookAt::repositionAroundTarget | ( | unsigned int | direction | ) |
References ASSERT, CAMERA_DIR_XMINUS, CAMERA_DIR_XPLUS, CAMERA_DIR_YMINUS, CAMERA_DIR_YPLUS, CAMERA_DIR_ZMINUS, CAMERA_DIR_ZPLUS, Camera::origin, setOrigin(), Point3D::sqrDist(), and target.
Referenced by MainWindowFrame::realignCameraButton().
|
virtual |
Roll around the view direction.
Implements Camera.
References Point3f::fx, Point3f::fy, Point3f::fz, Camera::lock, quat_rot(), recomputeUpDirection(), Camera::upDirection, and Camera::viewDirection.
|
inline |
|
virtual |
Set the look at target.
Reimplemented from Camera.
References ASSERT, Camera::lock, Camera::origin, recomputeViewDirection(), Point3D::sqrDist(), and target.
Referenced by repositionAroundTarget().
|
virtual |
Set the camera property from a key & string pair.
Implements Camera.
References ASSERT, CAMERA_KEY_LOOKAT_FOV, CAMERA_KEY_LOOKAT_LOCK, CAMERA_KEY_LOOKAT_ORIGIN, CAMERA_KEY_LOOKAT_ORTHOSCALE, CAMERA_KEY_LOOKAT_PROJECTIONMODE, CAMERA_KEY_LOOKAT_TARGET, CAMERA_KEY_LOOKAT_UPDIRECTION, Point3D::crossProd(), fovAngle, Camera::lock, Camera::origin, Camera::orthoScale, Point3D::parse(), PROJECTION_MODE_ORTHOGONAL, PROJECTION_MODE_PERSPECTIVE, Camera::projectionMode, recomputeUpDirection(), Point3D::sqrDist(), Point3D::sqrMag(), stream_cast(), target, TRANS, Camera::upDirection, and Camera::viewDirection.
void CameraLookAt::setTarget | ( | const Point3D & | pt | ) |
Set the look at target.
References ASSERT, Camera::origin, recomputeViewDirection(), Point3D::sqrDist(), and target.
Referenced by MainWindowFrame::realignCameraButton().
|
virtual |
Move the camera origin.
Reimplemented from Camera.
References Point3D::crossProd(), fovAngle, Camera::lock, M_PI, Camera::origin, PROJECTION_MODE_PERSPECTIVE, Camera::projectionMode, Point3D::sqrDist(), target, Camera::upDirection, and Camera::viewDirection.
|
virtual |
Write the state of the camera.
Implements Camera.
References ASSERT, escapeXML(), fovAngle, Camera::lock, nearPlane, Camera::origin, Camera::orthoScale, Camera::projectionMode, STATE_FORMAT_XML, tabs(), target, Camera::upDirection, and Camera::userString.
|
friend |
Streaming output operator, presents human readable text.
|
mutableprotected |
|
protected |
Perspective FOV.
Referenced by apply(), clone(), ensureVisible(), getProperties(), getViewWidth(), operator<<(), readState(), setProperty(), translate(), and writeState().
|
protected |
Distort to the viewing frustum. (eg for stero) ( a frustum is a rectangular pyramid with the top cut off)
|
protected |
Near clipping plane distance.
Referenced by apply(), clone(), ensureVisible(), operator<<(), readState(), and writeState().
|
protected |
Location for camera to look at.
Referenced by apply(), clone(), ensureVisible(), forwardsDolly(), getProperties(), getTarget(), lookAt(), move(), operator<<(), pivot(), readState(), recomputeViewDirection(), repositionAroundTarget(), setOrigin(), setProperty(), setTarget(), translate(), and writeState().