Main Page   Class Hierarchy   Compound List   Compound Members  

qglviewer::Camera Class Reference

An OpenGL camera description. Includes a frame definition and camera parameters. More...

List of all members.

Camera intrinsic parameters

float fieldOfView () const
Type type () const
float aspectRatio () const
float distanceToSceneCenter () const
float flySpeed () const
bool isManipulated () const
ManipulatedFrame::Mode mode () const
virtual float zNear () const
virtual float zFar () const
float zNearCoef () const
int screenWidth () const
int screenHeight () const
virtual void getProjectionMatrix (GLdouble m[16]) const
virtual void getProjectionMatrix (GLfloat m[16]) const
virtual void getModelViewMatrix (GLdouble m[16]) const
virtual void getModelViewMatrix (GLfloat m[16]) const
qglviewer::Vec pointUnderPixel (const int x, const int y, bool &found)
void setMode (ManipulatedFrame::Mode m)
void toggleMode ()
void setFieldOfView (float f)
void setFlySpeed (float s)
void setType (Type type)
void setZNearCoef (float coef)
void setSceneRadius (float r)
void setSceneBoundingBox (const Vec &m, const Vec &M)
void setSceneCenter (const qglviewer::Vec &sc)
void setSceneCenter (float x, float y, float z)
void setSceneCenterFromPixel (int x, int y)

Stereo mode

float horizontalFieldOfView () const
float IODist () const
float distanceToScreen () const
float distanceToZeroParallaxPlane () const
float physicalScreenWidth () const
void setHorizontalFieldOfView (float hfov)
void setIODist (float iod)
void setDistanceToScreen (float dts)
void setDistanceToZeroParallaxPlane (float dtz)
void setPhysicalScreenWidth (float sw)

Position and orientation of the camera

void getPosition (float &x, float &y, float &z) const
qglviewer::Vec position () const
void getOrientation (float &q0, float &q1, float &q2, float &q3) const
qglviewer::Quaternion orientation () const
void setPosition (float x, float y, float z)
void setPosition (const qglviewer::Vec &pos)
void setOrientation (const qglviewer::Quaternion &q)
void setOrientation (float q0, float q1, float q2, float q3)
void setOrientation (float theta, float phi)
void setCameraFromProjectionMatrix (const float *const m)

Revolve Around Point (in REVOLVE mode)

qglviewer::Vec revolveAroundPoint () const
void getRevolveAroundPoint (float &x, float &y, float &z) const
void setRevolveAroundPoint (const qglviewer::Vec &rap)
void setRevolveAroundPoint (float x, float y, float z)
void setRevolveAroundPointFromPixel (int x, int y)
void setRevolveAroundPointToSceneCenter ()

Camera positionning tools

Constraintconstraint ()
qglviewer::Vec upVector () const
void getUpVector (float &x, float &y, float &z) const
qglviewer::Vec viewDirection () const
void lookAt (const qglviewer::Vec &target)
void lookAt (float x, float y, float z)
void fitSphere (float x, float y, float z, float r)
void fitSphere (const qglviewer::Vec &center, float radius)
void setUpVector (const qglviewer::Vec &up, bool noMove=true)
void setUpVector (float x, float y, float z, bool noMove=true)
void fitBBox (const qglviewer::Vec &m, const qglviewer::Vec &M)
void showEntireScene ()
void centerScene ()
void setConstraint (Constraint *c)
void zoomOnPixel (int x, int y)
void zoomOutFromPixel (int x, int y)

Camera Paths

A camera path is defined by a KeyFrameInterpolator (see setKeyFrameInterpolator()). You can interactively addKeyFrame() to a given path, mainly using the default QGLViewer shortcut: Alt-F[1-12] (see QGLViewer::setKeyFrameKey()). Use playKeyFramePath() to make the camera follow the path (default shortcut = F[1-12]).

int nbPaths () const
qglviewer::KeyFrameInterpolatorkeyFrameInterpolator (unsigned short i) const
void saveCurrentPOV (unsigned short i=0)
void restorePOV (unsigned short i=0)
void setKeyFrameInterpolator (unsigned short i, qglviewer::KeyFrameInterpolator *const kfi)
void addKeyFrame (int i)
void playKeyFramePath (int i)
void deleteKeyFramePath (int i)
void drawAllPaths ()

Public Types

enum  Type { PERSPECTIVE, ORTHO }

Public Methods

 Camera ()
virtual ~Camera ()
virtual QDomElement domElement (const QString &name, QDomDocument &doc) const
virtual void initFromDOMElement (const QDomElement &de)
World to Camera coordinate systems
Methods to go from the world to the camera coordinate systems, and vice-versa.

void getCameraCoordinatesOf (const float src[3], float res[3]) const
void getCameraCoordinatesOf (const qglviewer::Vec &src, float res[3]) const
qglviewer::Vec cameraCoordinatesOf (const qglviewer::Vec &src) const
void getWorldCoordinatesOf (const float src[3], float res[3]) const
void getWorldCoordinatesOf (const qglviewer::Vec &src, float res[3]) const
qglviewer::Vec worldCoordinatesOf (const qglviewer::Vec &src) const
2D screen to 3D world coordinate systems
Methods to go from the 2D screen to the 3D world coordinate systems, and vice-versa.

qglviewer::Vec projectedCoordinatesOf (const qglviewer::Vec &src) const
void getProjectedCoordinatesOf (const float src[3], float res[3]) const
qglviewer::Vec unprojectedCoordinatesOf (const qglviewer::Vec &src) const
void getUnprojectedCoordinatesOf (const float src[3], float res[3]) const

Public Attributes

qglviewer::ManipulatedFrame frame

Protected Slots

void setWindowWidthAndHeight (int w, int h)

Protected Methods

virtual void loadProjectionMatrix (bool reset=true) const
virtual void loadProjectionMatrixStereo (bool leftBuffer=true) const
virtual void loadModelViewMatrix (bool reset=true) const
virtual void loadModelViewMatrixStereo (bool leftBuffer=true) const
virtual void mouseDoubleClickEvent (QMouseEvent *)
virtual void adaptFrameState (qglviewer::Frame *const fr, QMouseEvent *const) const
float sceneRadius () const
void getSceneCenter (float &x, float &y, float &z) const
qglviewer::Vec sceneCenter () const
void computeModelViewMatrix () const


Detailed Description

An OpenGL camera description. Includes a frame definition and camera parameters.

Camera parameters include the camera type (see Type) and the field of view. The near and far planes are determined from the scene Radius (updated by the QGLViewer()).


Member Enumeration Documentation

enum Type
 

The type of camera used by the viewer, set by setType(). This type will be use in loadProjectionMatrix().

See also:
setFieldOfView, setSceneRadius, type, setType, loadProjectionMatrix


Constructor & Destructor Documentation

Camera  
 

Default values are given to the camera parameters : sceneCenter=0, sceneRadius=1, camera type = PERSPECTIVE, default stereo value, ....

virtual ~Camera   [inline, virtual]
 

Virtual destructor. Empty.


Member Function Documentation

void adaptFrameState qglviewer::Frame *const    fr,
QMouseEvent *    const
const [protected, virtual]
 

Moves the frame fr according to the camera parameters. The behavior depends on the clicked button e:

Left button aligns the the closest frame axis (if any) with the camera viewing direction with alignWithAxis(). frame position() is not modified.

Middle button moves the frame so that it is visible. Details to come...

Right button moves the frame so that its origin is projected in the middle of the window (frame orientation() is not modified). Details to come...

This function is called with a double click while the manipulated frame state key is pressed.

void addKeyFrame int    i [slot]
 

Adds the current camera frame as a key frame to the path number i. This function can also be used if you simply want to save a camera point of view, as it is simply a key frame path made of one key frame.

The default shortcut for this function is Alt-F[1-12]. Set setKeyFrameKey() and setAddKeyFrameStateKey().

Use playKeyFramePath() to make the camera play the key frame path (resp restore point of view). Use deleteKeyFramePath() to clear the key frame path.

See also keyFrameInterpolator() and setKeyFrameInterpolator() to directly define a complete path.

float aspectRatio   const [inline]
 

Returns the currents camera aspect ratio (screenWidth/screenHeight), determined from the QGLViewer() window size.

qglviewer::Vec cameraCoordinatesOf const qglviewer::Vec   src const [inline]
 

Returns the camera frame coordinates of a point src defined in world coordinates. worldCoordinatesOf() performs the inverse transformation.

void centerScene   [slot]
 

Adjust the camera so that the sceneCenter() is projected on the center of the window.

See also showEntireScene().

void computeModelViewMatrix   const [protected]
 

Computes the model view matrix associated with the camera state. Called by loadModelViewMatrix() before each drawing. You may need to call this (unlikely) if you use the model view matrix out of the main drawing loop, for a (un) projectedCoordinatesOf() or a getModelViewMatrix() for instance.

Constraint* constraint   [inline]
 

Returns a pointer to the Constraint that is currently attached to the camera. See setConstraint().

void deleteKeyFramePath int    i [slot]
 

Deletes the KeyFrameInterpolator of index i. If this keyFrame path is being played (see playKeyFramePath() ), simply reset it to is its starting position (see KeyFrameInterpolator::resetInterpolation()). Use addKeyFrame() to define a key frame path.

float distanceToSceneCenter   const
 

Returns the distance from the camera center to sceneCenter(). Used by zNear() and zFar() to optimize the Z range.

float distanceToScreen   const [inline]
 

Returns the physical distance to screen (used for stereo mode only). Value is set using setDistanceToScreen()

float distanceToZeroParallaxPlane   const [inline]
 

Returns the distance to 0 parallax plane (used for stereo mode only). Value is set using setDistanceToZeroParallaxPlane()

QDomElement domElement const QString &    name,
QDomDocument &    doc
const [virtual]
 

Creates an XML QDomElement that represents the Camera. name is the name of the QDomElement tag. You need to provide the QDomDocument doc that will hold the resulting element.

Use initFromDOMElement() to restore the Camera state from the resulting domElement.

See also KeyFrameInterpolator::domElement(), Frame::domElement()...

If you want to save the camera state in a file, use

  QDomDocument doc("myCAMERA");
  doc.appendChild(domElement("Camera", doc));
  ofstream file("myCamera.xml");
  file << doc.toString();
Note that this is done automatically by QGLViewer::saveToFile() when a viewer is deleted.

Use the following code to retrieve state from the saved file:

 // Load DOM from file
 QDomDocument doc;
 QFile f("myCamera.xml");
 f.open(IO_ReadOnly);
 doc.setContent(&f);
 f.close();
 // Parse the DOM tree
 QDomElement main=doc.documentElement();
 myCamera.initFromDOMElement(main);

void drawAllPaths   [slot]
 

Draws the camera paths defined by the keyFrameInterpolator(). Simply calls KeyFrameInterpolator::drawPath() for all the defined path. See addKeyFrame() and setKeyFrameInterpolator() to define a path.

float fieldOfView   const [inline]
 

Returns the vertical field of view of the camera (in degrees). Value is set using setFieldOfView().

void fitBBox const qglviewer::Vec   m,
const qglviewer::Vec   M
[slot]
 

Set the camera so that the bounding box m,M is entirely visible, using fitSphere().

m and M are two extremal corners of the BBox.

void fitSphere const qglviewer::Vec   center,
float    radius
[slot]
 

Place camera so that the sphere (center, radius) is visible and fits the window. The camera is translated so that the sphere fits the screen, its orientation is unchanged.

void fitSphere float    x,
float    y,
float    z,
float    r
[inline, slot]
 

Same as fitSphere(), but with float parameters.

float flySpeed   const [inline]
 

Returns the current fly speed (used when mode() is FLY). Set with setFlySpeed(). Set to 0.5% of the sceneRadius in setSceneRadius().

void getCameraCoordinatesOf const qglviewer::Vec   src,
float    res[3]
const
 

Same as cameraCoordinatesOf(), but the result is returned in a float[3].

void getCameraCoordinatesOf const float    src[3],
float    res[3]
const
 

Same as cameraCoordinatesOf(), but the parameters are float[3].

void getModelViewMatrix GLfloat    m[16] const [virtual]
 

Set m to the current model view matrix. m is an array of 16 floats. Similar to a glLoadMatrixd(...) followed by a glGetFloatv(GL_MODELVIEW_MATRIX), but simply reads the internal matrix instead of calling openGL.

Attention:
If you call this function out of the classical drawing loop (QGLViewer::draw() or QGLViewer::postDraw()), you need to call computeModelViewMatrix() before this function, so that the model view matrix is properly updated.
Attention:
The result is an openGL 4x4 matrix, which is given in column-major order (see glMultMatrix man page for details).
See also:
getModelViewMatrix(GLdouble m[16])

void getModelViewMatrix GLdouble    m[16] const [virtual]
 

This function is provided for convenience, in case you want to work with double instead of floats, see getModelViewMatrix(GLfloat m[16]) for explanations.

void getOrientation float &    q0,
float &    q1,
float &    q2,
float &    q3
const
 

float version of orientation().

void getPosition float &    x,
float &    y,
float &    z
const
 

Same as position(), but with float parameters.

void getProjectedCoordinatesOf const float    src[3],
float    res[3]
const
 

float version of projectedCoordinatesOf().

void getProjectionMatrix GLfloat    m[16] const [virtual]
 

Set m to the current projection matrix. m is an array of 16 floats.

Attention:
glMatrixMode is set to GL_PROJECTION.
See also:
getProjectionMatrix(GLdouble m[16])

void getProjectionMatrix GLdouble    m[16] const [virtual]
 

This function is provided for convenience, in case you want to work with double instead of floats, see getProjectionMatrix(GLfloat m[16]) for explanations.

void getRevolveAroundPoint float &    x,
float &    y,
float &    z
const
 

float version of revolveAroundPoint().

void getSceneCenter float &    x,
float &    y,
float &    z
const [protected]
 

float version of sceneCenter().

void getUnprojectedCoordinatesOf const float    src[3],
float    res[3]
const
 

Same sa getUnprojectedCoordinatesOf(), but with float parameters.

void getUpVector float &    x,
float &    y,
float &    z
const
 

Same as upVector(), but with float parameters.

void getWorldCoordinatesOf const qglviewer::Vec   src,
float    res[3]
const
 

Same as worldCoordinatesOf(), but the result is returned in a float[3].

void getWorldCoordinatesOf const float    src[3],
float    res[3]
const
 

Same as worldCoordinatesOf(), but the parameters are float[3].

float horizontalFieldOfView   const [inline]
 

Returns the horizontal (X camera frame direction) field of view used by the camera (in degrees). Value is set using setHorizontalFieldOfView() or setFieldOfView(). The values are always linked by : horizontalFieldOfView() = fieldOfView() * Ratio().

void initFromDOMElement const QDomElement &    de [virtual]
 

Restore the Camera state from a QDomElement created by domElement(). See also KeyFrameInterpolator::initFromDOMElement(), Frame::initFromDOMElement().

float IODist   const [inline]
 

Returns the inter-ocular distance used for stereo. Value set using setIODist()

bool isManipulated   const [inline]
 

true when the camera is being manipulated by the user. Useful for switching to fast draw mode. See QGLViewer::fastDraw().

KeyFrameInterpolator * keyFrameInterpolator unsigned short    i const
 

Returns the current KeyFrameInterpolator that defines the camera path number i.

If the path is not defined for this index, the method returns a NULL pointer.

Attention:
index must be in the range 0..nbPaths()-1.

void loadModelViewMatrix bool    reset = true const [protected, virtual]
 

Load the current camera GL_MODELVIEW matrix.

When reset is true (default), it clears the previous projection matrix by calling glLoadMatrixd. Setting reset to false simply calls glMultMatrixd (migth be useful for some applications).

getModelViewMatrix() returns the current 4x4 model view matrix.

This function is protected, use QGLViewer::loadModelViewMatrix() to access it from your viewer.

Attention:
glMatrixMode is set to GL_MODELVIEW
makeCurrent() must be called by every calling method if this is used out of the main drawing loop (i.e. not needed in QGLViewer::draw() and QGLViewer::preDraw()).

void loadModelViewMatrixStereo bool    leftBuffer = true const [protected, virtual]
 

Load the GL_MODELVIEW matrix for stereo mode. It clears the previous modelview matrix by calling glLoadIdentity before setting the matrix. When leftBuffer is true (resp. false), it performs a left (resp. right) buffer translation by modifying the translation term directly in the modelView matrix.

Attention:
glMatrixMode is set to GL_MODELVIEW
makeCurrent() must be called by every calling method

void loadProjectionMatrix bool    reset = true const [protected, virtual]
 

Load the current camera GL_PROJECTION matrix. Default method set camera according to fieldOfView(), and window aspect ratio.

Uses zNear() and zFar() which are determined from sceneRadius() and sceneCenter() so that they best fit the scene size.

Camera type is returned by type(), and is set with setType().

When reset is true (default), it clears the previous projection matrix by calling glLoadIdentity before setting the matrix. Setting reset to false is usefull for GL_SELECT mode, to combine the matrix with a picking matrix.

getProjectionMatrix() returns the 4x4 projection matrix.

This function is protected, use QGLViewer::loadProjectionMatrix() to access it from your viewer.

Attention:
glMatrixMode is set to GL_PROJECTION
makeCurrent() must be called by every calling method.

void loadProjectionMatrixStereo bool    leftBuffer = true const [protected, virtual]
 

Load the current camera GL_PROJECTION matrix for Stereo mode. Only PERSPECTIVE camera type() case is handled.

Uses zNear() and zFar() which are determined from sceneRadius() and sceneCenter() so that they best fit the scene size.

Uses distanceToZeroParallaxPlane(), IODist(), and physicalScreenWidth() to compute cameras offset for stereovision, as well as assymetric frustums

Camera type is returned by type(), and is set with setType().

When leftBuffer is true (default), computes the projection matrix for left camera (right camera otherwise).

getProjectionMatrix() will always return the 4x4 mono projection matrix.

Attention:
glMatrixMode is set to GL_PROJECTION
makeCurrent() must be called by every calling method.

void lookAt float    x,
float    y,
float    z
[inline, slot]
 

Same as lookAt(), but with float parameters.

void lookAt const qglviewer::Vec   target [slot]
 

Set the camera orientation, so that it looks at point target (defined in the world coordinate system). The camera position is not modified. The camera is rotated so that the horizon is preserved. See also setOrientation(), showEntireScene(), fitSphere() and fitBBox().

ManipulatedFrame::Mode mode   const [inline]
 

Returns the value of frame mode, set by setMode() or toggleMode(). This mode determines the behavior or the camera when the mouse is moved.

void mouseDoubleClickEvent QMouseEvent *    e [protected, virtual]
 

When the user double clicks on the mouse :

Left button aligns the camera viewing direction to the closest axis (if any) with alignWithAxis(). position() is not modified.

Middle button places the camera so that the entire scene is visible (see showEntireScene() and setSceneRadius()).

Right button reset the camera position so that the sceneCenter() is projected in the middle of the window (orientation() is not modified).

int nbPaths   const [inline]
 

Returns the number of camera paths that can be defined. This is the maximum number of KeyFrameInterpolator that can be saved (index range is 0..nbPaths()-1), but some of them may not be defined (keyFrameInterpolator() will return NULL).

qglviewer::Quaternion orientation   const [inline]
 

Returns the camera current orientation, defined in the world coordinate system. Actually calls frame.orientation(). Use setOrientation() or lookAt() to set the camera orientation.

float physicalScreenWidth   const [inline]
 

Returns the physical screen width (used for stereo mode only). Value is set using setScreenWidth()

void playKeyFramePath int    i [slot]
 

Make the camera follw the key frame path number i. The key Frames are defined using addKeyFrame(). Use deleteKeyFramePath() to clear a path.

The default shortcut for this function is F[1-12]. Set setKeyFrameKey() and setPlayKeyFramePathStateKey().

See also keyFrameInterpolator() and setKeyFrameInterpolator() to directly define a complete path.

Vec pointUnderPixel const int    x,
const int    y,
bool &    found
 

Returns the coordinates of the 3D point located at pixel (x,y) on screen. Calls a glReadPixel to get the pixel depth and applies an unprojectedCoordinatesOf() to the result. found indicates whether a point was found or not (background pixel, result's depth is zFar()).

qglviewer::Vec position   const [inline]
 

Returns the camera position (the eye), defined in the world coordinate system. Actually calls worldCoordinatesOf(). Use setPosition() to set the camera position.

Vec projectedCoordinatesOf const qglviewer::Vec   src const
 

Returns the screen projected coordinates of a point src defined in the world coordinate system. See the gluProject man page for details. The x and y returned values are expressed in pixel, (0,0) being the lower left corner (QT QMouseEvent has (0,0) in the upper left corner).

This method is not computationnaly optimized. If you call it several times with no change in the matrices, you should buffer the entire projection matrix (modelview, projection and then viewport) to speed-up the queries. See the gluProject man page for details.

unprojectedCoordinatesOf() performs the inverse transformation.

Attention:
When used in conjunction with QGLViewer::startScreenCoordinatesSystem(), the computations of the projected coordinates must be done before entering the screen coordinate mode, as the camera matrix is no longer a 3D projection in this mode. See the screenCoordSystem example.
Attention:
If not used in QGLViewer::draw() or similar functions, call makeCurrent() and computeModelViewMatrix() before calling this function.

void restorePOV unsigned short    i = 0 [slot]
 

Restore the point of view saved with saveCurrentPOV().

Attention:
This function is deprecated use playKeyFramePath() instead.

qglviewer::Vec revolveAroundPoint   const [inline]
 

When the camera is in REVOLVE mode (see mode()), this is the point the camera revolves around. Default value is the sceneCenter(). Camera mode can be changed with toggleMode() or with setMode().

Attention:
setSceneCenter() changes this value.

void saveCurrentPOV unsigned short    i = 0 [slot]
 

The current camera Point Of View is saved, with an index i. Saved POV can be restored with restorePOV().

Attention:
This function is deprecated use addKeyFrame() instead.

qglviewer::Vec sceneCenter   const [inline, protected]
 

Returns the position of the scene center. This value is set by the QGLViewer. Default is 0,0,0 (world origin).

float sceneRadius   const [inline, protected]
 

Returns the scene radius used by the camera. Used to set the camera near and far planes (see zNear() and zFar()). This value is updated by the viewer through setSceneRadius().

int screenHeight   const [inline]
 

Returns the current height (in pixels) of the camera screen.

int screenWidth   const [inline]
 

Returns the current width (in pixels) of the camera screen.

void setCameraFromProjectionMatrix const float *const    m [slot]
 

m is the projection matrix as used in vision algorithm. It has 3 lines and 4 columns. It transforms a point in the world homogeneous coordinate system (4 coordinates: sx, sy, sz and s) in a point in the screen homogeneous coordinate system (3 coordinates: sx, sy, and s, where x and y are the pixel coordinates on the screen).

m is a pointer to the elements of the matrix ordered in line major order. If you define your matrix as a float matrix[3][4], you should call : setCameraFromProjectionMatrix(&(matrix[0][0]));

This code was written by Sylvain Paris (Sylvain.Paris@imag.fr).

void setConstraint Constraint   c [slot]
 

Attach a constraint to the camera frame. See the Constraint class documentation for details. This function actually set the same constraint to the camera frame (translation part) and to the camera.frame.referenceFrame() (rotationnal part).

void setDistanceToScreen float    dts [inline, slot]
 

Defines the distance in real world between the observer eyes and the screen -monitor or projection wall- in meters. Default value is 0.5m.

loadProjectionMatrixStereo() uses this value to define the camera offset and frustum.

void setDistanceToZeroParallaxPlane float    dtz [inline, slot]
 

Defines the distance in virtual world between the viewpoint and the plane where the horizontal parallax is null, that's to say where the stereo left and right images are superimposed.

loadProjectionMatrixStereo() uses this value to define the camera offset and frustum.

Attention:
This value is changed by QGLViewer::setSceneRadius(), setSceneRadius() and setFieldOfView(). When one of these values is modified, distanceToZeroParallaxPlane() is set to sceneRadius() / tan(fieldOfView()/2).

void setFieldOfView float    f [inline, slot]
 

Defines the vertical field of view of the camera (in degrees). Also used to fit the scene and mouse translations. fieldOfView() returns the current value. The default value is 45 degrees. loadProjectionMatrix() uses this value to define the camera.

The field of view corresponds the one used in gluPerspective (see manual). It set the Y (vertical) aperture of the camera. The X (horizontal) angle is infered from the window aspect ratio (see aspectRatio() and horizontalFieldOfView()).

distanceToZeroParallaxPlane() is set to sceneRadius() / tan(fieldOfView()/2) (used only for stereo mode, see QGLViewer::setStereo(), setSceneRadius() and setDistanceToZeroParallaxPlane()).

void setFlySpeed float    s [inline, slot]
 

When camera is in FLY mode (see mode()), tunes the speed of the displacement. Current value is given by flySpeed(). Note that is value is also set in setSceneRadius().

void setHorizontalFieldOfView float    hfov [inline, slot]
 

Defines the horizontal field of view of the camera (in degrees) by calling setFieldOfView() scaled by 1/aspectRatio() to keep consistency.

loadProjectionMatrixStereo() uses this value to define the camera offset and frustum.

void setIODist float    iod [inline, slot]
 

Defines the real inter-ocular distance(in meters). The default value used is 0.062, which fits most people.

loadProjectionMatrixStereo() uses this value to define the camera offset and frustum

void setKeyFrameInterpolator unsigned short    i,
qglviewer::KeyFrameInterpolator *const    kfi
[slot]
 

Changes the KeyFrameInterpolator that currently defines the camera path of index i. The previous keyFrameInterpolator() is lost and the pointer should be deleted by the calling function if needed:

  KeyFrameInterpolator* prevKFI = keyFrameInterpolator(3);
  setKeyFrameInterpolator(3, myKeyFrameInterpolator);
  delete prevKFI;

Attention:
Index i must be in the range 0..nbPaths()-1.

void setMode ManipulatedFrame::Mode    m [inline, slot]
 

Set the displacement mode of the camera, defined from ManipulatedFrame::Mode.

See the mouse behavior and customization HTML page for details.

void setOrientation float    theta,
float    phi
[slot]
 

Set the orientation of the camera as if it was located on a sphere, directed towards the revolveAroundPoint(), on a position defined by polar coordinates theta and phi (in radians). See also setUpVector().

theta=phi=0 means the camera is aligned with the frame Z axis. (theta rotates around Y, and then phi rotates around X).

void setOrientation float    q0,
float    q1,
float    q2,
float    q3
[inline, slot]
 

Same as setOrientation(), but with float parameters.

void setOrientation const qglviewer::Quaternion   q [slot]
 

Set the camera orientation, defined with respect to the world coordinate system. The current camera orientation can be obtained from orientation(). The camera position() is not modified by this function. See also lookAt() and setUpVector().

void setPhysicalScreenWidth float    sw [inline, slot]
 

Defines the width of the real screen (in meters). Typically 0.4m (default value) for a monitor and 10m for the cylindrical wall in Reality Center.

loadProjectionMatrixStereo() uses this value to define the camera offset and frustum.

void setPosition const qglviewer::Vec   pos [inline, slot]
 

Set the camera position (the eye), defined in the world coordinate system. The current camera position can be obtained from position().

void setPosition float    x,
float    y,
float    z
[inline, slot]
 

Same as setPosition(), but with float parameters.

void setRevolveAroundPoint float    x,
float    y,
float    z
[inline, slot]
 

float version of setRevolveAroundPoint().

void setRevolveAroundPoint const qglviewer::Vec   rap [slot]
 

Changes the revolveAroundPoint(), which defines the position (in world coordinates) of the 3D point the camera revolves around in REVOLVE camera mode (see mode() and setMode()). Current value can be get from revolveAroundPoint(). Default value is sceneCenter(), which default value is (0,0,0).

The zNear() and zFar() values are fitted to the scene, which will be entirely visible if revolveAroundPoint() is located inside a sceneRadius() sphere centered on sceneCenter().

The camera position and orientation are not modified so that the image displayed by the camera is not affected by the revolveAroundPoint() change.

Attention:
This value is modified by setSceneCenter().

void setRevolveAroundPointFromPixel int    x,
int    y
[slot]
 

The revolveAroundPoint() is set to the point located at pixel (x,y) on screen.

setRevolveAroundPoint() to the result of pointUnderPixel() (if a point was found). This function is binded to the left then right double simple click. See mouse page for details.

void setRevolveAroundPointToSceneCenter   [inline, slot]
 

See setRevolveAroundPoint() and sceneCenter(). Used by the ManipulatedFrame.

void setSceneBoundingBox const Vec   m,
const Vec   M
[slot]
 

Similar to setSceneRadius(), but the scene limits are defined by a bounding box.

void setSceneCenter float    x,
float    y,
float    z
[slot]
 

Same as setSceneCenter(), but with float parameters.

void setSceneCenter const qglviewer::Vec   sc [slot]
 

Changes the sceneCenter value (used for zNear() and zFar()). This value is set from QGLViewer::setSceneCenter().

Attention:
revolveAroundPoint() is set to sceneCenter() by this method. See setRevolveAroundPointToSceneCenter().

void setSceneCenterFromPixel int    x,
int    y
[slot]
 

setSceneCenter() to the result of pointUnderPixel() (if a point was found).

void setSceneRadius float    r [slot]
 

Scene radius (see sceneRadius()) scales axis and grid display and is used by zNear() and zFar(). Should be set according to the displayed scene radius. This value is updated by the viewer. Camera flySpeed() is set to 0.5% of this value.

distanceToZeroParallaxPlane() is set to sceneRadius()/tan(fieldOfView()/2) (used only for stereo mode, see QGLViewer::setStereo(), setFieldOfView() and setDistanceToZeroParallaxPlane()).

See also setSceneBoundingBox().

void setType Type    type [inline, slot]
 

Defines the camera type. Supported types are defined by the Type enum. loadProjectionMatrix() will create the camera accordingly. Use type() to get the current value.

     myViewer.camera.setType(qglviewer::Camera::ORTHO);

void setUpVector float    x,
float    y,
float    z,
bool    noMove = true
[inline, slot]
 

Same as setUpVector(), but with float parameters.

void setUpVector const qglviewer::Vec   up,
bool    noMove = true
[slot]
 

Rotate the camera such that its up vector becomes up, which is defined in the world coordinate system. Only the orientation of the camera is changed. The camera will be rotated around an axis orthogonal to up and to the current upVector() direction.

The noMove parameters controls whether the position() of the camera is changed or not. When noMove is set to true (default), the position() of the camera in the world coordinate system will remain the same, which is the intuitive behavior, especially in FLY mode (see mode()). Use this function in order to define the horizontal plane in FLY mode. See setMode() for details.

However it might be interesting to keep the revolveAroundPoint() (world origin by default) at the same position on screen. This can be achieved when noMove is set to false, and this is useful in the camera REVOLVE mode (see setMode()).

void setWindowWidthAndHeight int    w,
int    h
[protected, slot]
 

Update a copy of the viewer window dimension. Called by the QGLViewer when it is resized.

void setZNearCoef float    coef [inline, slot]
 

This value is used when the camera is inside the sceneRadius(), sceneCenter() sphere. The zNear() value is then set to zNearCoef() * sceneRadius(). Default value is 0.001, which is good for walkthrough applications. In case you need a high dynamic ZBuffer, you can increase this value (~0.1) so that the scene uses a wider range of Z values.

void showEntireScene   [slot]
 

Adjust the camera so that the entire scene is visible. The camera is first rotated to lookAt() sceneCenter(), and then translated (closer or further) to make the entire scene fit the window.

The scene is defined by sceneCenter() and sceneRadius().

You will typically use this function in QGLViewer::init() :

By default the sceneRadius() is 1.0, and the QGLViewer constructor calls this function. See also centerScene().

mouseDoubleClickEvent() calls this function after a middle button double click.

Attention:
As the camera lookAt() the sceneCenter(), a previous setOrientation() or setUpVector() of the camera will be lost. These functions should then be called after.

void toggleMode   [inline, slot]
 

Change camera mode (defined by the ManipulatedFrame::Mode enum), see mode() and setMode().

Type type   const [inline]
 

Returns the type of the camera used by the viewer. Set by setType(). Supported types are defined by the Type enum. Used by loadProjectionMatrix().

Vec unprojectedCoordinatesOf const qglviewer::Vec   src const
 

Returns the world unprojected coordinates of a point src defined in the screen coordinate system. The x and y input values are expressed in pixel, (0,0) being the lower left corner (QT QMouseEvent has (0,0) in the upper left corner). See the gluUnProject man page for details.

This method is not computationnaly optimized. If you call it several times with no change in the matrices, you should buffer the entire inverse projection matrix (modelview, projection and then viewport) to speed-up the queries. See the gluUnProject man page for details.

projectedCoordinatesOf() performs the inverse transformation.

Attention:
If not used in QGLViewer::draw() or similar functions, call makeCurrent() and computeModelViewMatrix() before calling this function.

Vec upVector   const
 

Return the current up vector of the camera, defined in the world coordinate system. See also setUpVector().

qglviewer::Vec viewDirection   const [inline]
 

Returns the normalized view direction of the camera (negative Z axis), defined in the world coordinate system.

qglviewer::Vec worldCoordinatesOf const qglviewer::Vec   src const [inline]
 

Returns the world coordinates of the point whose position is src, defined in the camera coordinate system. cameraCoordinatesOf() performs the inverse transformation.

float zFar   const [virtual]
 

Returns the zFar value used by the projection matrix. This value is fitted to sceneCenter() and sceneRadius() in order to ensure an optimal z sampling.

Attention:
The value is always positive and is the opposite of the camera frame actual value which is always negative. This is done in order to fit the gluPerspective positive standard.

float zNear   const [virtual]
 

Returns the zNear value used by the projection matrix. This value is fitted to sceneCenter() and sceneRadius() in order to ensure an optimal z sampling. Returned value is clipped when the camera is inside the scene sphere.

Attention:
The value is always positive and is the opposite of the camera frame actual value (always negative). This is done in order to fit the gluPerspective positive standard.

float zNearCoef   const [inline]
 

Returns the coefficient which is used to set ZNear() when the camera is inside the sceneRadius() sphere. Set with setZNearCoef().

void zoomOnPixel int    x,
int    y
[slot]
 

Make the camera zoom on the selected pixel (if an object is actually drawn, see pointUnderPixel()).

This function is binded to the middle then right double simple click. See mouse page for details. zoomOutFromPixel() performs (approximately) the inverse displacement.

void zoomOutFromPixel int    x,
int    y
[slot]
 

Make the camera zoom out.

This function is binded to the right then middle double simple click. See mouse page for details. zoomOnPixel() performs (approximately) the inverse displacement.


Member Data Documentation

qglviewer::ManipulatedFrame frame
 

The manipulated frame attached to the camera and which defines its position.


Generated on Thu Jan 16 12:53:47 2003 for libQGLViewer by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002