Inviwo 0.9.12-pre
Inviwo documentation
Loading...
Searching...
No Matches
inviwo::Camera Class Referenceabstract

Base class for cameras. Override this class to set your own projection matrix. More...

#include <inviwo/core/datastructures/camera/camera.h>

Inheritance diagram for inviwo::Camera:

Public Member Functions

 Camera (Camera &&other) noexcept=default
 Camera (const Camera &other)=default
 Camera (dvec3 lookFrom, dvec3 lookTo, dvec3 lookUp, double nearPlane, double farPlane, double aspectRatio)
 Create a camera.
virtual Cameraclone () const =0
virtual void configureProperties (CameraProperty &cameraProperty, bool attach)
virtual void deserialize (Deserializer &d) override
virtual double getAspectRatio () const
virtual std::string_view getClassIdentifier () const =0
virtual dvec4 getClipPosFromNormalizedDeviceCoords (const dvec3 &ndcCoords) const
 Convert from normalized device coordinates (xyz in [-1 1]) to clip coordinates, where z value of -1 correspond to the near plane and 1 to the far plane. Coordinates outside of the [-1 1]^3 range will be clipped.
dvec3 getDirection () const
 Get unnormalized direction of camera: lookTo - lookFrom.
double getFarPlaneDist () const
const dmat4 & getInverseProjectionMatrix () const
const dmat4 & getInverseViewMatrix () const
const dvec3 & getLookFrom () const
dvec3 getLookRight () const
const dvec3 & getLookTo () const
const dvec3 & getLookUp () const
double getNearPlaneDist () const
dvec3 getNormalizedDeviceFromNormalizedScreenAtFocusPointDepth (const dvec2 &normalizedScreenCoord) const
const dmat4 & getProjectionMatrix () const
const dmat4 & getViewMatrix () const
dvec3 getWorldPosFromNormalizedDeviceCoords (const dvec3 &ndcCoords) const
 Convert from normalized device coordinates (xyz in [-1 1]) to world coordinates.
Cameraoperator= (Camera &&other) noexcept=default
Cameraoperator= (const Camera &other)=default
virtual void serialize (Serializer &s) const override
virtual void setAspectRatio (double val)
virtual void setFarPlaneDist (double distance)
 Set distance to the far plane from lookFrom.
void setLook (dvec3 lookFrom, dvec3 lookTo, dvec3 lookUp)
virtual void setLookFrom (dvec3 val)
virtual void setLookTo (dvec3 val)
virtual void setLookUp (dvec3 val)
virtual void setNearPlaneDist (double distance)
 Set distance to the near plane from lookFrom.
virtual void updateFrom (const Camera &source)
virtual void zoom (const ZoomOptions &opts)=0

Protected Member Functions

virtual dmat4 calculateProjectionMatrix () const =0
 Calculate and return the projection matrix for the camera.
virtual dmat4 calculateViewMatrix () const
virtual bool equal (const Camera &other) const =0
bool equalTo (const Camera &other) const
void invalidateProjectionMatrix ()
void invalidateViewMatrix ()

Protected Attributes

double aspectRatio_
CameraPropertycamprop_ = nullptr
double farPlaneDist_
 Distance to the far plane from lookFrom.
bool invalidProjectionMatrix_
bool invalidViewMatrix_
dmat4 inverseProjectionMatrix_
dmat4 inverseViewMatrix_
dvec3 lookFrom_
dvec3 lookTo_
dvec3 lookUp_
double nearPlaneDist_
 Distance to the near plane from lookFrom.
dmat4 projectionMatrix_
dmat4 viewMatrix_

Friends

bool operator!= (const Camera &lhs, const Camera &rhs)
bool operator== (const Camera &lhs, const Camera &rhs)

Detailed Description

Base class for cameras. Override this class to set your own projection matrix.

See also
PerspectiveCamera
OrthographicCamera

Constructor & Destructor Documentation

◆ Camera()

inviwo::Camera::Camera ( dvec3 lookFrom,
dvec3 lookTo,
dvec3 lookUp,
double nearPlane,
double farPlane,
double aspectRatio )

Create a camera.

Default parameters creates a right handed coordinate system with camera looking towards the negative z-axis. with X = (1, 0, 0), Y = (0, 1, 0), Z = (0, 0, -1)

Parameters
lookFromCamera position (eye)
lookToCamera focus point (center)
lookUpCamera up direction
nearPlaneCamera near clip-plane
farPlaneCamera far clip-plane
aspectRatioCamera aspect ratio

Member Function Documentation

◆ calculateProjectionMatrix()

virtual dmat4 inviwo::Camera::calculateProjectionMatrix ( ) const
protectedpure virtual

Calculate and return the projection matrix for the camera.

Implement this function to provide your own projection computation functionality. For example orthogonal or perspective projection. This function will be called when the projection matrix is invalid.

See also
PerspectiveCamera
OrthographicCamera

Implemented in inviwo::OrthographicCamera, inviwo::PerspectiveCamera, inviwo::PlotCamera, inviwo::SGCTCamera, and inviwo::SkewedPerspectiveCamera.

◆ deserialize()

virtual void inviwo::Camera::deserialize ( Deserializer & d)
overridevirtual

Implements inviwo::Serializable.

◆ getClipPosFromNormalizedDeviceCoords()

virtual dvec4 inviwo::Camera::getClipPosFromNormalizedDeviceCoords ( const dvec3 & ndcCoords) const
virtual

Convert from normalized device coordinates (xyz in [-1 1]) to clip coordinates, where z value of -1 correspond to the near plane and 1 to the far plane. Coordinates outside of the [-1 1]^3 range will be clipped.

Parameters
ndcCoordsxyz clip-coordinates in [-1 1]^3, and the clip w-coordinate used for perspective division.
Returns
Clip space position

Reimplemented in inviwo::OrthographicCamera, and inviwo::PlotCamera.

◆ getWorldPosFromNormalizedDeviceCoords()

dvec3 inviwo::Camera::getWorldPosFromNormalizedDeviceCoords ( const dvec3 & ndcCoords) const

Convert from normalized device coordinates (xyz in [-1 1]) to world coordinates.

Parameters
ndcCoordsCoordinates in [-1 1]
Returns
World space position

◆ serialize()

virtual void inviwo::Camera::serialize ( Serializer & s) const
overridevirtual

Implements inviwo::Serializable.


The documentation for this class was generated from the following file:
  • include/inviwo/core/datastructures/camera/camera.h