cee::vis::Camera

class Camera : public RefCountedObject

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 Envision for Desktop 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()

See also

View

Public Types

enum ProjectionType

Projection type.

Values:

enumerator PERSPECTIVE

Perspective projection.

enumerator ORTHO

Orthographic (parallel) projection.

enum ScreenAxis

Rotation screen axis.

Values:

enumerator SCREEN_X_AXIS

Horizontal axis to the right.

enumerator SCREEN_Y_AXIS

Vertical axis to the up.

enumerator SCREEN_Z_AXIS

Normal direction leaving the screen.

Public 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.

void toLookAt(Vec3d *eye, Vec3d *vrp, Vec3d *up) const

Returns the eye position, view reference point and up vector for the current view matrix.

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.

The passed boundingBox should be the bounding box of the object/model you would like to fit the view to.

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.

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.

void rotateGlobalAxis(double radians, const Vec3d &axis)

Rotates the view using the model axis as reference direction axis and an angle of radians.

It uses the rotation point defined in the CameraInputHandler

void 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 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.

void 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 setProjectionAsOrtho(double height, double nearPlane, double farPlane)

Sets up an orthographic projection.

This works similar to glOrtho().

void enableAutoClipMinimumNearDistance(double minNearDistance)

Enables the auto clipping feature and sets a minimum near distance.

void enableAutoClipFixedNearDistance(double fixedNearDistance)

Enables the auto clipping feature and sets a fixed near distance.

void disableAutoClip()

Disables the auto clipping feature.

ProjectionType projection() const

Returns the current projection type (Perspective or Orthographic/Parallel)

double fieldOfViewYDegrees() const

Returns the total field of view in Y direction in degrees.

If projection is orthographic, this function will return UNDEFINED_DOUBLE.

double nearPlane() const

Returns the near clipping plane.

double farPlane() const

Returns the far clipping plane.

double frontPlaneFrustumHeight() const

Returns the height of the front plane frustum.

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.

The passed boundingBox should be the bounding box of the object/model you would like to fit the view to.

unsigned int viewportWidth() const

Returns the width of the viewport.

unsigned int viewportHeight() const

Returns the height of the viewport.

int 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 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.

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.

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.

Ray 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.

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.

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.

bool unproject(const Vec3d &coord, Vec3d *out) const

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.

bool project(const Vec3d &point, Vec3d *out) const

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.

Mat4d viewMatrix() const

Returns the view matrix.

void setViewMatrix(Mat4d mat)

Sets the view matrix.

CameraInputHandler *inputHandler()

Returns the current input handler for the camera.

const CameraInputHandler *inputHandler() const

Returns the current input handler for the camera.

void setInputHandler(CameraInputHandler *handler)

Sets the input handler to use for this camera.