23 #ifndef QGLVIEWER_CAMERA_H 24 #define QGLVIEWER_CAMERA_H 87 friend class ::QGLViewer;
105 enum Type { PERSPECTIVE, ORTHOGRAPHIC };
110 Vec position()
const;
111 Vec upVector()
const;
112 Vec viewDirection()
const;
113 Vec rightVector()
const;
116 void setFromModelViewMatrix(
const GLdouble*
const modelViewMatrix);
117 void setFromProjectionMatrix(
const qreal matrix[12]);
120 void setPosition(
const Vec& pos);
122 void setOrientation(qreal theta, qreal phi);
123 void setUpVector(
const Vec& up,
bool noMove=
true);
124 void setViewDirection(
const Vec& direction);
131 void lookAt(
const Vec& target);
132 void showEntireScene();
133 void fitSphere(
const Vec& center, qreal radius);
134 void fitBoundingBox(
const Vec& min,
const Vec& max);
135 void fitScreenRegion(
const QRect& rectangle);
137 void interpolateToZoomOnPixel(
const QPoint& pixel);
138 void interpolateToFitScene();
139 void interpolateTo(
const Frame& fr, qreal duration);
185 qreal
aspectRatio()
const {
return screenWidth_ /
static_cast<qreal
>(screenHeight_); }
196 void getViewport(GLint viewport[4])
const;
197 qreal pixelGLRatio(
const Vec& position)
const;
231 virtual qreal zNear()
const;
232 virtual qreal zFar()
const;
233 virtual void getOrthoWidthHeight(GLdouble& halfWidth, GLdouble& halfHeight)
const;
234 void getFrustumPlanesCoefficients(GLdouble coef[6][4])
const;
237 void setType(
Type type);
239 void setFieldOfView(qreal fov);
248 void setFOVToFitScene();
262 void setAspectRatio(qreal aspect) { setScreenWidthAndHeight(
int(100.0*aspect), 100); }
264 void setScreenWidthAndHeight(
int width,
int height);
298 qreal distanceToSceneCenter()
const;
301 void setSceneRadius(qreal radius);
302 void setSceneCenter(
const Vec& center);
303 bool setSceneCenterFromPixel(
const QPoint& pixel);
304 void setSceneBoundingBox(
const Vec& min,
const Vec& max);
311 void setPivotPoint(
const Vec& point);
312 bool setPivotPointFromPixel(
const QPoint& pixel);
315 Vec pivotPoint()
const;
319 void setRevolveAroundPoint(
const Vec& point);
320 bool setRevolveAroundPointFromPixel(
const QPoint& pixel);
322 Vec revolveAroundPoint()
const;
348 virtual void addKeyFrameToPath(
unsigned int i);
349 virtual void playPath(
unsigned int i);
350 virtual void deletePath(
unsigned int i);
351 virtual void resetPath(
unsigned int i);
352 virtual void drawAllPaths();
359 virtual void loadProjectionMatrix(
bool reset=
true)
const;
360 virtual void loadModelViewMatrix(
bool reset=
true)
const;
361 void computeProjectionMatrix()
const;
362 void computeModelViewMatrix()
const;
364 virtual void loadProjectionMatrixStereo(
bool leftBuffer=
true)
const;
365 virtual void loadModelViewMatrixStereo(
bool leftBuffer=
true)
const;
367 void getProjectionMatrix(GLfloat m[16])
const;
368 void getProjectionMatrix(GLdouble m[16])
const;
370 void getModelViewMatrix(GLfloat m[16])
const;
371 void getModelViewMatrix(GLdouble m[16])
const;
373 void getModelViewProjectionMatrix(GLfloat m[16])
const;
374 void getModelViewProjectionMatrix(GLdouble m[16])
const;
381 static void drawCamera(qreal scale=1.0, qreal aspectRatio=1.33, qreal fieldOfView=qreal(
M_PI)/4.0);
383 virtual void draw(
bool drawFarPlane=
true, qreal scale=1.0)
const;
390 Vec cameraCoordinatesOf(
const Vec& src)
const;
391 Vec worldCoordinatesOf(
const Vec& src)
const;
392 void getCameraCoordinatesOf(
const qreal src[3], qreal res[3])
const;
393 void getWorldCoordinatesOf(
const qreal src[3], qreal res[3])
const;
400 Vec projectedCoordinatesOf(
const Vec& src,
const Frame* frame=NULL)
const;
401 Vec unprojectedCoordinatesOf(
const Vec& src,
const Frame* frame=NULL)
const;
402 void getProjectedCoordinatesOf(
const qreal src[3], qreal res[3],
const Frame* frame=NULL)
const;
403 void getUnprojectedCoordinatesOf(
const qreal src[3], qreal res[3],
const Frame* frame=NULL)
const;
404 void convertClickToLine(
const QPoint& pixel,
Vec& orig,
Vec& dir)
const;
405 Vec pointUnderPixel(
const QPoint& pixel,
bool& found)
const;
412 qreal flySpeed()
const;
414 void setFlySpeed(qreal speed);
459 void setPhysicalDistanceToScreen(qreal distance) { Q_UNUSED(distance); qWarning(
"setPhysicalDistanceToScreen is deprecated, use setPhysicalScreenWidth instead"); }
473 virtual QDomElement domElement(
const QString& name, QDomDocument& document)
const;
475 virtual void initFromDOMElement(
const QDomElement& element);
480 void onFrameModified();
495 mutable GLdouble modelViewMatrix_[16];
497 mutable GLdouble projectionMatrix_[16];
506 QMap<unsigned int, KeyFrameInterpolator*>
kfi_;
512 #endif // QGLVIEWER_CAMERA_H void setZClippingCoefficient(qreal coef)
A keyFrame Catmull-Rom Frame interpolator.
qreal aspectRatio() const
The ManipulatedCameraFrame class represents a ManipulatedFrame with Camera specific mouse bindings...
void setAspectRatio(qreal aspect)
qreal fieldOfView() const
void setIODistance(qreal distance)
qreal physicalScreenWidth_
qreal physicalDistanceToScreen() const
qreal horizontalFieldOfView() const
ManipulatedCameraFrame * frame() const
qreal sceneRadius() const
The Vec class represents 3D positions and 3D vectors.
ManipulatedCameraFrame * frame_
qreal zNearCoefficient() const
KeyFrameInterpolator * interpolationKfi_
QMap< unsigned int, KeyFrameInterpolator * > kfi_
bool modelViewMatrixIsUpToDate_
qreal focusDistance() const
void setPhysicalDistanceToScreen(qreal distance)
void setZNearCoefficient(qreal coef)
void setPhysicalScreenWidth(qreal width)
void setHorizontalFieldOfView(qreal hfov)
qreal physicalScreenWidth() const
A versatile 3D OpenGL viewer based on QGLWidget.
A perspective or orthographic camera.
The Quaternion class represents 3D rotations and orientations.
void setFocusDistance(qreal distance)
The Frame class represents a coordinate system, defined by a position and an orientation.
bool projectionMatrixIsUpToDate_
qreal zClippingCoefficient() const
static void drawCamera(qreal scale)