23 #ifndef QGLVIEWER_CAMERA_H 24 #define QGLVIEWER_CAMERA_H 84 friend class ::QGLViewer;
102 enum Type { PERSPECTIVE, ORTHOGRAPHIC };
125 return frame()->inverseTransformOf(
Vec(0.0, 1.0, 0.0));
144 return frame()->inverseTransformOf(
Vec(1.0, 0.0, 0.0));
153 void setFromModelViewMatrix(
const GLdouble*
const modelViewMatrix);
154 void setFromProjectionMatrix(
const float matrix[12]);
160 void setOrientation(
float theta,
float phi);
161 void setUpVector(
const Vec& up,
bool noMove=
true);
162 void setViewDirection(
const Vec& direction);
169 void lookAt(
const Vec& target);
170 void showEntireScene();
171 void fitSphere(
const Vec& center,
float radius);
172 void fitBoundingBox(
const Vec& min,
const Vec& max);
173 void fitScreenRegion(
const QRect& rectangle);
175 void interpolateToZoomOnPixel(
const QPoint& pixel);
176 void interpolateToFitScene();
177 void interpolateTo(
const Frame& fr,
float duration);
223 float aspectRatio()
const {
return static_cast<float>(screenWidth_)/static_cast<float>(screenHeight_); };
234 void getViewport(GLint viewport[4])
const;
235 float pixelGLRatio(
const Vec& position)
const;
269 virtual float zNear()
const;
270 virtual float zFar()
const;
271 virtual void getOrthoWidthHeight(GLdouble& halfWidth, GLdouble& halfHeight)
const;
272 void getFrustumPlanesCoefficients(GLdouble coef[6][4])
const;
275 void setType(
Type type);
280 void setFieldOfView(
float fov) { fieldOfView_ = fov; setFocusDistance(sceneRadius() / tan(fov/2.0)); };
289 void setFOVToFitScene();
303 void setAspectRatio(
float aspect) { setScreenWidthAndHeight(
int(100.0*aspect), 100); };
305 void setScreenWidthAndHeight(
int width,
int height);
339 float distanceToSceneCenter()
const;
342 void setSceneRadius(
float radius);
343 void setSceneCenter(
const Vec& center);
344 bool setSceneCenterFromPixel(
const QPoint& pixel);
345 void setSceneBoundingBox(
const Vec& min,
const Vec& max);
352 void setRevolveAroundPoint(
const Vec& rap);
353 bool setRevolveAroundPointFromPixel(
const QPoint& pixel);
386 virtual void addKeyFrameToPath(
int i);
387 virtual void playPath(
int i);
388 virtual void deletePath(
int i);
389 virtual void resetPath(
int i);
390 virtual void drawAllPaths();
397 virtual void loadProjectionMatrix(
bool reset=
true)
const;
398 virtual void loadModelViewMatrix(
bool reset=
true)
const;
399 void computeProjectionMatrix()
const;
400 void computeModelViewMatrix()
const;
402 virtual void loadProjectionMatrixStereo(
bool leftBuffer=
true)
const;
403 virtual void loadModelViewMatrixStereo(
bool leftBuffer=
true)
const;
405 void getProjectionMatrix(GLdouble m[16])
const;
406 void getModelViewMatrix(GLdouble m[16])
const;
407 void getModelViewProjectionMatrix(GLdouble m[16])
const;
411 void getProjectionMatrix(GLfloat m[16])
const;
412 void getModelViewMatrix(GLfloat m[16])
const;
420 static void drawCamera(
float scale=1.0,
float aspectRatio=1.33,
float fieldOfView=
M_PI/4.0);
422 virtual void draw(
bool drawFarPlane=
true,
float scale=1.0)
const;
441 void getCameraCoordinatesOf(
const float src[3],
float res[3])
const;
442 void getWorldCoordinatesOf(
const float src[3],
float res[3])
const;
449 Vec projectedCoordinatesOf(
const Vec& src,
const Frame* frame=NULL)
const;
450 Vec unprojectedCoordinatesOf(
const Vec& src,
const Frame* frame=NULL)
const;
451 void getProjectedCoordinatesOf(
const float src[3],
float res[3],
const Frame* frame=NULL)
const;
452 void getUnprojectedCoordinatesOf(
const float src[3],
float res[3],
const Frame* frame=NULL)
const;
453 void convertClickToLine(
const QPoint& pixel,
Vec& orig,
Vec& dir)
const;
454 Vec pointUnderPixel(
const QPoint& pixel,
bool& found)
const;
468 float flySpeed()
const {
return frame()->flySpeed(); };
518 void setPhysicalDistanceToScreen(
float distance) { Q_UNUSED(distance); qWarning(
"setPhysicalDistanceToScreen is deprecated, use setPhysicalScreenWidth instead"); };
532 virtual QDomElement domElement(
const QString& name, QDomDocument& document)
const;
534 virtual void initFromDOMElement(
const QDomElement& element);
551 mutable GLdouble modelViewMatrix_[16];
552 mutable GLdouble projectionMatrix_[16];
560 QMap<int, KeyFrameInterpolator*>
kfi_;
566 #endif // QGLVIEWER_CAMERA_H void setAspectRatio(float aspect)
A keyFrame Catmull-Rom Frame interpolator.
float horizontalFieldOfView() const
void setHorizontalFieldOfView(float hfov)
The ManipulatedCameraFrame class represents a ManipulatedFrame with Camera specific mouse bindings...
float zClippingCoefficient() const
float focusDistance() const
void setPhysicalScreenWidth(float width)
float physicalDistanceToScreen() const
float physicalScreenWidth_
QMap< int, KeyFrameInterpolator * > kfi_
static void drawCamera(float scale)
void setZClippingCoefficient(float coef)
ManipulatedCameraFrame * frame() const
void setFocusDistance(float distance)
The Vec class represents 3D positions and 3D vectors.
float sceneRadius() const
ManipulatedCameraFrame * frame_
void setZNearCoefficient(float coef)
float physicalScreenWidth() const
KeyFrameInterpolator * interpolationKfi_
Vec revolveAroundPoint() const
float zNearCoefficient() const
Quaternion orientation() const
A perspective or orthographic camera.
The Quaternion class represents 3D rotations and orientations.
void setPosition(const Vec &pos)
The Frame class represents a coordinate system, defined by a position and an orientation.
float fieldOfView() const
Vec worldCoordinatesOf(const Vec &src) const
void setIODistance(float distance)
void setFlySpeed(float speed)
Vec cameraCoordinatesOf(const Vec &src) const
float aspectRatio() const
void setPhysicalDistanceToScreen(float distance)
Vec viewDirection() const
void setFieldOfView(float fov)