scenepic 1.1.0
3D Visualization Made Easy
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
scenepic::Camera Class Reference

A camera type. More...

#include <camera.h>

Public Member Functions

 Camera (const Vector &center, const Transform &rotation, double fov_y_degrees=45.0, double near_crop_distance=0.01, double far_crop_distance=20.0, double aspect_ratio=1.0)
 Constructor. More...
 
 Camera (const Transform &world_to_camera, double fov_y_degrees=45.0, double near_crop_distance=0.01, double far_crop_distance=20.0, double aspect_ratio=1.0)
 Constructor. More...
 
 Camera (const Transform &world_to_camera, const Transform &projection)
 Constructor. More...
 
 Camera (const Vector &center=Vector(0, 0, 4), const Vector &look_at=Vector(0, 0, 0), const Vector &up_dir=Vector(0, 1, 0), double fov_y_degrees=45.0, double near_crop_distance=0.01, double far_crop_distance=20.0, double aspect_ratio=1.0)
 Constructor. More...
 
Transform rotation () const
 The camera rotation matrix. More...
 
Vector center () const
 The camera center. More...
 
Vector look_at () const
 Where the camera is looking. More...
 
Vector up_dir () const
 The direction that is "up" for the camera. More...
 
float aspect_ratio () const
 The aspect ratio of the camera projection. More...
 
Cameraaspect_ratio (float aspect_ratio)
 The aspect ratio of the camera projection. More...
 
const Transform & camera_to_world () const
 The transform placing the camera in the scene. More...
 
const Transform & world_to_camera () const
 The transform placing the world in camera coordinates. More...
 
const Transform & projection () const
 The GL project matrix, transforming from camera view coordinates to NDC. More...
 
virtual JsonValue to_json () const
 Convert this object into ScenePic json. More...
 
std::string to_string () const
 Return a JSON string representing the object. More...
 
bool is_none () const
 Whether this is a "no camera" instance. More...
 

Static Public Member Functions

static Camera None ()
 A value indicating "no camera". More...
 
static std::vector< Cameraorbit (int num_frames, float distance, int num_times, float min_altitude=0.25, float max_altitude=0.8, Vector up_dir={0, 1, 0}, Vector forward_dir={0, 0, 1}, double fov_y_degrees=45.0, double aspect_ratio=1.0, double near_crop_distance=0.01, double far_crop_distance=20.0)
 Creates a sequence of cameras which move in an orbit around the origin. More...
 

Protected Attributes

Transform m_camera_to_world
 
Transform m_world_to_camera
 
Transform m_projection
 

Detailed Description

A camera type.

Constructor & Destructor Documentation

◆ Camera() [1/4]

scenepic::Camera::Camera ( const Vector &  center,
const Transform &  rotation,
double  fov_y_degrees = 45.0,
double  near_crop_distance = 0.01,
double  far_crop_distance = 20.0,
double  aspect_ratio = 1.0 
)

Constructor.

Parameters
centerthe camera center in world coordinates
rotationthe camera rotation matrix
fov_y_degreesvertical field of view in degrees
near_crop_distancethe near clipping plane of the view frustum
far_crop_distancethe far clipping plane of the view frustum
aspect_ratiothe aspect ratio of the image

◆ Camera() [2/4]

scenepic::Camera::Camera ( const Transform &  world_to_camera,
double  fov_y_degrees = 45.0,
double  near_crop_distance = 0.01,
double  far_crop_distance = 20.0,
double  aspect_ratio = 1.0 
)

Constructor.

Parameters
world_to_camerathe world-to-camera transform.
fov_y_degreesvertical field of view in degrees
near_crop_distancethe near clipping plane of the view frustum
far_crop_distancethe far clipping plane of the view frustum
aspect_ratiothe aspect ratio of the image

◆ Camera() [3/4]

scenepic::Camera::Camera ( const Transform &  world_to_camera,
const Transform &  projection 
)

Constructor.

Parameters
world_to_camerathe world-to-camera transform.
projectionmatrix translating view coordinates to NDC

◆ Camera() [4/4]

scenepic::Camera::Camera ( const Vector &  center = Vector(0, 0, 4),
const Vector &  look_at = Vector(0, 0, 0),
const Vector &  up_dir = Vector(0, 1, 0),
double  fov_y_degrees = 45.0,
double  near_crop_distance = 0.01,
double  far_crop_distance = 20.0,
double  aspect_ratio = 1.0 
)

Constructor.

Parameters
centerthe camera center
look_atwhere the camera is looking
up_dirthe direction that is "up" for the camera
fov_y_degreesvertical field of view in degrees
near_crop_distancethe near clipping plane of the view frustum
far_crop_distancethe far clipping plane of the view frustum
aspect_ratiothe aspect ratio of the image

Member Function Documentation

◆ aspect_ratio() [1/2]

float scenepic::Camera::aspect_ratio ( ) const

The aspect ratio of the camera projection.

◆ aspect_ratio() [2/2]

Camera & scenepic::Camera::aspect_ratio ( float  aspect_ratio)

The aspect ratio of the camera projection.

◆ camera_to_world()

const Transform & scenepic::Camera::camera_to_world ( ) const

The transform placing the camera in the scene.

◆ center()

Vector scenepic::Camera::center ( ) const

The camera center.

◆ is_none()

bool scenepic::Camera::is_none ( ) const

Whether this is a "no camera" instance.

◆ look_at()

Vector scenepic::Camera::look_at ( ) const

Where the camera is looking.

◆ None()

static Camera scenepic::Camera::None ( )
static

A value indicating "no camera".

◆ orbit()

static std::vector< Camera > scenepic::Camera::orbit ( int  num_frames,
float  distance,
int  num_times,
float  min_altitude = 0.25,
float  max_altitude = 0.8,
Vector  up_dir = {0, 1, 0},
Vector  forward_dir = {0, 0, 1},
double  fov_y_degrees = 45.0,
double  aspect_ratio = 1.0,
double  near_crop_distance = 0.01,
double  far_crop_distance = 20.0 
)
static

Creates a sequence of cameras which move in an orbit around the origin.

Parameters
num_framesthe number of frames in the sequence
distancethe distance of the camera from the origin
num_timesthe number of times to orbit
min_altitudethe minimum altitude of the orbit
max_altitudethe maximum altitude of the orbit
up_dirthe direction that is up
forward_dirthe direction that is forward
fov_y_degreesthe field of view of the camera in degrees
aspect_ratiothe aspect ratio of the camera
near_crop_distancethe near clipping plane of the view frustum
far_crop_distancethe far clipping plane of the view frustum
Returns
a sequence of cameras moving in an orbit

◆ projection()

const Transform & scenepic::Camera::projection ( ) const

The GL project matrix, transforming from camera view coordinates to NDC.

◆ rotation()

Transform scenepic::Camera::rotation ( ) const

The camera rotation matrix.

◆ to_json()

virtual JsonValue scenepic::Camera::to_json ( ) const
virtual

Convert this object into ScenePic json.

Returns
a json value

◆ to_string()

std::string scenepic::Camera::to_string ( ) const

Return a JSON string representing the object.

◆ up_dir()

Vector scenepic::Camera::up_dir ( ) const

The direction that is "up" for the camera.

◆ world_to_camera()

const Transform & scenepic::Camera::world_to_camera ( ) const

The transform placing the world in camera coordinates.

Member Data Documentation

◆ m_camera_to_world

Transform scenepic::Camera::m_camera_to_world
protected

◆ m_projection

Transform scenepic::Camera::m_projection
protected

◆ m_world_to_camera

Transform scenepic::Camera::m_world_to_camera
protected

The documentation for this class was generated from the following file: