jubilant-funicular
|
#include <Camera2D.h>
Public Member Functions | |
Camera2D () | |
Camera2D (crvec2 center) | |
Camera2D (crvec2 center, crvec2 dimensions) | |
Camera2D (crvec2 center, crvec2 dimensions, float orientation) | |
~Camera2D () | |
destructor | |
glm::mat3 | getTranslationMatrix () const |
glm::mat3 | getRotationMatrix () const |
glm::mat3 | getInverseRotationMatrix () const |
glm::mat3 | getDilationMatrix () const |
glm::mat3 | getCameraMatrix () const |
glm::mat3 | getInverseCameraMatrix () const |
glm::vec4 | getBoundsCenter () const |
returns camera bounds in the given format | |
glm::vec4 | getBoundsTopLeft () const |
glm::vec2 | getCenter () const |
returns the center, top left coordinate, and (half) dimensions of the camera's view | |
glm::vec2 | getTopLeft () const |
glm::vec2 | getDimensions () const |
glm::vec2 | getRotatedDimensions () const |
float | getOrientation () const |
std::tuple< glm::vec2, glm::vec2 > | getAxes () const |
returns (normalized) axes aligned with the camera | |
glm::vec2 | mouseToGame (crvec2 mouse, crvec2 windowDimensions) const |
converts mouse coordinates to world coordinates | |
glm::vec2 | screenToGame (crvec2 screen) const |
bool | inBounds (crvec2 pt) const |
Returns true if this pt is contained within the camera. | |
bool | inBounds (float x, float y) const |
bool | isVisible (const std::vector< glm::vec2 > &polygon) const |
Returns ture if this polygon would show up in the camera. | |
void | setCenter (crvec2 center) |
sets the values of the camera's fields | |
void | setCenter (float x, float y) |
void | setDimensions (crvec2 dimensions) |
void | setDimensions (float w, float h) |
void | setOrientation (float t) |
void | translateCenter (crvec2 translation, bool move_along_axes=false) |
void | translateCenter (float dx, float dy, bool move_along_axes=false) |
void | scaleDimensions (crvec2 dilation) |
scales the camera's field of view | |
void | scaleDimensions (float dw, float dh) |
void | rotate (float dt) |
rotates the camera | |
Private Attributes | |
glm::vec2 | m_center |
center of the camera's view in world coordinates | |
glm::vec2 | m_dimensions |
half dimensions of camera's view in world coordinates | |
float | m_orientation |
rotation about axis orthogonal to the world | |
represents a camera in two dimensions from which the world is viewed
You can imagine the 2D world is flat against the wall, and this camera is facing that wall. You can move the camera in space (i.e. setCenter/setDimensions), and it can be rotated about an axis orthogonal to the world, through its center.
Definition at line 13 of file Camera2D.h.
nta::Camera2D::Camera2D | ( | ) |
Constructs a new Camera2D. By default, the center is at (0,0), the dimensions are (100, 100), and orientation is 0
Definition at line 9 of file Camera2D.cpp.
glm::mat3 nta::Camera2D::getCameraMatrix | ( | ) | const |
returns the 3x3 matrix representing the camera's view
The camera translates, rotates, and then dilates
Definition at line 62 of file Camera2D.cpp.
glm::vec2 nta::Camera2D::screenToGame | ( | crvec2 | screen | ) | const |
converts screen coordinates to world coordinates
screen here just means the coordinates after multiplying by the camera matrix this is usually what's passed into gl_Position
Definition at line 102 of file Camera2D.cpp.
Referenced by mouseToGame().
void nta::Camera2D::translateCenter | ( | crvec2 | translation, |
bool | move_along_axes = false |
||
) |
moves the camera around the world By default, if the world is rotated, it does not move along the rotated axes
Definition at line 178 of file Camera2D.cpp.