Position and orientation | |
Vec | position () const |
Vec | upVector () const |
Vec | viewDirection () const |
Quaternion | orientation () const |
void | setFromProjectionMatrix (const float matrix[12]) |
void | setPosition (const Vec &pos) |
void | setOrientation (const Quaternion &q) |
void | setOrientation (float theta, float phi) |
void | setUpVector (const Vec &up, bool noMove=true) |
void | setViewDirection (const Vec &direction) |
Frustum parameters | |
Type | type () const |
float | fieldOfView () const |
float | horizontalFieldOfView () const |
float | aspectRatio () const |
int | screenWidth () const |
int | screenHeight () const |
void | getViewport (GLint viewport[4]) const |
float | pixelGLRatio (const Vec &pos) const |
float | zNearCoefficient () const |
float | zClippingCoefficient () const |
virtual float | zNear () const |
virtual float | zFar () const |
virtual void | getOrthoWidthHeight (GLdouble &halfWidth, GLdouble &halfHeight) const |
void | setType (Type type) |
void | setFieldOfView (float fov) |
void | setHorizontalFieldOfView (float hfov) |
void | setFOVToFitScene () |
void | setAspectRatio (float aspect) |
void | setScreenWidthAndHeight (int width, int height) |
void | setZNearCoefficient (float coef) |
void | setZClippingCoefficient (float coef) |
Scene radius and center | |
float | sceneRadius () const |
Vec | sceneCenter () const |
float | distanceToSceneCenter () const |
void | setSceneRadius (float radius) |
void | setSceneCenter (const Vec ¢er) |
bool | setSceneCenterFromPixel (const QPoint &pixel) |
void | setSceneBoundingBox (const Vec &min, const Vec &max) |
Revolve Around Point | |
Vec | revolveAroundPoint () const |
void | setRevolveAroundPoint (const Vec &rap) |
bool | setRevolveAroundPointFromPixel (const QPoint &pixel) |
Associated frame | |
ManipulatedCameraFrame * | frame () const |
void | setFrame (ManipulatedCameraFrame *const mcf) |
KeyFramed paths | |
KeyFrameInterpolator * | keyFrameInterpolator (int i) const |
void | setKeyFrameInterpolator (int i, KeyFrameInterpolator *const kfi) |
virtual void | addKeyFrameToPath (int i) |
virtual void | playPath (int i) |
virtual void | deletePath (int i) |
virtual void | resetPath (int i) |
virtual void | drawAllPaths () |
OpenGL matrices | |
virtual void | loadProjectionMatrix (bool reset=true) const |
virtual void | loadModelViewMatrix (bool reset=true) const |
void | computeProjectionMatrix () const |
void | computeModelViewMatrix () const |
virtual void | loadProjectionMatrixStereo (bool leftBuffer=true) const |
virtual void | loadModelViewMatrixStereo (bool leftBuffer=true) const |
void | getProjectionMatrix (GLdouble m[16]) const |
void | getModelViewMatrix (GLdouble m[16]) const |
World to Camera coordinate systems conversions | |
Vec | cameraCoordinatesOf (const Vec &src) const |
Vec | worldCoordinatesOf (const Vec &src) const |
void | getCameraCoordinatesOf (const float src[3], float res[3]) const |
void | getWorldCoordinatesOf (const float src[3], float res[3]) const |
2D screen to 3D world coordinate systems conversions | |
Vec | projectedCoordinatesOf (const Vec &src, const Frame *frame=NULL) const |
Vec | unprojectedCoordinatesOf (const Vec &src, const Frame *frame=NULL) const |
void | getProjectedCoordinatesOf (const float src[3], float res[3], const Frame *frame=NULL) const |
void | getUnprojectedCoordinatesOf (const float src[3], float res[3], const Frame *frame=NULL) const |
void | convertClickToLine (const QPoint &pixel, Vec &orig, Vec &dir) const |
Vec | pointUnderPixel (const QPoint &pixel, bool &found) const |
Drawing | |
virtual void | draw (bool fitNearPlane=false) const |
static void | drawCamera (float scale=1.0, float aspectRatio=1.33, float fieldOfView=M_PI/4.0) |
Fly speed | |
float | flySpeed () const |
void | setFlySpeed (float speed) |
Stereo parameters | |
float | IODistance () const |
float | physicalDistanceToScreen () const |
float | physicalScreenWidth () const |
float | focusDistance () const |
void | setIODistance (float distance) |
void | setPhysicalDistanceToScreen (float distance) |
void | setPhysicalScreenWidth (float width) |
void | setFocusDistance (float distance) |
XML representation | |
virtual QDomElement | domElement (const QString &name, QDomDocument &document) const |
virtual void | initFromDOMElement (const QDomElement &element) |
Positioning tools | |
void | lookAt (const Vec &target) |
void | showEntireScene () |
void | fitSphere (const Vec ¢er, float radius) |
void | fitBoundingBox (const Vec &min, const Vec &max) |
void | fitScreenRegion (const QRect &rectangle) |
void | centerScene () |
void | interpolateToZoomOnPixel (const QPoint &pixel) |
void | interpolateToFitScene () |
Public Types | |
enum | Type { PERSPECTIVE, ORTHOGRAPHIC } |
Public Member Functions | |
Camera () | |
virtual | ~Camera () |
Camera (const Camera &camera) | |
Camera & | operator= (const Camera &camera) |
A Camera defines some intrinsic parameters (fieldOfView(), position(), viewDirection(), upVector()...) and useful positioning tools that ease its placement (showEntireScene(), fitSphere(), lookAt()...). It exports its associated OpenGL projection and modelview matrices and can interactively be modified using the mouse.
The position() and orientation() of the Camera are defined by a ManipulatedCameraFrame (retrieved using frame()). These methods are just convenient wrappers to the equivalent Frame methods. This also means that the Camera frame() can be attached to a Frame::referenceFrame() which enables complex Camera setups.
Different displacements can be performed using the mouse. The list of possible actions is defined by the QGLViewer::MouseAction enum. Use QGLViewer::setMouseBinding() to attach a specific action to an arbitrary mouse button-state key binding. These actions are detailed in the mouse page.
The default button binding are: ROTATE (left), ZOOM (middle) and TRANSLATE (right). With this configuration, the Camera observes a scene and rotates around its revolveAroundPoint(). You can switch between this mode and a fly mode using the CAMERA_MODE (see QGLViewer::toggleCameraMode()) keyboard shortcut (default is 'Space').
The type() of the Camera can be Camera::ORTHOGRAPHIC or Camera::PERSPECTIVE (see Type()). fieldOfView() is meaningless with Camera::ORTHOGRAPHIC.
The near and far planes of the Camera are fitted to the scene and determined from QGLViewer::sceneRadius(), QGLViewer::sceneCenter() and zClippingCoefficient() by the zNear() and zFar() methods. Reasonable values on the scene extends hence have to be provided to the QGLViewer in order for the Camera to correctly display the scene. High level positioning methods also use this information (showEntireScene(), centerScene()...).
A Camera holds KeyFrameInterpolator that can be used to save Camera positions and paths. You can interactively addKeyFrameToPath() to a given path using the default Alt+F
[1-12] shortcuts. Use playPath() to make the Camera follow the path (default shortcut is F[1-12]). See the keyboard page for details on key customization.
Use cameraCoordinatesOf() ans worldCoordinatesOf() to convert to and from the Camera frame() coordinate system. projectedCoordinatesOf() and unprojectedCoordinatesOf() will convert from screen to 3D coordinates. convertClickToLine() is very useful for analytical object selection.
Stereo display is possible on machines with quad buffer capabilities (with Camera::PERSPECTIVE type() only). Test the stereoViewer example to check.
A Camera can also be used outside of a QGLViewer or even without OpenGL for its coordinate system conversion capabilities. Note however that some of them explicitly rely on the presence of a Z-buffer.
|
Enumerates the two possible types of Camera. See type() and setType(). This type mainly defines different Camera projection matrix (see loadProjectionMatrix()). Many other methods (pointUnderPixel(), convertClickToLine(), projectedCoordinatesOf(), ...) take this Type into account. |
|
Default constructor.
sceneCenter() is set to (0,0,0) and sceneRadius() is set to 1.0. type() is Camera::PERSPECTIVE, with a See IODistance(), physicalDistanceToScreen(), physicalScreenWidth() and focusDistance() documentations for default stereo parameter values. |
|
Virtual destructor. The frame() is deleted, but the different keyFrameInterpolator() are not deleted (in case they are shared). |
|
Copy constructor. Performs a deep copy using operator=(). |
|
Adds the current Camera position() and orientation() as a keyFrame to the path number This method can also be used if you simply want to save a Camera point of view (a path made of a single keyFrame). Use playPath() to make the Camera play the keyFrame path (resp. restore the point of view). Use deletePath() to clear the path. The default keyboard shortcut for this method is Alt+F[1-12]. Set QGLViewer::pathKey() and QGLViewer::addKeyFrameStateKey(). If you use directly this method and the keyFrameInterpolator(i) does not exist, a new one is created. Its KeyFrameInterpolator::interpolated() signal should then be connected to the QGLViewer::updateGL() slot (see setKeyFrameInterpolator()). |
|
Returns the Camera aspect ratio defined by screenWidth() / screenHeight(). When the Camera is attached to a QGLViewer, these values and hence the aspectRatio() are automatically fitted to the viewer's window aspect ratio using setScreenWidthAndHeight(). |
|
Returns the Camera frame coordinates of a point worldCoordinatesOf() performs the inverse transformation. Note that the point coordinates are simply converted in a different coordinate system. They are not projected on screen. Use projectedCoordinatesOf() for that. |
|
Moves the Camera so that its sceneCenter() is projected on the center of the window. The orientation() and fieldOfView() are unchanged. Simply projects the current position on a line passing through sceneCenter(). See also showEntireScene(). |
|
Computes the modelView matrix associated with the Camera's position() and orientation(). This matrix converts from the world coordinates system to the Camera coordinates system, and is applied just before the projection matrix when points are projected on screen. Use getModelViewMatrix() to retrieve this matrix. You must call this method if your Camera is not associated with a QGLViewer and is used for offscreen computations ((un)projectedCoordinatesOf() for instance). loadModelViewMatrix() does it otherwise. |
|
Computes the projection matrix associated with the Camera.
If type() is Camera::PERSPECTIVE, defines a
If type() is Camera::ORTHOGRAPHIC, the projection matrix is as what Both types use zNear() and zFar() to place clipping planes. These values are determined from sceneRadius() and sceneCenter() so that they best fit the scene size. Use getProjectionMatrix() to retrieve this matrix. Overload loadProjectionMatrix() if you want your Camera to use an exotic projection matrix. You must call this method if your Camera is not associated with a QGLViewer and is used for offscreen computations ((un)projectedCoordinatesOf() for instance). loadProjectionMatrix() does it otherwise. |
|
Gives the coefficients of a 3D half-line passing through the Camera eye and pixel (x,y).
The origin of the half line (eye position) is stored in
This method is useful for analytical intersection in a selection method. See the select example for an illustration. |
|
Deletes the keyFrameInterpolator() of index Disconnect the keyFrameInterpolator() KeyFrameInterpolator::interpolated() signal before deleting the keyFrameInterpolator() if needed: disconnect(camera()->keyFrameInterpolator(i), SIGNAL(interpolated()), this, SLOT(updateGL())); camera()->deletePath(i); |
|
Returns the distance from the Camera center to sceneCenter(), projected along the Camera Z axis. Used by zNear() and zFar() to optimize the Z range. |
|
Returns an XML
Concatenates the Camera parameters, the ManipulatedCameraFrame::domElement() and the paths' KeyFrameInterpolator::domElement().
Use initFromDOMElement() to restore the Camera state from the resulting If you want to save the Camera state in a file, use: QDomDocument document("myCamera"); doc.appendChild( myCamera->domElement("Camera", document) ); QFile f("myCamera.xml"); if (f.open(IO_WriteOnly)) { QTextStream out(&f); document.save(out, 2); } Note that the QGLViewer::camera() is automatically saved by QGLViewer::saveStateToFile() when a QGLViewer is closed. Use QGLViewer::restoreStateFromFile() to restore it back. |
|
Draws a representation of the Camera. Simply uses drawCamera() with the actual parameters of the Camera.
This method assumes that the
When
|
|
Draws all the Camera paths defined by the keyFrameInterpolator().
Simply calls KeyFrameInterpolator::drawPath() for all the defined paths. The path color is the current
|
|
Draws a perspective Camera shape (frustum and up vector arrow).
The Camera is classically looking down the negative Z axis, with an up vector along the Y axis. Its projection center is at coordinates (0,0,0). Modify the
The current |
|
Returns the vertical field of view of the Camera (in radians). Value is set using setFieldOfView(). Default value is pi/4 radians. This value is meaningless if the Camera type() is Camera::ORTHOGRAPHIC.
The field of view corresponds the one used in Use setFOVToFitScene() to adapt the fieldOfView() to a given scene. |
|
Moves the Camera so that the (world axis aligned) bounding box ( |
|
Moves the Camera so that the rectangular screen region defined by
The Camera is translated (its orientation() is unchanged) so that |
|
Moves the Camera so that the sphere defined by ( The Camera is simply translated along its viewDirection() so that the sphere fits the screen. Its orientation() and its fieldOfView() are unchanged. You should therefore orientate the Camera before you call this method. See lookAt(), setOrientation() and setUpVector(). |
|
Returns the fly speed of the Camera. Simply returns frame()->flySpeed(). See the ManipulatedCameraFrame::flySpeed() documentation. This value is only meaningful when the MouseAction bindings is MOVE_FORWARD or MOVE_BACKWARD. Set to 0.5% of the sceneRadius() by setSceneRadius(). See also setFlySpeed(). |
|
Returns the focus distance used by stereo display, expressed in OpenGL units. This is the distance in the virtual world between the Camera and the plane where the horizontal stereo parallax is null (the stereo left and right images are superimposed). This distance is the virtual world equivalent of the real-world physicalDistanceToScreen().
|
|
Returns the ManipulatedCameraFrame attached to the Camera. This ManipulatedCameraFrame defines its position() and orientation() and can translate mouse events into Camera displacement. Set using setFrame(). |
|
Same as cameraCoordinatesOf(), but with |
|
Fills First calls computeModelViewMatrix() to define the Camera modelView matrix.
Note that this matrix is usually not the one you would get from a
The result is an OpenGL 4x4 matrix, which is given in column-major order (see See also getProjectionMatrix(). |
|
Returns the 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: |
|
Same as projectedCoordinatesOf(), but with |
|
Fills Calls computeProjectionMatrix() to define the Camera projection matrix.
This matrix only reflects the Camera's internal parameters, and can differ from the
The result is an OpenGL 4x4 matrix, which is given in column-major order (see See also getModelViewMatrix(). |
|
Same as unprojectedCoordinatesOf(), but with |
|
Fills
This method is mainly used in conjunction with |
|
Same as worldCoordinatesOf(), but with |
|
Returns the horizontal field of view of the Camera (in radians). Value is set using setHorizontalFieldOfView() or setFieldOfView(). These values are always linked by: horizontalFieldOfView() = 2.0 * atan ( tan(fieldOfView()/2.0) * aspectRatio() ). |
|
Restores the Camera state from a Use the following code to retrieve a Camera state from a file created using domElement(): // Load DOM from file QDomDocument document; QFile f("myCamera.xml"); if (f.open(IO_ReadOnly)) { document.setContent(&f); f.close(); } // Parse the DOM tree QDomElement main = document.documentElement(); myCamera->initFromDOMElement(main); The frame() pointer is not modified by this method. The frame() state is however modified. The sceneRadius() and sceneCenter() are not part of the domElement() and are hence not modified by this method.
|
|
Interpolates the Camera on a one second KeyFrameInterpolator path so that the entire scene fits the screen at the end. The scene is defined by its sceneCenter() and its sceneRadius(). See showEntireScene(). The orientation() of the Camera is not modified. See also interpolateToZoomOnPixel(). |
|
Makes the Camera smoothly zoom on the pointUnderPixel()
Nothing happens if no pointUnderPixel() is found. Otherwise a KeyFrameInterpolator is created that animates the Camera on a one second path that brings the Camera closer to the point under See also interpolateToFitScene(). |
|
Returns the user's inter-ocular distance (in meters). Default value is 0.062m, which fits most people. loadProjectionMatrixStereo() uses this value to define the Camera offset and frustum. See setIODistance(). |
|
Returns the KeyFrameInterpolator that defines the Camera path number
If path |
|
Loads the OpenGL Calls computeModelViewMatrix() to compute the Camera's modelView matrix.
This method is used by QGLViewer::preDraw() (called before user's QGLViewer::draw() method) to set the
As a result, the vertices used in QGLViewer::draw() can be defined in the so called world coordinate system. They are multiplied by this matrix to get converted to the Camera coordinate system, before getting projected using the
When Overload this method or simply call glLoadMatrixd() at the beginning of QGLViewer::draw() if you want your Camera to use an exotic modelView matrix. See also loadProjectionMatrix(). getModelViewMatrix() returns the 4x4 modelView matrix.
|
|
Same as loadModelViewMatrix() but for a stereo setup. Only the Camera::PERSPECTIVE type() is supported for stereo mode. See QGLViewer::setStereoDisplay(). The modelView matrix is almost identical to the mono-vision one. It is simply translated along its horizontal axis by a value that depends on stereo parameters (see focusDistance(), IODistance(), and physicalScreenWidth()).
When loadProjectionMatrixStereo() explains how to retrieve to resulting matrix. See the stereoViewer and the anaglyph examples for an illustration.
|
|
Loads the OpenGL The Camera projection matrix is computed using computeProjectionMatrix().
When
This method is used by QGLViewer::preDraw() (called before user's QGLViewer::draw() method) to set the Use getProjectionMatrix() to retrieve this matrix. Overload this method if you want your Camera to use an exotic projection matrix. See also loadModelViewMatrix().
|
|
Same as loadProjectionMatrix() but for a stereo setup. Only the Camera::PERSPECTIVE type() is supported for stereo mode. See QGLViewer::setStereoDisplay(). Uses focusDistance(), IODistance(), and physicalScreenWidth() to compute cameras offset and asymmetric frustums.
When See the stereoViewer and the anaglyph examples for an illustration. To retrieve this matrix, use a code like: glMatrixMode(GL_PROJECTION); glPushMatrix(); loadProjectionMatrixStereo(left_or_right); glGetFloatv(GL_PROJECTION_MATRIX, m); glPopMatrix();
|
|
Sets the Camera orientation(), so that it looks at point The Camera position() is not modified. Simply setViewDirection(). See also setUpVector(), setOrientation(), showEntireScene(), fitSphere() and fitBoundingBox(). |
|
Equal operator.
All the parameters of
|
|
Returns the Camera orientation, defined in the world coordinate system.
Actually returns |
|
Returns the physical distance between the user's eyes and the screen (in meters). Default value is 0.5m. Used by loadModelViewMatrixStereo() and loadProjectionMatrixStereo() for stereo display. Value is set using setPhysicalDistanceToScreen(). physicalDistanceToScreen() and focusDistance() represent the same distance. The first one is expressed in physical real world units, while the latter is expressed in OpenGL virtual world units. Use their ratio to convert distances between these worlds. Use the following code to detect a reality center configuration (using its screen aspect ratio) and to automatically set physical distances accordingly: QDesktopWidget screen; if (fabs((float)screen.width() / (float)screen.height()) > 2.0) { camera()->setPhysicalDistanceToScreen(4.0); camera()->setPhysicalScreenWidth(10.0); } |
|
Returns the physical screen width, in meters. Default value is 0.4m (average monitor). Used for stereo display only (see loadModelViewMatrixStereo() and loadProjectionMatrixStereo()). Set using setPhysicalScreenWidth(). See physicalDistanceToScreen() for reality center automatic configuration. |
|
Returns the ratio between pixel and OpenGL units.
A line of Use this method to scale objects so that they have a constant pixel size on screen. The following code will draw a 20 pixel line, starting at sceneCenter() and always directed along the screen vertical direction: glBegin(GL_LINES); glVertex3fv(sceneCenter()); glVertex3fv(sceneCenter() + 20 * pixelGLRatio(sceneCenter()) * camera()->upVector()); glEnd(); |
|
Makes the Camera follow the path of keyFrameInterpolator() number If the interpolation is started, it stops it instead. This method silently ignores undefined (empty) paths (see keyFrameInterpolator()). The default keyboard shortcut for this method is F[1-12]. Set QGLViewer::pathKey() and QGLViewer::playPathStateKey(). |
|
Returns the coordinates of the 3D point located at pixel (x,y) on screen.
Calls a
|
|
Returns the Camera position (the eye), defined in the world coordinate system.
Use setPosition() to set the Camera position. Other convenient methods are showEntireScene() or fitSphere(). Actually returns This position corresponds to the projection center of a Camera::PERSPECTIVE Camera. It it not located in the image plane, which is at a zNear() distance ahead. |
|
Returns the screen projected coordinates of a point
When
The x and y coordinates of the returned Vec are expressed in pixel, (0,0) being the upper left corner of the window. The z coordinate ranges between 0.0 (near plane) and 1.0 (excluded, far plane). See the unprojectedCoordinatesOf() performs the inverse transformation. See the screenCoordSystem example.
This method only uses the intrinsic Camera parameters (see getModelViewMatrix(), getProjectionMatrix() and getViewport()) and is completely independent of the OpenGL
|
|
Resets the path of the keyFrameInterpolator() number If this path is not being played (see playPath() and KeyFrameInterpolator::interpolationIsStarted()), resets it to is its starting position (see KeyFrameInterpolator::resetInterpolation()). If the path is played, simply stops interpolation. |
|
The point the Camera revolves around with the ROTATE mouse binding. Defined in world coordinate system. Default value is the sceneCenter().
|
|
Returns the position of the scene center, defined in the world coordinate system. The scene observed by the Camera should be roughly centered on this position, and included in a sceneRadius() sphere. This approximate description of the scene permits a zNear() and zFar() clipping planes definition, and allows convenient positioning methods such as showEntireScene(). Default value is (0,0,0) (world origin). Use setSceneCenter() to change it. See also setSceneBoundingBox(). Note that QGLViewer::sceneCenter() (resp. QGLViewer::setSceneCenter()) simply call this method (resp. setSceneCenter()) on its associated QGLViewer::camera(). |
|
Returns the radius of the scene observed by the Camera. You need to provide such an approximation of the scene dimensions so that the Camera can adapt its zNear() and zFar() values. See the sceneCenter() documentation. See also setSceneBoundingBox(). Note that QGLViewer::sceneRadius() (resp. QGLViewer::setSceneRadius()) simply call this method (resp. setSceneRadius()) on its associated QGLViewer::camera(). |
|
Returns the height (in pixels) of the Camera screen. Set using setScreenWidthAndHeight(). This value is automatically fitted to the QGLViewer's window dimensions when the Camera is attached to a QGLViewer. See also QGLWidget::height() |
|
Returns the width (in pixels) of the Camera screen. Set using setScreenWidthAndHeight(). This value is automatically fitted to the QGLViewer's window dimensions when the Camera is attached to a QGLViewer. See also QGLWidget::width() |
|
Defines the Camera aspectRatio(). This value is actually inferred from the screenWidth() / screenHeight() ratio. You should use setScreenWidthAndHeight() instead. This method might however be convenient when the Camera is not associated with a QGLViewer. It actually sets the screenHeight() to 100 and the screenWidth() accordingly. See also setFOVToFitScene().
|
|
Sets the vertical fieldOfView() of the Camera (in radians). Note that focusDistance() is set to sceneRadius() / tan(fieldOfView()/2) by this method. |
|
Sets the Camera flySpeed().
|
|
Sets the focusDistance(), in OpenGL scene units. |
|
Changes the Camera fieldOfView() so that the entire scene (defined by QGLViewer::sceneCenter() and QGLViewer::sceneRadius()) is visible from the Camera position(). The position() and orientation() of the Camera are not modified and you first have to orientate the Camera in order to actually see the scene (see lookAt(), showEntireScene() or fitSphere()). This method is especially useful for shadow maps computation. Use the Camera positioning tools (setPosition(), lookAt()) to position a Camera at the light position. Then use this method to define the fieldOfView() so that the shadow map resolution is optimally used: // The light camera needs size hints in order to optimize its fieldOfView lightCamera->setSceneRadius(sceneRadius()); lightCamera->setSceneCenter(sceneCenter()); // Place the light camera. lightCamera->setPosition(lightFrame->position()); lightCamera->lookAt(sceneCenter()); lightCamera->setFOVToFitScene(); See the (soon available) shadowMap contribution example for a practical implementation.
|
|
Sets the Camera frame(). If you want to move the Camera, use setPosition() and setOrientation() or one of the Camera positioning methods (lookAt(), fitSphere(), showEntireScene()...) instead. If you want to save the Camera position(), there's no need to call this method either. Use addKeyFrameToPath() and playPath() instead. This method is actually mainly useful if you derive the ManipulatedCameraFrame class and want to use an instance of your new class to move the Camera.
A |
|
Defines the Camera position(), orientation() and fieldOfView() from a projection matrix.
Its three lines correspond to the homogeneous coordinates of the normals to the planes x=0, y=0 and z=0, defined in the Camera coordinate system.
The elements of the matrix are ordered in line major order: you can call
|
|
Sets the horizontalFieldOfView() of the Camera (in radians). horizontalFieldOfView() and fieldOfView() are linked by the aspectRatio(). This method actually calls setFieldOfView(( 2.0 * atan (tan(hfov / 2.0) / aspectRatio()) )) so that a call to horizontalFieldOfView() returns the expected value. |
|
Sets the IODistance(). |
|
Sets the KeyFrameInterpolator that defines the Camera path of index The previous keyFrameInterpolator() is lost and should be deleted by the calling method if needed.
The KeyFrameInterpolator::interpolated() signal of myViewer.camera()->deletePath(3); myViewer.camera()->setKeyFrameInterpolator(3, myKeyFrameInterpolator); connect(myKeyFrameInterpolator, SIGNAL(interpolated()), myViewer, SLOT(updateGL());
|
|
Sets the orientation() of the Camera using polar coordinates.
See also setUpVector(). The position() of the Camera is unchanged, you may want to call showEntireScene() after this method to move the Camera. This method can be useful to create Quicktime VR panoramic sequences, see the QGLViewer::saveSnapshot() documentation for details. |
|
Sets the Camera orientation(), defined in the world coordinate system. |
|
Sets the physicalDistanceToScreen(). |
|
Sets the physical screen (monitor or projected wall) width (in meters). |
|
Sets the Camera position() (the eye), defined in the world coordinate system. |
|
Changes the revolveAroundPoint() to |
|
The revolveAroundPoint() is set to the point located under
Returns
See also setSceneCenterFromPixel(). |
|
Similar to setSceneRadius() and setSceneCenter(), but the scene limits are defined by a (world axis aligned) bounding box. |
|
Sets the sceneCenter().
|
|
setSceneCenter() to the result of pointUnderPixel(
Returns See also setRevolveAroundPointFromPixel(). See the pointUnderPixel() documentation. |
|
Sets the sceneRadius() value. Negative values are ignored.
|
|
Sets Camera screenWidth() and screenHeight() (expressed in pixels). You should not call this method when the Camera is associated with a QGLViewer, since the latter automatically updates these values when it is resized (hence overwritting your values). If your Camera is used without a QGLViewer (offscreen rendering, shadow maps), use setAspectRatio() instead to define the projection matrix. |
|
Defines the Camera type(). Prefix the type with Camera, as in: camera()->setType(Camera::ORTHOGRAPHIC); // or even qglviewer::Camera::ORTHOGRAPHIC if you do not use namespace |
|
Rotates the Camera so that its upVector() becomes
The Camera is rotated around an axis orthogonal to
When
When |
|
Rotates the Camera so that its viewDirection() is The Camera position() is not modified. The Camera is rotated so that the horizon (defined by its upVector()) is preserved. See also lookAt() and setUpVector(). |
|
Sets the zClippingCoefficient() value. |
|
Sets the zNearCoefficient() value. |
|
Moves the Camera so that the entire scene is visible. Simply calls fitSphere() on a sphere defined by sceneCenter() and sceneRadius(). You will typically use this method in QGLViewer::init() after you defined a new sceneRadius(). |
|
Returns the Camera::Type of the Camera. Set by setType(). Mainly used by loadProjectionMatrix(). A Camera::PERSPECTIVE Camera is mainly defined by its fieldOfView(). With a Camera::ORTHOGRAPHIC type(), the fieldOfView() is meaningless and the width and height of the Camera frustum are inferred from the distance to the revolveAroundPoint() using getOrthoWidthHeight(). Both use zNear() and zFar() (to define their clipping planes) and aspectRatio() (for frustum shape). |
|
Returns the world unprojected coordinates of a point
The
The result is expressed in the projectedCoordinatesOf() performs the inverse transformation.
This method only uses the intrinsic Camera parameters (see getModelViewMatrix(), getProjectionMatrix() and getViewport()) and is completely independent of the OpenGL
gluUnProject man page for details. |
|
Returns the normalized up vector of the Camera, defined in the world coordinate system. Set using setUpVector(). Simply returns frame()->inverseTransformOf(Vec(0.0, 1.0, 0.0)). |
|
Returns the normalized view direction of the Camera (negative Z axis), defined in the world coordinate system. Change this value using setViewDirection(), lookAt() or setOrientation(). Simply returns frame()->inverseTransformOf(Vec(0.0, 0.0, -1.0)). |
|
Returns the world coordinates of the point whose position cameraCoordinatesOf() performs the inverse transformation. |
|
Returns the coefficient used to position the near and far clipping planes. The near (resp. far) clipping plane is positioned at a distance equal to zClippingCoefficient() sceneRadius() in front of (resp. behind) the sceneCenter(). This garantees an optimal use of the z-buffer range and minimizes aliasing. See the zNear() and zFar() documentations. Default value is square root of 3.0 (so that a cube of size sceneRadius() is not clipped). However, since the sceneRadius() is used for other purposes (see showEntireScene(), flySpeed(), ...) and you may want to change this value to define more precisely the location of the clipping planes. See also zNearCoefficient().
|
|
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(): zFar = distanceToSceneCenter() + zClippingCoefficient()*sceneRadius(); See the zNear() documentation for details. |
|
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::zFarr() const { return 100.0; }; }
|
|
Returns the coefficient which is used to set zNear() when the Camera is inside the sphere defined by sceneCenter() and zClippingCoefficient() * sceneRadius(). In that case, the zNear() value is set to zNearCoefficient() * zClippingCoefficient() * sceneRadius(). See the zNear() documentation for details. Default value is 0.005, which is appropriate for most applications. In case you need a high dynamic ZBuffer precision, you can increase this value (~0.1). A lower value will prevent clipping of very close objects at the expense of a worst Z precision. Only meaningful when Camera type is Camera::PERSPECTIVE. |