StandardCamera Class Reference
Inheritance diagram for StandardCamera:

Public Member Functions

void changeOrthoFrustumSize (int delta)
 
virtual void getOrthoWidthHeight (GLdouble &halfWidth, GLdouble &halfHeight) const
 Returns the halfWidth and halfHeight of the Camera orthographic frustum.
 
virtual float zFar () const
 Returns the far clipping plane distance used by the Camera projection matrix.
 
virtual float zNear () const
 Returns the near clipping plane distance used by the Camera projection matrix.
 
- Public Member Functions inherited from Camera
 Camera ()
 Default constructor.
 
 Camera (const Camera &camera)
 Copy constructor.
 
virtual ~Camera ()
 Virtual destructor.
 
Cameraoperator= (const Camera &camera)
 Equal operator.
 
Vec position () const
 Returns the Camera position (the eye), defined in the world coordinate system.
 
Vec upVector () const
 Returns the normalized up vector of the Camera, defined in the world coordinate system.
 
Vec viewDirection () const
 Returns the normalized view direction of the Camera, defined in the world coordinate system.
 
Vec rightVector () const
 Returns the normalized right vector of the Camera, defined in the world coordinate system.
 
Quaternion orientation () const
 Returns the Camera orientation, defined in the world coordinate system.
 
void setFromModelViewMatrix (const GLdouble *const modelViewMatrix)
 Sets the Camera's position() and orientation() from an OpenGL ModelView matrix.
 
void setFromProjectionMatrix (const float matrix[12])
 Defines the Camera position(), orientation() and fieldOfView() from a projection matrix.
 
Type type () const
 Returns the Camera::Type of the Camera.
 
float fieldOfView () const
 Returns the vertical field of view of the Camera (in radians).
 
float horizontalFieldOfView () const
 Returns the horizontal field of view of the Camera (in radians).
 
float aspectRatio () const
 Returns the Camera aspect ratio defined by screenWidth() / screenHeight().
 
int screenWidth () const
 Returns the width (in pixels) of the Camera screen.
 
int screenHeight () const
 Returns the height (in pixels) of the Camera screen.
 
void getViewport (GLint viewport[4]) const
 Fills viewport with the Camera OpenGL viewport.
 
float pixelGLRatio (const Vec &position) const
 Returns the ratio between pixel and OpenGL units at position.
 
float zNearCoefficient () const
 Returns the coefficient which is used to set zNear() when the Camera is inside the sphere defined by sceneCenter() and zClippingCoefficient() * sceneRadius().
 
float zClippingCoefficient () const
 Returns the coefficient used to position the near and far clipping planes.
 
void getFrustumPlanesCoefficients (GLdouble coef[6][4]) const
 Returns the 6 plane equations of the Camera frustum.
 
float sceneRadius () const
 Returns the radius of the scene observed by the Camera.
 
Vec sceneCenter () const
 Returns the position of the scene center, defined in the world coordinate system.
 
float distanceToSceneCenter () const
 Returns the distance from the Camera center to sceneCenter(), projected along the Camera Z axis.
 
Vec revolveAroundPoint () const
 The point the Camera revolves around with the QGLViewer::ROTATE mouse binding.
 
ManipulatedCameraFrameframe () const
 Returns the ManipulatedCameraFrame attached to the Camera.
 
KeyFrameInterpolatorkeyFrameInterpolator (int i) const
 Returns the KeyFrameInterpolator that defines the Camera path number i.
 
virtual void loadProjectionMatrix (bool reset=true) const
 Loads the OpenGL GL_PROJECTION matrix with the Camera projection matrix.
 
virtual void loadModelViewMatrix (bool reset=true) const
 Loads the OpenGL GL_MODELVIEW matrix with the modelView matrix corresponding to the Camera.
 
void computeProjectionMatrix () const
 Computes the projection matrix associated with the Camera.
 
void computeModelViewMatrix () const
 Computes the modelView matrix associated with the Camera's position() and orientation().
 
virtual void loadProjectionMatrixStereo (bool leftBuffer=true) const
 Same as loadProjectionMatrix() but for a stereo setup.
 
virtual void loadModelViewMatrixStereo (bool leftBuffer=true) const
 Same as loadModelViewMatrix() but for a stereo setup.
 
void getProjectionMatrix (GLdouble m[16]) const
 Fills m with the Camera projection matrix values.
 
void getModelViewMatrix (GLdouble m[16]) const
 Fills m with the Camera modelView matrix values.
 
void getModelViewProjectionMatrix (GLdouble m[16]) const
 Fills m with the product of the ModelView and Projection matrices.
 
void getProjectionMatrix (GLfloat m[16]) const
 
void getModelViewMatrix (GLfloat m[16]) const
 
virtual void draw (bool drawFarPlane=true, float scale=1.0) const
 Draws a representation of the Camera in the 3D world.
 
Vec cameraCoordinatesOf (const Vec &src) const
 Returns the Camera frame coordinates of a point src defined in world coordinates.
 
Vec worldCoordinatesOf (const Vec &src) const
 Returns the world coordinates of the point whose position src is defined in the Camera coordinate system.
 
void getCameraCoordinatesOf (const float src[3], float res[3]) const
 Same as cameraCoordinatesOf(), but with float[3] parameters (src and res may be identical pointers).
 
void getWorldCoordinatesOf (const float src[3], float res[3]) const
 Same as worldCoordinatesOf(), but with float[3] parameters (src and res may be identical pointers).
 
Vec projectedCoordinatesOf (const Vec &src, const Frame *frame=NULL) const
 Returns the screen projected coordinates of a point src defined in the frame coordinate system.
 
Vec unprojectedCoordinatesOf (const Vec &src, const Frame *frame=NULL) const
 Returns the world unprojected coordinates of a point src defined in the screen coordinate system.
 
void getProjectedCoordinatesOf (const float src[3], float res[3], const Frame *frame=NULL) const
 Same as projectedCoordinatesOf(), but with float parameters (src and res can be identical pointers).
 
void getUnprojectedCoordinatesOf (const float src[3], float res[3], const Frame *frame=NULL) const
 Same as unprojectedCoordinatesOf(), but with float parameters (src and res can be identical pointers).
 
void convertClickToLine (const QPoint &pixel, Vec &orig, Vec &dir) const
 Gives the coefficients of a 3D half-line passing through the Camera eye and pixel (x,y).
 
Vec pointUnderPixel (const QPoint &pixel, bool &found) const
 Returns the coordinates of the 3D point located at pixel (x,y) on screen.
 
float flySpeed () const
 Returns the fly speed of the Camera.
 
float IODistance () const
 Returns the user's inter-ocular distance (in meters).
 
float physicalDistanceToScreen () const
 Returns the physical distance between the user's eyes and the screen (in meters).
 
float physicalScreenWidth () const
 Returns the physical screen width, in meters.
 
float focusDistance () const
 Returns the focus distance used by stereo display, expressed in OpenGL units.
 
virtual QDomElement domElement (const QString &name, QDomDocument &document) const
 Returns an XML QDomElement that represents the Camera.
 

Additional Inherited Members

- Public Types inherited from Camera
enum  Type { PERSPECTIVE, ORTHOGRAPHIC }
 Enumerates the two possible types of Camera. More...
 
- Public Slots inherited from Camera
void setPosition (const Vec &pos)
 Sets the Camera position() (the eye), defined in the world coordinate system.
 
void setOrientation (const Quaternion &q)
 Sets the Camera orientation(), defined in the world coordinate system.
 
void setOrientation (float theta, float phi)
 Sets the orientation() of the Camera using polar coordinates.
 
void setUpVector (const Vec &up, bool noMove=true)
 Rotates the Camera so that its upVector() becomes up (defined in the world coordinate system).
 
void setViewDirection (const Vec &direction)
 Rotates the Camera so that its viewDirection() is direction (defined in the world coordinate system).
 
void setType (Type type)
 Defines the Camera type().
 
void setFieldOfView (float fov)
 Sets the vertical fieldOfView() of the Camera (in radians).
 
void setHorizontalFieldOfView (float hfov)
 Sets the horizontalFieldOfView() of the Camera (in radians).
 
void setFOVToFitScene ()
 Changes the Camera fieldOfView() so that the entire scene (defined by QGLViewer::sceneCenter() and QGLViewer::sceneRadius()) is visible from the Camera position().
 
void setAspectRatio (float aspect)
 Defines the Camera aspectRatio().
 
void setScreenWidthAndHeight (int width, int height)
 Sets Camera screenWidth() and screenHeight() (expressed in pixels).
 
void setZNearCoefficient (float coef)
 Sets the zNearCoefficient() value.
 
void setZClippingCoefficient (float coef)
 Sets the zClippingCoefficient() value.
 
void setSceneRadius (float radius)
 Sets the sceneRadius() value.
 
void setSceneCenter (const Vec &center)
 Sets the sceneCenter().
 
bool setSceneCenterFromPixel (const QPoint &pixel)
 setSceneCenter() to the result of pointUnderPixel(pixel).
 
void setSceneBoundingBox (const Vec &min, const Vec &max)
 Similar to setSceneRadius() and setSceneCenter(), but the scene limits are defined by a (world axis aligned) bounding box.
 
void setRevolveAroundPoint (const Vec &rap)
 Changes the revolveAroundPoint() to rap (defined in the world coordinate system).
 
bool setRevolveAroundPointFromPixel (const QPoint &pixel)
 The revolveAroundPoint() is set to the point located under pixel on screen.
 
void setFrame (ManipulatedCameraFrame *const mcf)
 Sets the Camera frame().
 
void setKeyFrameInterpolator (int i, KeyFrameInterpolator *const kfi)
 Sets the KeyFrameInterpolator that defines the Camera path of index i.
 
virtual void addKeyFrameToPath (int i)
 Adds the current Camera position() and orientation() as a keyFrame to the path number i.
 
virtual void playPath (int i)
 Makes the Camera follow the path of keyFrameInterpolator() number i.
 
virtual void deletePath (int i)
 Deletes the keyFrameInterpolator() of index i.
 
virtual void resetPath (int i)
 Resets the path of the keyFrameInterpolator() number i.
 
virtual void drawAllPaths ()
 Draws all the Camera paths defined by the keyFrameInterpolator().
 
void setFlySpeed (float speed)
 Sets the Camera flySpeed().
 
void setIODistance (float distance)
 Sets the IODistance().
 
void setPhysicalDistanceToScreen (float distance)
 Sets the physicalDistanceToScreen().
 
void setPhysicalScreenWidth (float width)
 Sets the physical screen (monitor or projected wall) width (in meters).
 
void setFocusDistance (float distance)
 Sets the focusDistance(), in OpenGL scene units.
 
virtual void initFromDOMElement (const QDomElement &element)
 Restores the Camera state from a QDomElement created by domElement().
 
void lookAt (const Vec &target)
 Sets the Camera orientation(), so that it looks at point target (defined in the world coordinate system).
 
void showEntireScene ()
 Moves the Camera so that the entire scene is visible.
 
void fitSphere (const Vec &center, float radius)
 Moves the Camera so that the sphere defined by (center, radius) is visible and fits the window.
 
void fitBoundingBox (const Vec &min, const Vec &max)
 Moves the Camera so that the (world axis aligned) bounding box (min, max) is entirely visible, using fitSphere().
 
void fitScreenRegion (const QRect &rectangle)
 Moves the Camera so that the rectangular screen region defined by rectangle (pixel units, with origin in the upper left corner) fits the screen.
 
void centerScene ()
 Moves the Camera so that its sceneCenter() is projected on the center of the window.
 
void interpolateToZoomOnPixel (const QPoint &pixel)
 Makes the Camera smoothly zoom on the pointUnderPixel() pixel.
 
void interpolateToFitScene ()
 Interpolates the Camera on a one second KeyFrameInterpolator path so that the entire scene fits the screen at the end.
 
void interpolateTo (const Frame &fr, float duration)
 Smoothly interpolates the Camera on a KeyFrameInterpolator path so that it goes to fr.
 
- Static Public Member Functions inherited from Camera
static void drawCamera (float scale=1.0, float aspectRatio=1.33, float fieldOfView=M_PI/4.0)
 This method has been deprecated in libQGLViewer version 2.2.0.
 

Detailed Description

Definition at line 326 of file renderworld.cpp.

Member Function Documentation

virtual void getOrthoWidthHeight ( GLdouble &  halfWidth,
GLdouble &  halfHeight 
) const
inlinevirtual

Returns the halfWidth and halfHeight of the Camera orthographic frustum.

These values are only valid and used when the Camera is of type() Camera::ORTHOGRAPHIC. They are expressed in OpenGL units and are used by loadProjectionMatrix() to define the projection matrix using:

glOrtho( -halfWidth, halfWidth, -halfHeight, halfHeight, zNear(), zFar() )

These values are proportional to the Camera (z projected) distance to the revolveAroundPoint(). When zooming on the object, the Camera is translated forward and its frustum is narrowed, making the object appear bigger on screen, as intuitively expected.

Overload this method to change this behavior if desired, as is done in the standardCamera example.

Reimplemented from Camera.

Definition at line 344 of file renderworld.cpp.

References Camera::aspectRatio().

virtual float zFar ( ) const
inlinevirtual

Returns the far clipping plane distance used by the Camera projection matrix.

The far clipping plane is positioned at a distance equal to zClippingCoefficient() * sceneRadius() behind the sceneCenter():

See the zNear() documentation for details.

Reimplemented from Camera.

Definition at line 334 of file renderworld.cpp.

virtual float zNear ( ) const
inlinevirtual

Returns the near clipping plane distance used by the Camera projection matrix.

The clipping planes' positions depend on the sceneRadius() and sceneCenter() rather than being fixed small-enough and large-enough values. A good scene dimension approximation will hence result in an optimal precision of the z-buffer.

The near clipping plane is positioned at a distance equal to zClippingCoefficient() * sceneRadius() in front of the sceneCenter():

In order to prevent negative or too small zNear() values (which would degrade the z precision), zNearCoefficient() is used when the Camera is inside the sceneRadius() sphere:

const float zMin = zNearCoefficient() * zClippingCoefficient() * sceneRadius();
if (zNear < zMin)
zNear = zMin;
// With an ORTHOGRAPHIC type, the value is simply clamped to 0.0

See also the zFar(), zClippingCoefficient() and zNearCoefficient() documentations.

If you need a completely different zNear computation, overload the zNear() and zFar() methods in a new class that publicly inherits from Camera and use QGLViewer::setCamera():

class myCamera :: public qglviewer::Camera
{
virtual float Camera::zNear() const { return 0.001; };
virtual float Camera::zFar() const { return 100.0; };
}

See the standardCamera example for an application.

Attention
The value is always positive although the clipping plane is positioned at a negative z value in the Camera coordinate system. This follows the gluPerspective standard.

Reimplemented from Camera.

Definition at line 331 of file renderworld.cpp.


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