|
| Camera () |
|
| ~Camera () |
|
virtual void | dispose () |
|
const Vec3 | getPosition () const |
|
void | setPosition (const Vec3 pos) |
|
const Vec3 | getDirection () const |
|
void | setDirection (const Vec3 vec) |
|
const Vec3 | getUp () const |
|
void | setUp (const Vec3 vec) |
|
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 |
|
virtual void | update ()=0 |
|
void | lookAt (const Vec3 target) |
|
void | lookAt (const Vec3 target, const Vec3 up) |
|
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 |
|
This is a base class for a camera.
The actual cameras are OrthographicCamera and PerspectiveCamera.This class hash the shared functionality for transforms and queries in 3d space. In particular, it has several methods that help you to select a 3d object with the mouse.
The design of this class ensures that the direction vector and the up vector of the camera are orthonormal at all times.
Ray cugl::Camera::getPickRay |
( |
const Vec3 |
windowCoords | ) |
const |
Returns a picking Ray from the coordinates given in window coordinates.
A picking ray is used to select an object in 3d space. It creates a ray into the screen based on a selection in the viewport. You can then use this ray to select an object.
Window coords are the location of the point in the viewport. Ideally, the viewport should be the same size as the screen, but these are not screen coordinates. The screen has the origin in the top left, while window coordinates still have the origin in the bottom left.
While the viewport is a flat 2d plane, this method still takes a 3d point. The z-coordinate corresponds to the position of the point in the z-buffer.
- Parameters
-
windowCoords | The point in window coordinates |
Returns a picking Ray from the coordinates given in window coordinates.
Ray cugl::Camera::getPickRay |
( |
const Vec3 |
windowCoords, |
|
|
const Rect |
viewport |
|
) |
| const |
Returns a picking Ray from the coordinates given in window coordinates.
A picking ray is used to select an object in 3d space. It creates a ray into the screen based on a selection in the viewport. You can then use this ray to select an object.
Window coords are the location of the point in the viewport. Ideally, the viewport should be the same size as the screen, but these are not screen coordinates. The screen has the origin in the top left, while window coordinates still have the origin in the bottom left.
While the viewport is a flat 2d plane, this method still takes a 3d point. The z-coordinate corresponds to the position of the point in the z-buffer.
- Parameters
-
windowCoords | The point in window coordinates |
viewport | The screen viewport |
Returns a picking Ray from the coordinates given in window coordinates.
Ray cugl::Camera::getPickRayFromScreen |
( |
const Vec2 |
screenCoords | ) |
const |
|
inline |
Returns a picking Ray from the coordinates given in screen coordinates.
A picking ray is used to select an object in 3d space. It creates a ray into the screen based on a selection in the viewport. You can then use this ray to select an object.
Screen coords differ from window coordinates, as the the origin is in the top left instad of the bottom left. The SDL event system uses screen space for input events, which is why this method is necessary.
- Parameters
-
screenCoords | The point in screen coordinates |
Returns a picking Ray from the coordinates given in screen coordinates.
Vec3 cugl::Camera::project |
( |
const Vec3 |
worldCoords | ) |
const |
Returns the window space equivalent of a point in world coordinates.
This is the same as GLU gluProject. Window coords are the location of the point in the viewport. Ideally, the viewport should be the same size as the screen, but these are not screen coordinates. The screen has the origin in the top left, while
While the viewport is a flat 2d plane, this method still returns a 3d point. The z-coordinate corresponds to the position of the point in the z-buffer.
- Parameters
-
worldCoords | The point in wprld coordinates |
- Returns
- the window space equivalent of a point in world coordinates.
Vec3 cugl::Camera::project |
( |
const Vec3 |
worldCoords, |
|
|
const Rect |
viewport |
|
) |
| const |
Returns the window space equivalent of a point in world coordinates.
This is the same as GLU gluProject. Window coords are the location of the point in the viewport. Ideally, the viewport should be the same size as the screen, but these are not screen coordinates. The screen has the origin in the top left, while
While the viewport is a flat 2d plane, this method still returns a 3d point. The z-coordinate corresponds to the position of the point in the z-buffer.
- Parameters
-
worldCoords | The point in world coordinates |
viewport | The screen viewport |
- Returns
- the window space equivalent of a point in world coordinates.
Vec3 cugl::Camera::screenToWindowCoords |
( |
const Vec2 |
screenCoords | ) |
const |
Returns the screen space equivalent of a point in window coordinates.
Ideally, window space and screen space would be the same space. They are both defined by the viewport and have the same offset and dimension. However, screen coordinates have the origin in the top left while window coordinates have the origin in the bottom left.
We need this conversion because events (such as mouse clicks) register in screen space, while drawing happens in window space.
While the viewport is a flat 2d plane, this method still takes a 3d point. The z-coordinate corresponds to the near position, closest to the screen.
- Parameters
-
screenCoords | The point in screen coordinates |
Vec3 cugl::Camera::screenToWindowCoords |
( |
const Vec2 |
screenCoords, |
|
|
const Rect |
viewport |
|
) |
| const |
Returns the screen space equivalent of a point in window coordinates.
Ideally, window space and screen space would be the same space. They are both defined by the viewport and have the same offset and dimension. However, screen coordinates have the origin in the top left while window coordinates have the origin in the bottom left.
We need this conversion because events (such as mouse clicks) register in screen space, while drawing happens in window space.
While the viewport is a flat 2d plane, this method still takes a 3d point. The z-coordinate corresponds to the near position, closest to the screen.
- Parameters
-
screenCoords | The point in screen coordinates |
viewport | The screen viewport |
Vec3 cugl::Camera::screenToWorldCoords |
( |
const Vec2 |
screenCoords | ) |
const |
|
inline |
Returns the world space equivalent of a point in screen coordinates.
Ideally, window space and screen space would be the same space. They are both defined by the viewport and have the same offset and dimension. However, screen coordinates have the origin in the top left while window coordinates have the origin in the bottom left.
In computing the world space coordinates, this method assumes that the z-value of the original vector is the same as near, which is the closest it can be the screen.
This method is important for converting event coordinates (such as a mouse click) to world coordinates.
- Parameters
-
screenCoords | The point in screen coordinates |
- Returns
- the world space equivalent of a point in screen coordinates.
Vec3 cugl::Camera::unproject |
( |
const Vec3 |
windowCoords | ) |
const |
Returns the world space equivalent of a point in window coordinates.
This is the same as GLU gluUnProject, but does not rely on OpenGL. Window coords are the location of the point in the viewport. Ideally, the viewport should be the same size as the screen, but these are not screen coordinates. The screen has the origin in the top left, while Window coordinates still have the origin in the bottom left.
While the viewport is a flat 2d plane, this method still requires a 3d point. The z-coordinate corresponds to the position of the point in the z-buffer.
- Parameters
-
windowCoords | The point in window coordinates |
- Returns
- the world space equivalent of a point in window coordinates.
Vec3 cugl::Camera::unproject |
( |
const Vec3 |
windowCoords, |
|
|
const Rect |
viewport |
|
) |
| const |
Returns the world space equivalent of a point in window coordinates.
This is the same as GLU gluUnProject, but does not rely on OpenGL. Window coords are the location of the point in the viewport. Ideally, the viewport should be the same size as the screen, but these are not screen coordinates. The screen has the origin in the top left, while Window coordinates still have the origin in the bottom left.
While the viewport is a flat 2d plane, this method still requires a 3d point. The z-coordinate corresponds to the position of the point in the z-buffer.
- Parameters
-
windowCoords | The point in window coordinates |
viewport | The screen viewport |
- Returns
- the world space equivalent of a point in window coordinates.
Vec2 cugl::Camera::windowToScreenCoords |
( |
const Vec3 |
windowCoords | ) |
const |
Returns the window space equivalent of a point in screen coordinates.
Ideally, window space and screen space would be the same space. They are both defined by the viewport and have the same offset and dimension. However, screen coordinates have the origin in the top left while window coordinates have the origin in the bottom left.
We need this conversion because events (such as mouse clicks) register in screen space, while drawing happens in window space.
- Parameters
-
windowCoords | The point in window coordinates |
Vec2 cugl::Camera::windowToScreenCoords |
( |
const Vec3 |
windowCoords, |
|
|
const Rect |
viewport |
|
) |
| const |
Returns the window space equivalent of a point in screen coordinates.
Ideally, window space and screen space would be the same space. They are both defined by the viewport and have the same offset and dimension. However, screen coordinates have the origin in the top left while window coordinates have the origin in the bottom left.
We need this conversion because events (such as mouse clicks) register in screen space, while drawing happens in window space.
- Parameters
-
windowCoords | The point in window coordinates |
viewport | The screen viewport |
Vec2 cugl::Camera::worldToScreenCoords |
( |
const Vec3 |
worldCoords | ) |
const |
|
inline |
Returns the screen space equivalent of a point in world coordinates.
Ideally, window space and screen space would be the same space. They are both defined by the viewport and have the same offset and dimension. However, screen coordinates have the origin in the top left while window coordinates have the origin in the bottom left.
This method is important for converting world coordinates to event coordinates (such as a mouse click).
- Parameters
-
worldCoords | The point in wprld coordinates |
- Returns
- the screen space equivalent of a point in world coordinates.