The camera configuration of a view. More...
Public Types | |
enum | ProjectionType { PERSPECTIVE, ORTHO } |
Projection type. More... | |
enum | ScreenAxis { SCREEN_X_AXIS, SCREEN_Y_AXIS, SCREEN_Z_AXIS } |
Rotation screen axis. More... | |
Public Member Functions | |
void | setFromLookAt (const Vec3d &eye, const Vec3d &vrp, const Vec3d &up) |
Sets the view matrix using the eye position eye, the view reference point vrp and the up vector up. More... | |
void | toLookAt (Vec3d *eye, Vec3d *vrp, Vec3d *up) const |
Returns the eye position, view reference point and up vector for the current view matrix. More... | |
void | fitView (const BoundingBox &boundingBox, const Vec3d &dir, const Vec3d &up, double adjustmentFactor=0.9) |
Sets up the view to contain the passed bounding box, with the camera looking from the given direction dir and with the given up vector up. More... | |
void | fitViewOrtho (const BoundingBox &boundingBox, double eyeDist, const Vec3d &dir, const Vec3d &up, double adjustmentFactor=0.9) |
Sets up the view to contain the passed bounding box, with the camera looking from the given direction dir, at the give distance eyeDist and with the given up vector up. More... | |
void | rotateGlobalAxis (double radians, const Vec3d &axis) |
Rotates the view using the model axis as reference direction axis and a angle of radians. More... | |
void | rotateScreenAxis (double radians, ScreenAxis dir) |
Rotates the view using the screen axis as reference. More... | |
void | rubberbandZoom (int x, int y, unsigned int width, unsigned int height) |
Zooms in or out in the view by the given rubberband rectangle. More... | |
void | setProjectionAsPerspective (double fieldOfViewYDeg, double nearPlane, double farPlane) |
Sets up a perspective projection. More... | |
void | setProjectionAsOrtho (double height, double nearPlane, double farPlane) |
Sets up an orthographic projection. More... | |
void | enableAutoClipMinimumNearDistance (double minNearDistance) |
Enables the auto clipping feature and sets a minimum near distance. More... | |
void | enableAutoClipFixedNearDistance (double fixedNearDistance) |
Enables the auto clipping feature and sets a fixed near distance. More... | |
void | disableAutoClip () |
Disables the auto clipping feature. More... | |
ProjectionType | projection () const |
Returns the current projection type (Perspective or Orthographic/Parallel) More... | |
double | fieldOfViewYDegrees () const |
Returns the total field of view in Y direction in degrees. More... | |
double | nearPlane () const |
Returns the near clipping plane. More... | |
double | farPlane () const |
Returns the far clipping plane. More... | |
double | frontPlaneFrustumHeight () const |
Returns the height of the front plane frustum. More... | |
Vec3d | computeFitViewEyePosition (const BoundingBox &boundingBox, const Vec3d &dir, const Vec3d &up, double adjustmentFactor=0.9, double fieldOfViewYDeg=40.0) const |
Returns the eye point that will contain the model from the given direction and up vector. More... | |
unsigned int | viewportWidth () const |
Returns the width of the viewport. More... | |
unsigned int | viewportHeight () const |
Returns the height of the viewport. More... | |
int | viewportPositionX () const |
Returns the X coordinate of the bottom left corner of the viewport associated with this camera. More... | |
int | viewportPositionY () const |
Returns the Y coordinate of the bottom left corner of the viewport associated with this camera. More... | |
void | setViewport (int x, int y, unsigned int width, unsigned int height) |
Specifies the position and dimensions of the viewport, and update the projection matrix. More... | |
Ray | rayFromWindowCoordinates (int x, int y) const |
Returns a ray computed from the windows coordinates. More... | |
Plane | planeFromWindowCoordinates (int x1, int y1, int x2, int y2) const |
Returns a plane in world coordinates defined by the line (x1, y1) -> (x2, y2) going straight into the view. More... | |
bool | unproject (const Vec3d &coord, Vec3d *out) const |
OpenGL like unproject. More... | |
bool | project (const Vec3d &point, Vec3d *out) const |
Maps object coordinates to window coordinates. More... | |
Mat4d | viewMatrix () const |
Returns the view matrix. More... | |
void | setViewMatrix (Mat4d mat) |
Sets the view matrix. More... | |
CameraInputHandler * | inputHandler () |
Returns the current input handler for the camera. More... | |
const CameraInputHandler * | inputHandler () const |
Returns the current input handler for the camera. More... | |
void | setInputHandler (CameraInputHandler *handler) |
Sets the input handler to use for this camera. More... | |
![]() | |
void | addRef () const |
Increments the reference count for this object. More... | |
void | release () const |
Decrements the reference count for this object. More... | |
int | refCount () const |
Returns the reference count for this object. More... | |
void | setRefCountZero () const |
Sets the ref count to zero, but DOES NOT delete the object. More... | |
The camera configuration of a view.
The camera object describes how to look at the model in the view. The view point is set using eye position, view reference point and up vectors. Set with setFromLookAt() and get with toLookAt().
The Camera has an input handler, CameraInputHandler, that handles user input(mouse and keyboard events) and manipulates the camera based on these events.This is used to move the camera around the scene to inspect the model. Ceetron Desktop Components provides two default Input Handlers :
The camera enables both perspective (field of view and clipping planes) and parallel projection. The camera offers useful features such as support for rubberband zooming and extracting ray from windows coordinates to be used for picking.
Each View has an associated Camera object. Get the camera using View::camera()
cee::Vec3d cee::vis::Camera::computeFitViewEyePosition | ( | const BoundingBox & | boundingBox, |
const Vec3d & | dir, | ||
const Vec3d & | up, | ||
double | adjustmentFactor = 0.9 , |
||
double | fieldOfViewYDeg = 40.0 |
||
) | const |
Returns the eye point that will contain the model from the given direction and up vector.
The passed boundingBox should be the bounding box of the object/model you would like to fit the view to.
void cee::vis::Camera::disableAutoClip | ( | ) |
Disables the auto clipping feature.
void cee::vis::Camera::enableAutoClipFixedNearDistance | ( | double | fixedNearDistance | ) |
Enables the auto clipping feature and sets a fixed near distance.
void cee::vis::Camera::enableAutoClipMinimumNearDistance | ( | double | minNearDistance | ) |
Enables the auto clipping feature and sets a minimum near distance.
double cee::vis::Camera::farPlane | ( | ) | const |
Returns the far clipping plane.
double cee::vis::Camera::fieldOfViewYDegrees | ( | ) | const |
Returns the total field of view in Y direction in degrees.
If projection is orthographic, this function will return UNDEFINED_DOUBLE.
void cee::vis::Camera::fitView | ( | const BoundingBox & | boundingBox, |
const Vec3d & | dir, | ||
const Vec3d & | up, | ||
double | adjustmentFactor = 0.9 |
||
) |
Sets up the view to contain the passed bounding box, with the camera looking from the given direction dir and with the given up vector up.
The passed boundingBox should be the bounding box of the object/model you would like to fit the view to.
void cee::vis::Camera::fitViewOrtho | ( | const BoundingBox & | boundingBox, |
double | eyeDist, | ||
const Vec3d & | dir, | ||
const Vec3d & | up, | ||
double | adjustmentFactor = 0.9 |
||
) |
Sets up the view to contain the passed bounding box, with the camera looking from the given direction dir, at the give distance eyeDist and with the given up vector up.
We recommend to set the eyeDist to boundingBox.radius()*2
.0
The passed boundingBox should be the bounding box of the object/model you would like to fit the view to.
double cee::vis::Camera::frontPlaneFrustumHeight | ( | ) | const |
Returns the height of the front plane frustum.
CameraInputHandler * cee::vis::Camera::inputHandler | ( | ) |
Returns the current input handler for the camera.
const CameraInputHandler * cee::vis::Camera::inputHandler | ( | ) | const |
Returns the current input handler for the camera.
double cee::vis::Camera::nearPlane | ( | ) | const |
Returns the near clipping plane.
Plane cee::vis::Camera::planeFromWindowCoordinates | ( | int | x1, |
int | y1, | ||
int | x2, | ||
int | y2 | ||
) | const |
Returns a plane in world coordinates defined by the line (x1, y1) -> (x2, y2) going straight into the view.
The input (window) coordinates must be specified in OpenGL style coordinates, which means a right handed coordinate system with the origin in the lower left corner of the window.
This is useful for clipping or set generation based on user input in screen coordinates.
Maps object coordinates to window coordinates.
The returned window coordinates out are in OpenGL style coordinates, which means a right handed coordinate system with the origin in the lower left corner of the window.
cee::vis::Camera::ProjectionType cee::vis::Camera::projection | ( | ) | const |
Returns the current projection type (Perspective or Orthographic/Parallel)
cee::Ray cee::vis::Camera::rayFromWindowCoordinates | ( | int | x, |
int | y | ||
) | const |
Returns a ray computed from the windows coordinates.
The input (window) coordinates must be specified in OpenGL style coordinates, which means a right handed coordinate system with the origin in the lower left corner of the window.
void cee::vis::Camera::rotateGlobalAxis | ( | double | radians, |
const Vec3d & | axis | ||
) |
Rotates the view using the model axis as reference direction axis and a angle of radians.
It uses the rotation point defined in the CameraInputHandler
void cee::vis::Camera::rotateScreenAxis | ( | double | radians, |
ScreenAxis | dir | ||
) |
Rotates the view using the screen axis as reference.
Direction dir is the ScreenAxis: { SCREEN_X_AXIS, SCREEN_Y_AXIS, SCREEN_Z_AXIS } The X-screen axis is always the horizontal vector pointing to the right. The Y-screen axis is always the vertical vector going up. The Z-screen axis is always the normal vector leaving the screen.
Angle in radians. It uses the rotation point defined in the CameraInputHandler
void cee::vis::Camera::rubberbandZoom | ( | int | x, |
int | y, | ||
unsigned int | width, | ||
unsigned int | height | ||
) |
Zooms in or out in the view by the given rubberband rectangle.
The input (window) coordinates (x, y) must be specified in OpenGL style coordinates, which means a right handed coordinate system with the origin in the lower left corner of the window.
Sets the view matrix using the eye position eye, the view reference point vrp and the up vector up.
void cee::vis::Camera::setInputHandler | ( | CameraInputHandler * | handler | ) |
Sets the input handler to use for this camera.
void cee::vis::Camera::setProjectionAsOrtho | ( | double | height, |
double | nearPlane, | ||
double | farPlane | ||
) |
Sets up an orthographic projection.
This works similar to glOrtho().
void cee::vis::Camera::setProjectionAsPerspective | ( | double | fieldOfViewYDeg, |
double | nearPlane, | ||
double | farPlane | ||
) |
Sets up a perspective projection.
The fieldOfViewYDeg parameter is the total field of view angle (in degrees) in the Y direction. Works similar to gluPerspective().
void cee::vis::Camera::setViewMatrix | ( | Mat4d | mat | ) |
Sets the view matrix.
void cee::vis::Camera::setViewport | ( | int | x, |
int | y, | ||
unsigned int | width, | ||
unsigned int | height | ||
) |
Specifies the position and dimensions of the viewport, and update the projection matrix.
This method is usually used as a response to a Resize message from the window system.
The input (window) coordinates (x, y) must be specified in OpenGL style coordinates, which means a right handed coordinate system with the origin in the lower left corner of the window.
Returns the eye position, view reference point and up vector for the current view matrix.
OpenGL like unproject.
The input (window) coordinates coord must be specified in OpenGL style coordinates, which means a right handed coordinate system with the origin in the lower left corner of the window.
Mat4d cee::vis::Camera::viewMatrix | ( | ) | const |
Returns the view matrix.
unsigned int cee::vis::Camera::viewportHeight | ( | ) | const |
Returns the height of the viewport.
int cee::vis::Camera::viewportPositionX | ( | ) | const |
Returns the X coordinate of the bottom left corner of the viewport associated with this camera.
The returned coordinate is specified in OpenGL style coordinates, which means a right handed coordinate system with the origin in the lower left corner of the window.
int cee::vis::Camera::viewportPositionY | ( | ) | const |
Returns the Y coordinate of the bottom left corner of the viewport associated with this camera.
The returned coordinate is specified in OpenGL style coordinates, which means a right handed coordinate system with the origin in the lower left corner of the window.
unsigned int cee::vis::Camera::viewportWidth | ( | ) | const |
Returns the width of the viewport.