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 <camera.h>

+ Inheritance diagram for inviwo::Camera:

Public Member Functions

 Camera (vec3 lookFrom, vec3 lookTo, vec3 lookUp, float nearPlane, float farPlane, float aspectRatio)
 Create a camera.
 
 Camera (const Camera &other)=default
 
Cameraoperator= (const Camera &other)=default
 
 Camera (Camera &&other) noexcept=default
 
Cameraoperator= (Camera &&other) noexcept=default
 
virtual Cameraclone () const =0
 
virtual std::string_view getClassIdentifier () const =0
 
virtual void updateFrom (const Camera &source)
 
virtual void configureProperties (CameraProperty &cameraProperty, bool attach)
 
const vec3 & getLookFrom () const
 
virtual void setLookFrom (vec3 val)
 
const vec3 & getLookTo () const
 
virtual void setLookTo (vec3 val)
 
const vec3 & getLookUp () const
 
virtual void setLookUp (vec3 val)
 
virtual float getAspectRatio () const
 
virtual void setAspectRatio (float val)
 
virtual void zoom (float factor, std::optional< mat4 > boundingBox)=0
 
vec3 getDirection () const
 Get unnormalized direction of camera: lookTo - lookFrom.
 
virtual void setNearPlaneDist (float distance)
 Set distance to the near plane from lookFrom.
 
float getNearPlaneDist () const
 
virtual void setFarPlaneDist (float distance)
 Set distance to the far plane from lookFrom.
 
float getFarPlaneDist () const
 
const mat4 & getViewMatrix () const
 
const mat4 & getProjectionMatrix () const
 
const mat4 & getInverseViewMatrix () const
 
const mat4 & getInverseProjectionMatrix () const
 
vec3 getWorldPosFromNormalizedDeviceCoords (const vec3 &ndcCoords) const
 Convert from normalized device coordinates (xyz in [-1 1]) to world coordinates.
 
virtual vec4 getClipPosFromNormalizedDeviceCoords (const vec3 &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.
 
vec3 getNormalizedDeviceFromNormalizedScreenAtFocusPointDepth (const vec2 &normalizedScreenCoord) const
 
virtual void serialize (Serializer &s) const override
 
virtual void deserialize (Deserializer &d) override
 
- Public Member Functions inherited from inviwo::Serializable

Protected Member Functions

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

Protected Attributes

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

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 ( vec3 lookFrom,
vec3 lookTo,
vec3 lookUp,
float nearPlane,
float farPlane,
float 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 mat4 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::SGCTCamera, and inviwo::SkewedPerspectiveCamera.

◆ deserialize()

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

Implements inviwo::Serializable.

◆ getClipPosFromNormalizedDeviceCoords()

virtual vec4 inviwo::Camera::getClipPosFromNormalizedDeviceCoords ( const vec3 & 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.

◆ getWorldPosFromNormalizedDeviceCoords()

vec3 inviwo::Camera::getWorldPosFromNormalizedDeviceCoords ( const vec3 & 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: