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 | |
Constraint * | constraint () |
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 ¢er, 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::KeyFrameInterpolator * | keyFrameInterpolator (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 |
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()).
|
The type of camera used by the viewer, set by setType(). This type will be use in loadProjectionMatrix().
|
|
Default values are given to the camera parameters : sceneCenter=0, sceneRadius=1, camera type = PERSPECTIVE, default stereo value, .... |
|
Virtual destructor. Empty. |
|
Moves the frame 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. |
|
Adds the current camera frame as a key frame to the path number 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. |
|
Returns the currents camera aspect ratio (screenWidth/screenHeight), determined from the QGLViewer() window size. |
|
Returns the camera frame coordinates of a point |
|
Adjust the camera so that the sceneCenter() is projected on the center of the window. See also showEntireScene(). |
|
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. |
|
Returns a pointer to the Constraint that is currently attached to the camera. See setConstraint(). |
|
Deletes the KeyFrameInterpolator of index |
|
Returns the distance from the camera center to sceneCenter(). Used by zNear() and zFar() to optimize the Z range. |
|
Returns the physical distance to screen (used for stereo mode only). Value is set using setDistanceToScreen() |
|
Returns the distance to 0 parallax plane (used for stereo mode only). Value is set using setDistanceToZeroParallaxPlane() |
|
Creates an XML QDomElement that represents the Camera. 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(); 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); |
|
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. |
|
Returns the vertical field of view of the camera (in degrees). Value is set using setFieldOfView(). |
|
Set the camera so that the bounding box
|
|
Place camera so that the sphere ( |
|
Same as fitSphere(), but with float parameters. |
|
Returns the current fly speed (used when mode() is FLY). Set with setFlySpeed(). Set to 0.5% of the sceneRadius in setSceneRadius(). |
|
Same as cameraCoordinatesOf(), but the result is returned in a float[3]. |
|
Same as cameraCoordinatesOf(), but the parameters are float[3]. |
|
Set
|
|
This function is provided for convenience, in case you want to work with double instead of floats, see getModelViewMatrix(GLfloat m[16]) for explanations. |
|
float version of orientation(). |
|
Same as position(), but with float parameters. |
|
float version of projectedCoordinatesOf(). |
|
Set
|
|
This function is provided for convenience, in case you want to work with double instead of floats, see getProjectionMatrix(GLfloat m[16]) for explanations. |
|
float version of revolveAroundPoint(). |
|
float version of sceneCenter(). |
|
Same sa getUnprojectedCoordinatesOf(), but with float parameters. |
|
Same as upVector(), but with float parameters. |
|
Same as worldCoordinatesOf(), but the result is returned in a float[3]. |
|
Same as worldCoordinatesOf(), but the parameters are float[3]. |
|
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(). |
|
Restore the Camera state from a QDomElement created by domElement(). See also KeyFrameInterpolator::initFromDOMElement(), Frame::initFromDOMElement(). |
|
Returns the inter-ocular distance used for stereo. Value set using setIODist() |
|
|
|
Returns the current KeyFrameInterpolator that defines the camera path number
If the path is not defined for this index, the method returns a
|
|
Load the current camera GL_MODELVIEW matrix.
When getModelViewMatrix() returns the current 4x4 model view matrix. This function is protected, use QGLViewer::loadModelViewMatrix() to access it from your viewer.
|
|
Load the GL_MODELVIEW matrix for stereo mode. It clears the previous modelview matrix by calling
|
|
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 getProjectionMatrix() returns the 4x4 projection matrix. This function is protected, use QGLViewer::loadProjectionMatrix() to access it from your viewer.
|
|
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 getProjectionMatrix() will always return the 4x4 mono projection matrix.
|
|
Same as lookAt(), but with float parameters. |
|
Set the camera orientation, so that it looks at point |
|
Returns the value of frame mode, set by setMode() or toggleMode(). This mode determines the behavior or the camera when the mouse is moved. |
|
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). |
|
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.. |
|
Returns the camera current orientation, defined in the world coordinate system. Actually calls |
|
Returns the physical screen width (used for stereo mode only). Value is set using setScreenWidth() |
|
Make the camera follw the key frame path number 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. |
|
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. |
|
Returns the camera position (the eye), defined in the world coordinate system. Actually calls worldCoordinatesOf(). Use setPosition() to set the camera position. |
|
Returns the screen projected coordinates of a point
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 unprojectedCoordinatesOf() performs the inverse transformation.
|
|
Restore the point of view saved with saveCurrentPOV().
|
|
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().
|
|
The current camera Point Of View is saved, with an index
|
|
Returns the position of the scene center. This value is set by the QGLViewer. Default is 0,0,0 (world origin). |
|
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(). |
|
Returns the current height (in pixels) of the camera screen. |
|
Returns the current width (in pixels) of the camera screen. |
|
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 This code was written by Sylvain Paris (Sylvain.Paris@imag.fr). |
|
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). |
|
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. |
|
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.
|
|
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 distanceToZeroParallaxPlane() is set to sceneRadius() / tan(fieldOfView()/2) (used only for stereo mode, see QGLViewer::setStereo(), setSceneRadius() and setDistanceToZeroParallaxPlane()). |
|
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(). |
|
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. |
|
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 |
|
Changes the KeyFrameInterpolator that currently defines the camera path of index KeyFrameInterpolator* prevKFI = keyFrameInterpolator(3); setKeyFrameInterpolator(3, myKeyFrameInterpolator); delete prevKFI;
|
|
Set the displacement mode of the camera, defined from ManipulatedFrame::Mode. See the mouse behavior and customization HTML page for details. |
|
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=phi=0 means the camera is aligned with the frame Z axis. ( |
|
Same as setOrientation(), but with float parameters. |
|
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(). |
|
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. |
|
Set the camera position (the eye), defined in the world coordinate system. The current camera position can be obtained from position(). |
|
Same as setPosition(), but with float parameters. |
|
float version of setRevolveAroundPoint(). |
|
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.
|
|
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. |
|
See setRevolveAroundPoint() and sceneCenter(). Used by the ManipulatedFrame. |
|
Similar to setSceneRadius(), but the scene limits are defined by a bounding box. |
|
Same as setSceneCenter(), but with |
|
Changes the sceneCenter value (used for zNear() and zFar()). This value is set from QGLViewer::setSceneCenter().
|
|
setSceneCenter() to the result of pointUnderPixel() (if a point was found). |
|
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(). |
|
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); |
|
Same as setUpVector(), but with float parameters. |
|
Rotate the camera such that its up vector becomes
The
However it might be interesting to keep the revolveAroundPoint() (world origin by default) at the same position on screen. This can be achieved when |
|
Update a copy of the viewer window dimension. Called by the QGLViewer when it is resized. |
|
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. |
|
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() : setSceneRadius(3.0); showEntireScene(); 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.
|
|
Change camera mode (defined by the ManipulatedFrame::Mode enum), see mode() and setMode(). |
|
Returns the type of the camera used by the viewer. Set by setType(). Supported types are defined by the Type enum. Used by loadProjectionMatrix(). |
|
Returns the world unprojected coordinates of a point
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 projectedCoordinatesOf() performs the inverse transformation.
|
|
Return the current up vector of the camera, defined in the world coordinate system. See also setUpVector(). |
|
Returns the normalized view direction of the camera (negative Z axis), defined in the world coordinate system. |
|
Returns the world coordinates of the point whose position is |
|
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.
|
|
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.
|
|
Returns the coefficient which is used to set ZNear() when the camera is inside the sceneRadius() sphere. Set with setZNearCoef(). |
|
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. |
|
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. |
|
The manipulated frame attached to the camera and which defines its position. |