CUGL
Cornell University Game Library
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
cugl::OrthographicCamera Class Reference

#include <CUOrthographicCamera.h>

Inheritance diagram for cugl::OrthographicCamera:
cugl::Camera

Public Member Functions

 OrthographicCamera ()
 
 ~OrthographicCamera ()
 
void dispose () override
 
bool init (const Size &size, bool yDown=false)
 
bool init (float width, float height, bool yDown=false)
 
bool initOffset (const Rect &rect, bool yDown=false)
 
bool initOffset (const Vec2 &origin, const Size &size, bool yDown=false)
 
bool initOffset (float x, float y, float width, float height, bool yDown=false)
 
void set (const Size &size, bool yDown=false)
 
void set (float width, float height, bool yDown=false)
 
void set (const Rect &rect, bool yDown=false)
 
void set (const Vec2 &origin, const Size &size, bool yDown=false)
 
void set (float x, float y, float width, float height, bool yDown=false)
 
void update () override
 
float getZoom () const
 
void setZoom (float zoom)
 
- Public Member Functions inherited from cugl::Camera
 Camera ()
 
 ~Camera ()
 
const Vec3getPosition () const
 
const Vec3getDirection () const
 
const Vec3getUp () const
 
float getNear () const
 
void setNear (float value)
 
float getFar () const
 
void setFar (float value)
 
const RectgetViewport () const
 
const Mat4getProjection () const
 
const Mat4getView () const
 
const Mat4getCombined () const
 
const Mat4getInverseProjectView () const
 
void lookAt (const Vec3 &target)
 
void lookAt (float x, float y, float z)
 
void normalizeUp ()
 
void rotate (const Quaternion &quat)
 
void rotate (const Vec3 &axis, float angle)
 
void rotateX (float angle)
 
void rotateY (float angle)
 
void rotateZ (float angle)
 
void rotate (float angle)
 
void rotate (const Mat4 &transform)
 
void rotateAround (const Vec3 &point, const Vec3 &axis, float angle)
 
void translate (const Vec3 &vec)
 
void translate (const Vec2 &vec)
 
void translate (float tx, float ty, float tz)
 
void translate (float tx, float ty)
 
void transform (const Mat4 &transform)
 
Vec3 unproject (const Vec3 &windowCoords) const
 
Vec3 unproject (const Vec3 &windowCoords, const Rect &viewport) const
 
Vec3 screenToWorldCoords (const Vec2 &screenCoords) const
 
Vec3 project (const Vec3 &worldCoords) const
 
Vec3 project (const Vec3 &worldCoords, const Rect &viewport) const
 
Vec2 worldToScreenCoords (const Vec3 &worldCoords) const
 
Ray getPickRay (const Vec3 &windowCoords) const
 
Ray getPickRay (const Vec3 &windowCoords, const Rect &viewport) const
 
Ray getPickRayFromScreen (const Vec2 &screenCoords) const
 
Vec2 windowToScreenCoords (const Vec3 &windowCoords) const
 
Vec2 windowToScreenCoords (const Vec3 &windowCoords, const Rect &viewport) const
 
Vec3 screenToWindowCoords (const Vec2 &screenCoords) const
 
Vec3 screenToWindowCoords (const Vec2 &screenCoords, const Rect &viewport) const
 

Static Public Member Functions

static std::shared_ptr< OrthographicCameraalloc (const Size &size, bool yDown=false)
 
static std::shared_ptr< OrthographicCameraalloc (float width, float height, bool yDown=false)
 
static std::shared_ptr< OrthographicCameraallocOffset (const Rect &rect, bool yDown=false)
 
static std::shared_ptr< OrthographicCameraallocOffset (const Vec2 &origin, const Size &size, bool yDown=false)
 
static std::shared_ptr< OrthographicCameraallocOffset (float x, float y, float width, float height, bool yDown=false)
 

Protected Attributes

float _zoom
 
bool _initialized
 
- Protected Attributes inherited from cugl::Camera
Vec3 _position
 
Vec3 _direction
 
Vec3 _upwards
 
Mat4 _projection
 
Mat4 _modelview
 
Mat4 _combined
 
Mat4 _inverse
 
float _near
 
float _far
 
Rect _viewport
 

Detailed Description

This is a class for a camera with orthographic projection.

This camera is used by the Scene class.

Constructor & Destructor Documentation

cugl::OrthographicCamera::OrthographicCamera ( )
inline

Creates a degenerate camera.

All of the matrices are the identity and the viewport is empty.

cugl::OrthographicCamera::~OrthographicCamera ( )
inline

Deletes this camera, disposing all resources.

Member Function Documentation

static std::shared_ptr<OrthographicCamera> cugl::OrthographicCamera::alloc ( const Size size,
bool  yDown = false 
)
inlinestatic

Returns a newly allocated OrthographicCamera for the given viewport.

The viewport origin is assumed to be (0,0).

If yDown is true, the origin will be at the top left corner (similar to screen coordinates). Otherwise, it will place the origin at the traditional OpenGL origin (bottom left corner).

Parameters
sizeThe viewport size
yDownWhether to put the origin in the top left corner
Returns
a newly allocated OrthographicCamera for the given viewport.
static std::shared_ptr<OrthographicCamera> cugl::OrthographicCamera::alloc ( float  width,
float  height,
bool  yDown = false 
)
inlinestatic

Returns a newly allocated OrthographicCamera for the given viewport.

The viewport origin is assumed to be (0,0).

If yDown is true, the origin will be at the top left corner (similar to screen coordinates). Otherwise, it will place the origin at the traditional OpenGL origin (bottom left corner).

Parameters
widthThe viewport width
heightThe viewport height
yDownWhether to put the origin in the top left corner
Returns
a newly allocated OrthographicCamera for the given viewport.
static std::shared_ptr<OrthographicCamera> cugl::OrthographicCamera::allocOffset ( const Rect rect,
bool  yDown = false 
)
inlinestatic

Returns a newly allocated OrthographicCamera for the given viewport.

Offseting the viewport origin has no affect on the position attribute. It only affects the coordinate conversion methods Camera#project() and Camera#unproject(). It is supposed to represent the offset of the viewport in a larger canvas.

If yDown is true, the origin will be at the top left corner (similar to screen coordinates). Otherwise, it will place the origin at the traditional OpenGL origin (bottom left corner).

Parameters
rectThe viewport bounding box
yDownWhether to put the origin in the top left corner
Returns
a newly allocated OrthographicCamera for the given viewport.
static std::shared_ptr<OrthographicCamera> cugl::OrthographicCamera::allocOffset ( const Vec2 origin,
const Size size,
bool  yDown = false 
)
inlinestatic

Returns a newly allocated OrthographicCamera for the given viewport.

Offseting the viewport origin has no affect on the position attribute. It only affects the coordinate conversion methods Camera#project() and Camera#unproject(). It is supposed to represent the offset of the viewport in a larger canvas.

If yDown is true, the origin will be at the top left corner (similar to screen coordinates). Otherwise, it will place the origin at the traditional OpenGL origin (bottom left corner).

Parameters
originThe viewport offset
sizeThe viewport size
yDownWhether to put the origin in the top left corner
Returns
a newly allocated OrthographicCamera for the given viewport.
static std::shared_ptr<OrthographicCamera> cugl::OrthographicCamera::allocOffset ( float  x,
float  y,
float  width,
float  height,
bool  yDown = false 
)
inlinestatic

Returns a newly allocated OrthographicCamera for the given viewport.

Offseting the viewport origin has no affect on the position attribute. It only affects the coordinate conversion methods Camera#project() and Camera#unproject(). It is supposed to represent the offset of the viewport in a larger canvas.

If yDown is true, the origin will be at the top left corner (similar to screen coordinates). Otherwise, it will place the origin at the traditional OpenGL origin (bottom left corner).

Parameters
xThe viewport x offset
yThe viewport y offset
widthThe viewport width
heightThe viewport height
yDownWhether to put the origin in the top left corner
Returns
a newly allocated OrthographicCamera for the given viewport.
void cugl::OrthographicCamera::dispose ( )
overridevirtual

Returns this camera to the denegerate one, with all matrices the identity.

Reimplemented from cugl::Camera.

float cugl::OrthographicCamera::getZoom ( ) const
inline

Returns the magnification zoom of this camera.

Large values make the images larger. So, 2x magnification makes images twices as large and effectively halves the viewport.

Returns
the magnification zoom of this camera.
bool cugl::OrthographicCamera::init ( const Size size,
bool  yDown = false 
)
inline

Initializes an OrthographicCamera for the given viewport.

The viewport origin is assumed to be (0,0).

If yDown is true, the origin will be at the top left corner (similar to screen coordinates). Otherwise, it will place the origin at the traditional OpenGL origin (bottom left corner).

Parameters
sizeThe viewport size
yDownWhether to put the origin in the top left corner
Returns
true if initialization was successful.
bool cugl::OrthographicCamera::init ( float  width,
float  height,
bool  yDown = false 
)
inline

Initializes an OrthographicCamera for the given viewport.

The viewport origin is assumed to be (0,0).

If yDown is true, the origin will be at the top left corner (similar to screen coordinates). Otherwise, it will place the origin at the traditional OpenGL origin (bottom left corner).

Parameters
widthThe viewport width
heightThe viewport height
yDownWhether to put the origin in the top left corner
Returns
true if initialization was successful.
bool cugl::OrthographicCamera::initOffset ( const Rect rect,
bool  yDown = false 
)
inline

Initializes an OrthographicCamera for the given viewport.

Offseting the viewport origin has no affect on the position attribute. It only affects the coordinate conversion methods Camera#project() and Camera#unproject(). It is supposed to represent the offset of the viewport in a larger canvas.

If yDown is true, the origin will be at the top left corner (similar to screen coordinates). Otherwise, it will place the origin at the traditional OpenGL origin (bottom left corner).

Parameters
rectThe viewport bounding box
yDownWhether to put the origin in the top left corner
Returns
true if initialization was successful.
bool cugl::OrthographicCamera::initOffset ( const Vec2 origin,
const Size size,
bool  yDown = false 
)
inline

Initializes an OrthographicCamera for the given viewport.

Offseting the viewport origin has no affect on the position attribute. It only affects the coordinate conversion methods Camera#project() and Camera#unproject(). It is supposed to represent the offset of the viewport in a larger canvas.

If yDown is true, the origin will be at the top left corner (similar to screen coordinates). Otherwise, it will place the origin at the traditional OpenGL origin (bottom left corner).

Parameters
originThe viewport offset
sizeThe viewport size
yDownWhether to put the origin in the top left corner
Returns
true if initialization was successful.
bool cugl::OrthographicCamera::initOffset ( float  x,
float  y,
float  width,
float  height,
bool  yDown = false 
)

Initializes an OrthographicCamera for the given viewport.

Offseting the viewport origin has no affect on the position attribute. It only affects the coordinate conversion methods Camera#project() and Camera#unproject(). It is supposed to represent the offset of the viewport in a larger canvas.

If yDown is true, the origin will be at the top left corner (similar to screen coordinates). Otherwise, it will place the origin at the traditional OpenGL origin (bottom left corner).

Parameters
xThe viewport x offset
yThe viewport y offset
widthThe viewport width
heightThe viewport height
yDownWhether to put the origin in the top left corner
Returns
true if initialization was successful.
void cugl::OrthographicCamera::set ( const Size size,
bool  yDown = false 
)
inline

Sets this OrthographicCamera to have the given viewport.

The viewport origin is assumed to be (0,0).

If yDown is true, the origin will be at the top left corner (similar to screen coordinates). Otherwise, it will place the origin at the traditional OpenGL origin (bottom left corner).

Parameters
sizeThe viewport size
yDownWhether to put the origin in the top left corner
void cugl::OrthographicCamera::set ( float  width,
float  height,
bool  yDown = false 
)
inline

Sets this OrthographicCamera to have the given viewport.

The viewport origin is assumed to be (0,0).

If yDown is true, the origin will be at the top left corner (similar to screen coordinates). Otherwise, it will place the origin at the traditional OpenGL origin (bottom left corner).

Parameters
widthThe viewport width
heightThe viewport height
yDownWhether to put the origin in the top left corner
void cugl::OrthographicCamera::set ( const Rect rect,
bool  yDown = false 
)
inline

Sets this OrthographicCamera to have the given viewport.

Offseting the viewport origin has no affect on the position attribute. It only affects the coordinate conversion methods Camera#project() and Camera#unproject(). It is supposed to represent the offset of the viewport in a larger canvas.

If yDown is true, the origin will be at the top left corner (similar to screen coordinates). Otherwise, it will place the origin at the traditional OpenGL origin (bottom left corner).

Parameters
rectThe viewport bounding box
yDownWhether to put the origin in the top left corner
void cugl::OrthographicCamera::set ( const Vec2 origin,
const Size size,
bool  yDown = false 
)
inline

Sets this OrthographicCamera to have the given viewport.

Offseting the viewport origin has no affect on the position attribute. It only affects the coordinate conversion methods Camera#project() and Camera#unproject(). It is supposed to represent the offset of the viewport in a larger canvas.

If yDown is true, the origin will be at the top left corner (similar to screen coordinates). Otherwise, it will place the origin at the traditional OpenGL origin (bottom left corner).

Parameters
originThe viewport offset
sizeThe viewport size
yDownWhether to put the origin in the top left corner
void cugl::OrthographicCamera::set ( float  x,
float  y,
float  width,
float  height,
bool  yDown = false 
)

Sets this OrthographicCamera to have the given viewport.

Offseting the viewport origin has no affect on the position attribute. It only affects the coordinate conversion methods Camera#project() and Camera#unproject(). It is supposed to represent the offset of the viewport in a larger canvas.

If yDown is true, the origin will be at the top left corner (similar to screen coordinates). Otherwise, it will place the origin at the traditional OpenGL origin (bottom left corner).

Parameters
xThe viewport x offset
yThe viewport y offset
widthThe viewport width
heightThe viewport height
yDownWhether to put the origin in the top left corner
void cugl::OrthographicCamera::setZoom ( float  zoom)

Sets the magnification zoom of this camera.

Large values make the images larger. So, 2x magnification makes images twices as large and effectively halves the viewport.

Changing this value will have no effect on the underlying matrices until you call the update() method.

Parameters
zoomThe magnification zoom
void cugl::OrthographicCamera::update ( )
overridevirtual

Recalculates the projection and view matrix of this camera.

Use this after you've manipulated any of the attributes of the camera.

Implements cugl::Camera.

Member Data Documentation

bool cugl::OrthographicCamera::_initialized
protected

Whether or not the camera has been initialized

float cugl::OrthographicCamera::_zoom
protected

The magnification zoom of the camera


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