CUGL 2.1
Cornell University Game Library
|
#include <CUPerspectiveCamera.h>
Public Member Functions | |
PerspectiveCamera () | |
~PerspectiveCamera () | |
void | dispose () override |
bool | init (const Size size, float fieldOfView=DEFAULT_CAMERA_FOV) |
bool | init (float width, float height, float fieldOfView=DEFAULT_CAMERA_FOV) |
bool | init (const Rect rect, float fieldOfView=DEFAULT_CAMERA_FOV) |
bool | init (const Vec2 origin, const Size size, float fieldOfView=DEFAULT_CAMERA_FOV) |
bool | init (float x, float y, float width, float height, float fieldOfView=DEFAULT_CAMERA_FOV) |
void | set (const Size size, float fieldOfView=DEFAULT_CAMERA_FOV) |
void | set (float width, float height, float fieldOfView=DEFAULT_CAMERA_FOV) |
void | set (const Rect rect, float fieldOfView=DEFAULT_CAMERA_FOV) |
void | set (const Vec2 origin, const Size size, float fieldOfView=DEFAULT_CAMERA_FOV) |
void | set (float x, float y, float width, float height, float fieldOfView=DEFAULT_CAMERA_FOV) |
void | update () override |
float | getFieldOfView () const |
void | setFieldOfView (float fov) |
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< PerspectiveCamera > | alloc (const Size size, float fieldOfView=DEFAULT_CAMERA_FOV) |
static std::shared_ptr< PerspectiveCamera > | alloc (float width, float height, float fieldOfView=DEFAULT_CAMERA_FOV) |
static std::shared_ptr< PerspectiveCamera > | alloc (const Rect rect, float fieldOfView=DEFAULT_CAMERA_FOV) |
static std::shared_ptr< PerspectiveCamera > | alloc (const Vec2 origin, const Size size, float fieldOfView=DEFAULT_CAMERA_FOV) |
static std::shared_ptr< PerspectiveCamera > | alloc (float x, float y, float width, float height, float fieldOfView=DEFAULT_CAMERA_FOV) |
Protected Attributes | |
float | _fieldOfView = 67 |
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 a perspective projection.
This camera is used for 3d rendering.
|
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 |
Initializes a new PerspectiveCamera for the given viewport and field of view.
The field of view given is for the height, and is measured in degrees. The field of view for the width will be calculated according to the aspect ratio. Furthermore, the aspect ratio is derived from the viewport size.
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.
rect | The viewport bounding box |
fieldOfView | The field of view of the height, in degrees |
|
inlinestatic |
Initializes a new PerspectiveCamera for the given viewport and field of view.
The field of view given is for the height, and is measured in degrees. The field of view for the width will be calculated according to the aspect ratio. Furthermore, the aspect ratio is derived from the viewport size.
The viewport origin is assumed to be (0,0).
size | The viewport size |
fieldOfView | The field of view of the height, in degrees |
|
inlinestatic |
Initializes a new PerspectiveCamera for the given viewport and field of view.
The field of view given is for the height, and is measured in degrees. The field of view for the width will be calculated according to the aspect ratio. Furthermore, the aspect ratio is derived from the viewport size.
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.
origin | The viewport offset |
size | The viewport size |
fieldOfView | The field of view of the height, in degrees |
|
inlinestatic |
Initializes a new PerspectiveCamera for the given viewport and field of view.
The field of view given is for the height, and is measured in degrees. The field of view for the width will be calculated according to the aspect ratio. Furthermore, the aspect ratio is derived from the viewport size.
The viewport origin is assumed to be (0,0).
width | The viewport width |
height | The viewport height |
fieldOfView | The field of view of the height, in degrees |
|
inlinestatic |
Initializes a new PerspectiveCamera for the given viewport and field of view.
The field of view given is for the height, and is measured in degrees. The field of view for the width will be calculated according to the aspect ratio. Furthermore, the aspect ratio is derived from the viewport size.
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.
x | The viewport x offset |
y | The viewport y offset |
width | The viewport width |
height | The viewport height |
fieldOfView | The field of view of the height, in degrees |
|
overridevirtual |
Returns this camera to the denegerate one, with all matrices the identity.
Reimplemented from cugl::Camera.
|
inline |
Returns the field of view for the given camera.
The field of view given is for the height, and is measured in degrees. The field of view for the width will be calculated according to the aspect ratio. Furthermore, the aspect ratio is derived from the viewport size.
|
inline |
Initializes a new PerspectiveCamera for the given viewport and field of view.
The field of view given is for the height, and is measured in degrees. The field of view for the width will be calculated according to the aspect ratio. Furthermore, the aspect ratio is derived from the viewport size.
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.
rect | The viewport bounding box |
fieldOfView | The field of view of the height, in degrees |
|
inline |
Initializes a new PerspectiveCamera for the given viewport and field of view.
The field of view given is for the height, and is measured in degrees. The field of view for the width will be calculated according to the aspect ratio. Furthermore, the aspect ratio is derived from the viewport size.
The viewport origin is assumed to be (0,0).
size | The viewport size |
fieldOfView | The field of view of the height, in degrees |
|
inline |
Initializes a new PerspectiveCamera for the given viewport and field of view.
The field of view given is for the height, and is measured in degrees. The field of view for the width will be calculated according to the aspect ratio. Furthermore, the aspect ratio is derived from the viewport size.
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.
origin | The viewport offset |
size | The viewport size |
fieldOfView | The field of view of the height, in degrees |
|
inline |
Initializes a new PerspectiveCamera for the given viewport and field of view.
The field of view given is for the height, and is measured in degrees. The field of view for the width will be calculated according to the aspect ratio. Furthermore, the aspect ratio is derived from the viewport size.
The viewport origin is assumed to be (0,0).
width | The viewport width |
height | The viewport height |
fieldOfView | The field of view of the height, in degrees |
bool cugl::PerspectiveCamera::init | ( | float | x, |
float | y, | ||
float | width, | ||
float | height, | ||
float | fieldOfView = DEFAULT_CAMERA_FOV |
||
) |
Initializes a new PerspectiveCamera for the given viewport and field of view.
The field of view given is for the height, and is measured in degrees. The field of view for the width will be calculated according to the aspect ratio. Furthermore, the aspect ratio is derived from the viewport size.
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.
x | The viewport x offset |
y | The viewport y offset |
width | The viewport width |
height | The viewport height |
fieldOfView | The field of view of the height, in degrees |
|
inline |
Sets this PerspectiveCamera to have the given viewport and field of view.
The field of view given is for the height, and is measured in degrees. The field of view for the width will be calculated according to the aspect ratio. Furthermore, the aspect ratio is derived from the viewport size.
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.
rect | The viewport bounding box |
fieldOfView | The field of view of the height, in degrees |
|
inline |
Sets this PerspectiveCamera to have the given viewport and field of view.
The field of view given is for the height, and is measured in degrees. The field of view for the width will be calculated according to the aspect ratio. Furthermore, the aspect ratio is derived from the viewport size.
The viewport origin is assumed to be (0,0).
size | The viewport size |
fieldOfView | The field of view of the height, in degrees |
|
inline |
Sets this PerspectiveCamera to have the given viewport and field of view.
The field of view given is for the height, and is measured in degrees. The field of view for the width will be calculated according to the aspect ratio. Furthermore, the aspect ratio is derived from the viewport size.
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.
origin | The viewport offset |
size | The viewport size |
fieldOfView | The field of view of the height, in degrees |
|
inline |
Sets this PerspectiveCamera to have the given viewport and field of view.
The field of view given is for the height, and is measured in degrees. The field of view for the width will be calculated according to the aspect ratio. Furthermore, the aspect ratio is derived from the viewport size.
The viewport origin is assumed to be (0,0).
width | The viewport width |
height | The viewport height |
fieldOfView | The field of view of the height, in degrees |
void cugl::PerspectiveCamera::set | ( | float | x, |
float | y, | ||
float | width, | ||
float | height, | ||
float | fieldOfView = DEFAULT_CAMERA_FOV |
||
) |
Sets this PerspectiveCamera to have the given viewport and field of view.
The field of view given is for the height, and is measured in degrees. The field of view for the width will be calculated according to the aspect ratio. Furthermore, the aspect ratio is derived from the viewport size.
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.
x | The viewport x offset |
y | The viewport y offset |
width | The viewport width |
height | The viewport height |
fieldOfView | The field of view of the height, in degrees |
void cugl::PerspectiveCamera::setFieldOfView | ( | float | fov | ) |
Sets the field of view for the given camera.
The field of view given is for the height, and is measured in degrees. The field of view for the width will be calculated according to the aspect ratio. Furthermore, the aspect ratio is derived from the viewport size.
Changing this value will have no effect on the underlying matrices until you call the update() method.
fov | the field of view for the given camera. |
|
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 |
The field of view of the height, in degrees
|
protected |
Whether or not the camera has been initialized