CUGL 2.1
Cornell University Game Library
|
#include <CUOrthographicCamera.h>
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 Vec3 | getPosition () const |
const Vec3 | getDirection () const |
const Vec3 | getUp () const |
float | getNear () const |
void | setNear (float value) |
float | getFar () const |
void | setFar (float value) |
const Rect | getViewport () const |
const Mat4 & | getProjection () const |
const Mat4 & | getView () const |
const Mat4 & | getCombined () const |
const Mat4 & | getInverseProjectView () 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< OrthographicCamera > | alloc (const Size size, bool yDown=false) |
static std::shared_ptr< OrthographicCamera > | alloc (float width, float height, bool yDown=false) |
static std::shared_ptr< OrthographicCamera > | allocOffset (const Rect rect, bool yDown=false) |
static std::shared_ptr< OrthographicCamera > | allocOffset (const Vec2 origin, const Size size, bool yDown=false) |
static std::shared_ptr< OrthographicCamera > | allocOffset (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 |
This is a class for a camera with orthographic projection.
This camera is used by the Scene class.
|
inline |
Creates a degenerate camera.
All of the matrices are the identity and the viewport is empty.
|
inline |
Deletes this camera, disposing all resources.
|
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).
size | The viewport size |
yDown | Whether to put the origin in the top left corner |
|
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).
width | The viewport width |
height | The viewport height |
yDown | Whether to put the origin in the top left corner |
|
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).
rect | The viewport bounding box |
yDown | Whether to put the origin in the top left corner |
|
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).
origin | The viewport offset |
size | The viewport size |
yDown | Whether to put the origin in the top left corner |
|
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).
x | The viewport x offset |
y | The viewport y offset |
width | The viewport width |
height | The viewport height |
yDown | Whether to put the origin in the top left corner |
|
overridevirtual |
Returns this camera to the denegerate one, with all matrices the identity.
Reimplemented from cugl::Camera.
|
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.
|
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).
size | The viewport size |
yDown | Whether to put the origin in the top left corner |
|
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).
width | The viewport width |
height | The viewport height |
yDown | Whether to put the origin in the top left corner |
|
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).
rect | The viewport bounding box |
yDown | Whether to put the origin in the top left corner |
|
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).
origin | The viewport offset |
size | The viewport size |
yDown | Whether to put the origin in the top left corner |
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).
x | The viewport x offset |
y | The viewport y offset |
width | The viewport width |
height | The viewport height |
yDown | Whether to put the origin in the top left corner |
|
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).
rect | The viewport bounding box |
yDown | Whether to put the origin in the top left corner |
|
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).
size | The viewport size |
yDown | Whether to put the origin in the top left corner |
|
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).
origin | The viewport offset |
size | The viewport size |
yDown | Whether to put the origin in the top left corner |
|
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).
width | The viewport width |
height | The viewport height |
yDown | Whether 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).
x | The viewport x offset |
y | The viewport y offset |
width | The viewport width |
height | The viewport height |
yDown | Whether 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.
zoom | The magnification zoom |
|
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.
|
protected |
Whether or not the camera has been initialized
|
protected |
The magnification zoom of the camera