#include <camera.h>
Position and orientation of the camera | |
Vec | position () const |
Quaternion | orientation () const |
void | getPosition (float &x, float &y, float &z) const |
void | getOrientation (float &q0, float &q1, float &q2, float &q3) const |
void | setPosition (const Vec &pos) |
void | setPosition (float x, float y, float z) |
void | setOrientation (const Quaternion &q) |
void | setOrientation (float q0, float q1, float q2, float q3) |
void | setOrientation (float theta, float phi) |
void | setCameraFromProjectionMatrix (const float *const m) |
Positioning tools | |
void | setUpVector (float x, float y, float z, bool noMove=true) |
void | showEntireScene () |
void | fitBoundingBox (const Vec &m, const Vec &M) |
void | fitSphere (const Vec ¢er, float radius) |
void | fitSphere (float x, float y, float z, float r) |
void | lookAt (const Vec &target) |
void | lookAt (float x, float y, float z) |
void | centerScene () |
void | setUpVector (const Vec &up, bool noMove=true) |
void | fitScreenRegion (int xa, int ya, int xb, int yb) |
void | setFOVToFitScene () |
void | interpolateToZoomOnPixel (int x, int y) |
void | interpolateToFitScene () |
Intrinsic parameters | |
float | fieldOfView () const |
float | horizontalFieldOfView () const |
float | flySpeed () const |
Type | type () const |
void | setFieldOfView (float f) |
void | setHorizontalFieldOfView (float hfov) |
void | setFlySpeed (float s) |
void | setType (Type type) |
Associated parameters | |
virtual float | zNear () const |
virtual float | zFar () const |
float | zNearCoef () const |
void | getOrthoWidthHeight (GLdouble &w, GLdouble &h) const |
float | aspectRatio () const |
int | screenWidth () const |
int | screenHeight () const |
float | pixelGLRatio (const Vec &pos) |
float | distanceToSceneCenter () const |
Vec | upVector () const |
void | getUpVector (float &x, float &y, float &z) const |
Vec | viewDirection () const |
void | getViewDirection (float &x, float &y, float &z) const |
Vec | pointUnderPixel (const int x, const int y, bool &found) |
bool | isManipulated () const |
void | getViewport (GLint viewport[4]) const |
void | setZNearCoef (float coef) |
void | setAspectRatio (float aspect) |
Revolve Around Point | |
Vec | revolveAroundPoint () const |
void | getRevolveAroundPoint (float &x, float &y, float &z) const |
void | setRevolveAroundPoint (const Vec &rap) |
void | setRevolveAroundPoint (float x, float y, float z) |
bool | setRevolveAroundPointFromPixel (int x, int y) |
Paths | |
int | nbPaths () const |
KeyFrameInterpolator * | keyFrameInterpolator (unsigned short i) const |
void | setKeyFrameInterpolator (unsigned short i, KeyFrameInterpolator *const kfi) |
virtual void | addKeyFrame (unsigned short i) |
virtual void | playKeyFramePath (unsigned short i) |
virtual void | deleteKeyFramePath (unsigned short i) |
virtual void | resetKeyFramePath (unsigned short i) |
virtual void | drawAllPaths () |
Associated frame | |
ManipulatedCameraFrame * | frame () const |
void | setFrame (ManipulatedCameraFrame *const f) |
OpenGL associated matrices | |
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 | 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 |
virtual void | computeModelViewMatrix () const |
World to Camera coordinate systems conversions | |
void | getCameraCoordinatesOf (const float src[3], float res[3]) const |
Vec | cameraCoordinatesOf (const Vec &src) const |
void | getWorldCoordinatesOf (const float src[3], float res[3]) const |
Vec | worldCoordinatesOf (const Vec &src) const |
2D screen to 3D world coordinate systems conversions | |
Vec | projectedCoordinatesOf (const Vec &src, const Frame *frame=NULL) const |
void | getProjectedCoordinatesOf (const float src[3], float res[3], const Frame *frame=NULL) const |
Vec | unprojectedCoordinatesOf (const Vec &src, const Frame *frame=NULL) const |
void | getUnprojectedCoordinatesOf (const float src[3], float res[3], const Frame *frame=NULL) const |
void | convertClickToLine (int x, int y, Vec &orig, Vec &dir) const |
void | convertClickToLine (int x, int y, float orig[3], float dir[3]) const |
Stereo mode parameters | |
float | IODist () const |
float | distanceToScreen () const |
float | distanceToZeroParallaxPlane () const |
float | physicalScreenWidth () const |
void | setIODist (float iod) |
void | setDistanceToScreen (float dts) |
void | setDistanceToZeroParallaxPlane (float dtz) |
void | setPhysicalScreenWidth (float sw) |
XML representation | |
virtual QDomElement | domElement (const QString &name, QDomDocument &doc) const |
virtual void | initFromDOMElement (const QDomElement &de) |
Scene radius and center | |
float | sceneRadius () const |
Vec | sceneCenter () const |
void | setSceneRadius (float r) |
void | setSceneBoundingBox (const Vec &m, const Vec &M) |
void | setSceneCenter (const Vec &sc) |
void | setSceneCenter (float x, float y, float z) |
bool | setSceneCenterFromPixel (int x, int y) |
Internal methods | |
bool | cameraPathIsEdited () const |
void | editCameraPath (bool edit=true) |
void | setWindowWidthAndHeight (int w, int h) |
Public Types | |
enum | Type { PERSPECTIVE, ORTHO } |
Public Member Functions | |
Camera () | |
virtual | ~Camera () |
A Camera defines some intrinsic camera parameters, such as fieldOfView(), position(), viewDirection(), upVector()... It also provides useful positioning tools that ease its placement : showEntireScene(), fitSphere(), fitBoundingBox(),, ...
The type() of the Camera can be ORTHO or PERSPECTIVE (see Type()). fieldOfView() is meaningless in ORTHO.
The position() and orientation() of the Camera are defined by a ManipulatedCameraFrame that can be retrieved with frame(). These functions are just a convenient interface for the associated Frame functions. This also means that the Camera frame() can be attached to a Frame::referenceFrame() which enable complex Camera setups.
Different camera 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 : QGLViewer::ROTATE (left), QGLViewer::ZOOM (middle) and QGLViewer::TRANSLATE (right). With this configuration, the camera observes a scene and rotates around its revolveAroundPoint(). You can switch between this mode and a walkthrough mode using the QGLViewer::CAMERA_MODE keyboard accelerator (see QGLViewer::setKeyboardAccelerator() and QGLViewer::toggleCameraMode()).
The near and far planes of the Camera are determined from the QGLViewer::sceneRadius() and QGLViewer::sceneCenter() by the zNear() and zFar() functions. 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 functions can then be automated (showEntireScene(), centerScene()...). Once again, see the mouse page for details.
A Camera holds 12 KeyFrameInterpolator that can be used to save camera positions and paths. You can interactively addKeyFrame() to a given path using the default Alt+F
[1-12] accelerators. Use playKeyFramePath() to make the camera follow the path (default accelerator 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 PERSPECTIVE type() only). Test the stereoViewer example to check.
|
The type of camera used by the QGLViewer, set by setType(). This type will be use in loadProjectionMatrix().
|
|
Camera constructor. Default values are set : sceneCenter() is set to (0,0,0), sceneRadius() set to 1.0, camera type() is set to PERSPECTIVE, with a See IODist(), distanceToScreen(), physicalScreenWidth() and distanceToZeroParallaxPlane() for default stereo parameter values. |
|
Virtual destructor. Current frame() is deleted. |
|
Adds the current camera frame as a key frame to the path number The default keyboard accelerator for this function is Alt-F[1-12]. Set QGLViewer::setKeyFrameKey() and QGLViewer::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 |
|
Returns |
|
Move the camera so that the sceneCenter() is projected on the center of the window. The orientation() and fieldOfView() are unchanged. ManipulatedCameraFrame::mouseDoubleClickEvent() calls this function after a right button double click. See also showEntireScene(). |
|
Computes the model view matrix associated with the camera state. Called by loadModelViewMatrix() before each drawing. You need to call this function if you use the model view matrix out of the main drawing loop (unlikely), for a (un) projectedCoordinatesOf() or a getModelViewMatrix() for instance. |
|
Same as convertClickToLine(), but the result is returned as |
|
This function should be called by your selection function to transform a window x,y coordinate to a (world coordinates) half line, for analytical intersection process.
The origin of the half line (eye position) is stored in Typical usage would be: convertClickToLine(e->x(), e->y(), orig, dir);
The See the select example for an illustration. |
|
Deletes the KeyFrameInterpolator of index The keyFrameInterpolator() KeyFrameInterpolator::interpolated() signal was probably connected to the camera's viewer updateGL() slot, and you may want to disconnect it before deleting the keyFrameInterpolator(): disconnect(camera()->keyFrameInterpolator(i), SIGNAL(interpolated()), this, SLOT(updateGL())); camera()->deleteKeyFramePath(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 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( myCamera->domElement("Camera", doc) ); QFile f("myCamera.xml"); if (f.open(IO_WriteOnly)) { QTextStream out(&f); doc.save(out, 2); } Use the following code to retrieve state from the saved file: // Load DOM from file QDomDocument doc; QFile f("myCamera.xml"); if (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::drawPathModifyGLState() for all the defined path. See addKeyFrame() and setKeyFrameInterpolator() to define a path.
The path color is the current
|
|
Starts or stops the edition of the camera paths. Called by QGLViewer::editCameraPath() and QGLViewer::toggleCameraPathEditor(). Get current value with cameraPathIsEdited(). |
|
Returns the vertical field of view of the camera (in radians). Value is set using setFieldOfView(), default value is pi/4 radians. |
|
Moves the camera so that the bounding box
|
|
Moves the camera so that the screen region defined by ( The camera is translated (its orientation() is unchanged) so that the input rectangle is entirely visible. Since the pixel coordinates only define a frustum in 3D, it's the intersection of the frustum with a plane (orthogonal to the viewDirection() and passing through the sceneCenter()) that is used to define the 3D rectangle that is fitted. |
|
Same as fitSphere(), but with float parameters. |
|
Moves the camera so that the sphere ( |
|
Returns the current fly speed of the camera. This function is identical to ManipulatedCameraFrame::flySpeed(). The flySpeed() is only meaningful when the mouse bindings are set to QGLViewer::MOVE_FORWARD or QGLViewer::MOVE_BACKWARD (see QGLViewer::setMouseBinding() and the mouse page. Set with setFlySpeed(). Set to 0.5% of the sceneRadius in setSceneRadius(). |
|
The ManipulatedCameraFrame attached to the camera and which defines its position and orientation. See setFrame(). |
|
Same as cameraCoordinatesOf(), but the parameters are |
|
Set
This matrix actually represents the state of the
|
|
This function is provided for convenience, in case you want to work with |
|
|
|
Returns the half width |
|
Same as position(), but with |
|
|
|
Set
|
|
This function is provided for convenience, in case you want to work with |
|
|
|
Same as getUnprojectedCoordinatesOf(), but with |
|
Same as upVector(), but with |
|
|
|
Fills |
|
Same as worldCoordinatesOf(), but the parameters are |
|
Returns the horizontal (X camera frame direction) field of view used by the camera (in radians). Value is set using setHorizontalFieldOfView() or setFieldOfView(). The values are always linked by : horizontalFieldOfView() = 2.0 * atan ( tan(fieldOfView()/2.0) * aspectRatio() ). |
|
Restore the Camera state from a QDomElement created by domElement(). See also KeyFrameInterpolator::initFromDOMElement(), Frame::initFromDOMElement(). |
|
Inperpolates the camera position on a one second KeyFrameInterpolator path stating from the current position, so that at the end the entire scene is visible and fits in screen (see showEntireScene()). See also interpolateToZoomOnPixel(). This function is called when you press the middle mouse button and then double click the right button. See mouse page for details. |
|
Make the camera zoom on the selected pixel (if an object is actually drawn in this pixel, see pointUnderPixel()). A KeyFrameInterpolator is created and animates the camera on a one second path that brings the camera closer to the selected pixel. See also interpolateToFitScene(). This function is called when you press the middle mouse button and then double click the left button. See mouse page for details. |
|
Returns the inter-ocular distance used for stereo (in meters). 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 The KeyFrameInterpolator::interpolated() signal of this keyFrameInterpolator() should be connected to any object that should be notified when the frame is interpolated. The camera's associated viewer (if any) should especially be connected. See the setKeyFrameInterpolator() documentation.
|
|
Loads the current camera GL_MODELVIEW matrix.
When getModelViewMatrix() returns the current 4x4 model view matrix.
|
|
Loads 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 in PERSPECTIVE type(). See getOrthoWidthHeight() for ORTHO type(). 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.
|
|
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 asymmetric 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 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 returns |
|
Returns the physical screen width (used for stereo mode only). Value is set using setPhysicalScreenWidth() |
|
Returns the pixel to GL unit ratio. A line of 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().address()); glVertex3fv((sceneCenter() + 20*pixelGLRatio(sceneCenter())*upVector()).address()); glEnd();
|
|
Make the camera follow the key frame path number The default keyboard accelerator for this function is F[1-12]. Set QGLViewer::setKeyFrameKey() and QGLViewer::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 (origin in the upper left corner). Calls a
|
|
Returns the camera position (the eye), defined in the world coordinate system. Use setPosition() to set the camera position. Other convenient functions are showEntireScene(), fitBoundingBox() or fitSphere(). Actually returns |
|
Returns the screen projected coordinates of a point
See the
This method is not computationally optimized. If you call it several times with no change in the matrices, you should pre-comp)ute the entire projection matrix (modelview, projection and then viewport) to speed-up the queries. See the unprojectedCoordinatesOf() performs the inverse transformation.
|
|
If this keyFrame path is not being played (see playKeyFramePath() ), reset it to is its starting position (see KeyFrameInterpolator::resetInterpolation()). If the path is played, simply stop interpolation. |
|
With QGLViewer::ROTATE mouse binding, this is the point the camera revolves around (defined in world coordinate system). Default value is the sceneCenter().
|
|
Returns the position of the scene center. This value is set setSceneCenter(), which is called by QGLViewer::setSceneCenter(). 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 modifed by QGLViewer::setSceneRadius(), which simply calls setSceneRadius(). |
|
Returns the current height (in pixels) of the camera screen. See also QGLWidget::height(). |
|
Returns the current width (in pixels) of the camera screen. See also QGLWidget::width() |
|
Defines the camera aspectRatio(). When a Camera is attached to a QGLViewer (using QGLViewer::setCamera()), the Camera screenWidth() and screenHeight() (and hence aspectRatio()) are automatically set and updated from the QGLViewer window dimensions (using the protected setWindowWidthAndHeight() method). This function then becomes useless and non effective as the dimensions will be modifed by the next window resizing. However, when the Camera positioning functions are used, for instance, to create a shadow map as seen from a virtual light source, this function is needed, since the aspectRatio() of the Camera is used to create the projection matrix (see loadProjectionMatrix()). See the (soon available) shadowMap example for an illustration.
|
|
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). |
|
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. distanceToScreen() and distanceToZeroParallaxPlane() represent the same distance. distanceToScreen() is expressed in physical real units, while distanceToZeroParallaxPlane() is expressed in openGL virtual world units. Use their ratio to convert distances between these worlds. |
|
Defines the distance in virtual world between the viewpoint and the plane where the horizontal parallax is null, that is to say where the stereo left and right images are superimposed. This distance is also referred as the focus distance. loadProjectionMatrixStereo() uses this value to define the camera offset and frustum. distanceToScreen() and distanceToZeroParallaxPlane() represent the same distance. distanceToScreen() is expressed in physical real units, while distanceToZeroParallaxPlane() is expressed in openGL virtual world units. Use their ratio to convert distances between these worlds.
|
|
Defines the vertical field of view of the camera (in radians). Also used to fit the scene and mouse translations. fieldOfView() returns the current value. The default value is pi/4 radians. loadProjectionMatrix() uses this value to define the camera.
The field of view corresponds the one used in Use setFOVToFitScene() to adapt the fieldOfView(). This is not the normal way of zooming in or out. All the other positioning camera function (showEntireScene(), fitSphere()...) move the camera instead of changing its fieldOfView(). distanceToZeroParallaxPlane() is set to sceneRadius() / tan(fieldOfView()/2) (used only for stereo mode, see QGLViewer::setStereoDisplay(), setSceneRadius() and setDistanceToZeroParallaxPlane()). |
|
When the camera associated mouse action is QGLViewer::MOVE_FORWARD or QGLViewer::MOVE_BACKWARD, tunes the speed of the displacement. Current value is given by flySpeed(). See the mouse page for details.
|
|
Change the camera fieldOfView() so that the entire scene (defined by QGLViewer;;sceneCenter() and QGLViewer::sceneRadius()) would be visible from the current camera position(). The position() and orientation() of the camera are not modified and you have to properly orientate the camera in order to actually see the scene (see lookAt()). See also showEntireScene() and fitSphere(). This function is especially useful for shadow maps computation. Use the camera positioning tools (setPosition(), lookAt()) to position a camera at the light position. Use setFOVToFitScene() to define an optimal fieldOfView() for this camera, so that the shadow map resolution is optimally used.
// The light camera needs size hints in order to optimize FOV light_camera->setSceneRadius(sceneRadius()); light_camera->setSceneCenter(sceneCenter()); // Place the light camera. light_camera->setPosition(light_frame->position()); light_camera->lookAt(sceneCenter()); light_camera->setFOVToFitScene(); Use a viewer QGLViewer::displayZBuffer() function to actually see the computed shadow map. See the shadowMap contribution example for a practical implementation.
|
|
Changes the ManipulatedCameraFrame that defines the position and orientation of the camera. If you simply want to move the camera, use setPosition() and setOrientation() or one of the camera positioning functions : lookAt(), fitSphere(), fitBoundingBox(), showEntireScene()... If you want to save camera positions, there's no real need to call this function either. Use addKeyFrame() and playKeyFramePath() for this. This function 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 delete camera()->frame();
camera()->setFrame(myManipulatedCameraFrame());
|
|
Defines the horizontal field of view of the camera (in radians). Actually calls setFieldOfView() scaled by 1/aspectRatio(). 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.062m, 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
The KeyFrameInterpolator::interpolated() signal of
deleteKeyFramePath(3); setKeyFrameInterpolator(3, myKeyFrameInterpolator); connect(myKeyFrameInterpolator, SIGNAL(interpolated()), myViewer, SLOT(updateGL()); The KeyFrameInterpolator::interpolated() signal can also be connected to all the viewers updateGL() slots: QGLViewer::connectSignalToAllViewers(myKeyFrameInterpolator, SIGNAL(interpolated()));
|
|
Set the orientation of the camera using polar coordinates This function can be useful to create Quicktime VR panoramic sequences, see QGLViewer::saveSnapshot() for details. |
|
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. |
|
Same as setPosition(), but with float parameters. |
|
Set the camera position (the eye), defined in the world coordinate system. The current camera position can be obtained from position(). |
|
|
|
Changes the revolveAroundPoint(), which defines the position (in world coordinates) of the 3D point the camera revolves around in QGLViewer::ROTATE mode. 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.
Returns This function is called when you press the right mouse button and then double click the left button. See mouse page for details. |
|
Similar to setSceneRadius() and setSceneCenter(), 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).
Returns |
|
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 QGLViewer::setSceneRadius(). distanceToZeroParallaxPlane() is set to sceneRadius()/tan(fieldOfView()/2) (used only for stereo mode, see QGLViewer::setStereoDisplay(), 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); myViewer.camera()->showEntireScene(); |
|
Same as setUpVector(), but with float parameters. |
|
Rotates the camera such that its up vector becomes Use this function in order to define the horizontal plane in fly mode (QGLViewer::MOVE_FORWARD or QGLViewer::MOVE_BACKWARD binding).
However it might be interesting to compensate the orientation modification by a translation, so that the revolveAroundPoint() stays projected at the same position on screen. This is especially useful when the camera is an observer of the scene (default mouse binding) and it can be achieved when |
|
Update a copy of the QGLViewer window dimensions. Called by the QGLViewer when it is resized. You should not call this function directly, as the QGLViewer does it. However, if your Camera is used outside of a QGLViewer (offscreen rendering, shadow maps), you need to provide the screen width and height in order to define the camera aspectRatio() which is used to define the projection matrix in loadProjectionMatrix(). Use setAspectRatio() for that purpose. |
|
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 appropriate for walkthrough 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. |
|
Adjust the camera so that the entire scene is visible. The camera is translated to make the entire scene fit the window, its orientation() is unchanged. The scene is defined by the QGLViewer::sceneCenter() and QGLViewer::sceneRadius(). The fieldOfView() is not modified by this function. QGLViewer::showEntireScene() simply calls this function. See also setFOVToFitScene(). You will typically use this function in QGLViewer::init(): setSceneRadius(3.0); showEntireScene(); You should orientate the camera before you call this function. See lookAt(), setOrientation() and setUpVector(). By default the QGLViewer::sceneRadius() is 1.0, and the QGLViewer constructor calls this function. See also centerScene(). ManipulatedCameraFrame::mouseDoubleClickEvent() calls this function after a middle button double click. |
|
Returns the type of the camera used by the QGLViewer. Set by setType(). Supported types are defined by the Type() enum. Used by loadProjectionMatrix(). |
|
Returns the world unprojected coordinates of a point
The result is expressed in the
This method is not computationally 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(). 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. |
|
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: float coef = sqrt(2.0); // so that a 1x1 grid fits if (cameraPathIsEdited()) coef = 5.0; zFar=distanceToSceneCenter() + coef*sceneRadius();
The
|
|
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: float coef = sqrt(2.0); // so that a 1x1 grid fits if (cameraPathIsEdited()) coef = 5.0; zNear = distanceToSceneCenter() - coef*sceneRadius(); // Prevents negative or null zNear values. if (zNear < zNearCoef() * sceneRadius()) switch (type()) { case Camera::PERSPECTIVE : zNear = zNearCoef() * sceneRadius(); break; case Camera::ORTHO : zNear = 0.0; break; } Returned value is clipped when the camera is inside the scene sphere to prevent negative or too small zNear() values (see setZNearCoef()).
The
|
|
Returns the coefficient which is used to set zNear() when the camera is inside the sceneRadius() sphere. Set with setZNearCoef(). Only meaningful when camera type is Camera::PERSPECTIVE. |