39#ifndef EASY3D_RENDERER_CAMERA_H
40#define EASY3D_RENDERER_CAMERA_H
43#include <easy3d/core/types.h>
44#include "easy3d/util/signal.h"
210 const mat3 &R,
const vec3 &t,
bool convert =
true);
397 return static_cast<float>(screenWidth_) /
static_cast<float>(screenHeight_);
542 projectionMatrixIsUpToDate_ =
false;
550 zClippingCoef_ = coef;
551 projectionMatrixIsUpToDate_ =
false;
715 int screenWidth_, screenHeight_;
720 float zClippingCoef_;
723 mat4 modelViewMatrix_;
724 bool modelViewMatrixIsUpToDate_;
725 mat4 projectionMatrix_;
726 bool projectionMatrixIsUpToDate_;
void setHorizontalFieldOfView(float hfov)
Sets the horizontalFieldOfView() of the Camera (in radians).
Definition camera.h:507
void setSceneCenter(const vec3 ¢er)
Set the center of the scene.
void showEntireScene() const
Show the entire scene.
void setPivotPoint(const vec3 &point)
Set the pivot point of the camera. After this method is called, the Camera rotates around this point.
float zClippingCoefficient() const
Returns the coefficient used to position the near and far clipping planes.
Definition camera.h:452
Camera & operator=(const Camera &camera)
Assignment operator.
KeyFrameInterpolator * keyframe_interpolator() const
Get the keyframe interpolator.
Definition camera.h:336
void setOrientation(const quat &q) const
Set the orientation of the camera.
int screenWidth() const
Returns the width (in pixels) of the Camera screen.
Definition camera.h:406
mat4 modelViewProjectionMatrix() const
Get the model view projection matrix.
int screenHeight() const
Returns the height (in pixels) of the Camera screen.
Definition camera.h:414
Type
Enumerates the two possible types of Camera.
Definition camera.h:143
@ PERSPECTIVE
Perspective camera.
Definition camera.h:144
@ ORTHOGRAPHIC
Orthographic camera.
Definition camera.h:145
void setZNearCoefficient(float coef)
Set the zNear coefficient.
Definition camera.h:540
void setFOVToFitScene()
Set the field of view to fit the scene.
void setSceneRadius(float radius)
Set the radius of the scene.
void fitSphere(const vec3 ¢er, float radius) const
Move the camera so that entire sphere fits the screen.
quat orientation() const
Get the orientation of the camera.
float sceneRadius() const
Returns the radius of the scene observed by the Camera.
Definition camera.h:565
Camera(const Camera &camera)
Copy constructor.
void interpolateToLookAt(const vec3 &point)
Perform keyframe interpolation to look at a point.
vec3 projectedCoordinatesOf(const vec3 &src, const Frame *frame=nullptr) const
Returns the screen projected coordinates of a 3D point defined in the frame coordinate system....
vec3 cameraCoordinatesOf(const vec3 &src) const
Convert world coordinates to camera coordinates.
void set_modelview_matrix(const mat4 &mv)
Temporally change the modelview matrix.
float aspectRatio() const
Returns the Camera aspect ratio defined by screenWidth() / screenHeight().
Definition camera.h:396
const mat4 & projectionMatrix() const
Get the projection matrix.
void setScreenWidthAndHeight(int width, int height)
Set the screen width and height.
vec3 pivotPoint() const
Get the pivot point of the camera.
void convertClickToLine(int x, int y, vec3 &orig, vec3 &dir) const
Returns the coefficients of a 3D half-line passing through the Camera eye and pixel (x,...
void setFieldOfView(float fov)
Set the field of view of the camera.
void set_projection_matrix(const mat4 &proj)
Temporally change the projection matrix.
virtual float zFar() const
Get the far clipping plane distance.
void setAspectRatio(float aspect)
Defines the Camera aspectRatio().
Definition camera.h:526
void setOrientation(float theta, float phi) const
Set the orientation of the camera.
void setType(Type type)
Set the type of the camera.
void lookAt(const vec3 &target) const
Make the camera look at a target.
void setZClippingCoefficient(float coef)
Set the zClipping coefficient.
Definition camera.h:549
void set_from_calibration(float fx, float fy, float skew, float cx, float cy, const mat3 &R, const vec3 &t, bool convert=true)
Defines the position(), orientation() and fieldOfView() of the camera from calibrated camera intrinsi...
float zNearCoefficient() const
Returns the coefficient which is used to set zNear() when the Camera is inside the sphere defined by ...
Definition camera.h:434
void computeModelViewMatrix()
Compute the model view matrix.
void setUpVector(const vec3 &up, bool noMove=true) const
Set the up vector of the camera.
vec3 rightVector() const
Get the right vector of the camera.
float fieldOfView() const
Returns the vertical field of view of the camera (in radians).
Definition camera.h:376
void fitBoundingBox(const vec3 &min, const vec3 &max) const
Move the camera so that entire box fits the screen.
vec3 unprojectedCoordinatesOf(const vec3 &src, const Frame *frame=nullptr) const
Returns the world unprojected coordinates of a point defined in the screen coordinate system....
vec3 upVector() const
Get the up vector of the camera.
Signal frame_modified
A signal indicating the frame has been modified.
Definition camera.h:733
void setFrame(ManipulatedCameraFrame *const mcf)
Set the manipulated frame of the camera.
void interpolateToFitScene()
Perform keyframe interpolation to fit the scene.
void centerScene() const
Moves the Camera so that its sceneCenter() is projected in the center of the screen.
void fitScreenRegion(int xmin, int ymin, int xmax, int ymax) const
Moves the Camera so that the rectangular screen region fits the screen.
virtual ~Camera()
Destructor.
float pixelGLRatio(const vec3 &position) const
Get the pixel GL ratio at a position.
void setViewDirection(const vec3 &direction) const
Set the view direction of the camera.
virtual float zNear() const
Get the near clipping plane distance.
Camera()
Default constructor.
void computeProjectionMatrix()
Compute the projection matrix.
const mat4 & modelViewMatrix() const
Get the model view matrix.
void getFrustumPlanesCoefficients(float coef[6][4]) const
Get the frustum planes coefficients.
vec3 position() const
Get the position of the camera.
void set_from_model_view_matrix(const mat4 &mv) const
Sets the Camera's position() and orientation() from an OpenGL ModelView matrix.
vec3 viewDirection() const
Get the view direction of the camera.
vec3 worldCoordinatesOf(const vec3 &src) const
Convert camera coordinates to world coordinates.
void setPosition(const vec3 &pos) const
Set the position of the camera.
vec3 sceneCenter() const
Returns the position of the scene center, defined in the world coordinate system.
Definition camera.h:576
void interpolateTo(const Frame *frame, float duration)
Perform keyframe interpolation to a frame.
Type type() const
Get the type of the camera.
Definition camera.h:365
float horizontalFieldOfView() const
Returns the horizontal field of view of the camera (in radians).
Definition camera.h:386
void set_from_calibration(const mat34 &proj)
Defines the position(), orientation() and fieldOfView() of the camera from calibrated camera intrinsi...
virtual void getOrthoWidthHeight(float &halfWidth, float &halfHeight) const
Get the orthographic width and height.
float distanceToSceneCenter() const
Get the distance to the scene center.
void getFrustumPlanesCoefficients2(float coef[6][4]) const
Get the frustum planes coefficients (alternative version).
ManipulatedCameraFrame * frame() const
Returns the ManipulatedFrame attached to the Camera.
Definition camera.h:623
void setSceneBoundingBox(const vec3 &min, const vec3 &max)
Set the bounding box of the scene.
The Frame class represents a coordinate system, defined by a position and an orientation.
Definition frame.h:78
A keyframe interpolator for animation generation.
Definition key_frame_interpolator.h:104
A manipulated frame with camera-specific mouse bindings.
Definition manipulated_camera_frame.h:61
A light-weight implementation of the simple signal-slot mechanism.
Definition signal.h:54
Definition collider.cpp:182
Vec< 3, float > vec3
A 3D point/vector of float type.
Definition types.h:44
FT min()
Function returning minimum representable value for a given type.
Quat< float > quat
A quaternion of float type.
Definition types.h:85
FT max()
Function returning maximum representable value for a given type.
Mat4< float > mat4
A 4 by 4 matrix of float type.
Definition types.h:67
Mat3< float > mat3
A 3 by 3 matrix of float type.
Definition types.h:65
Mat< 3, 4, float > mat34
A 3 by 4 matrix of float type.
Definition types.h:69