1 #ifndef NTA_CAMERA2D_H_INCLUDED
2 #define NTA_CAMERA2D_H_INCLUDED
26 Camera2D(crvec2 center, crvec2 dimensions);
27 Camera2D(crvec2 center, crvec2 dimensions,
float orientation);
30 glm::mat3 getTranslationMatrix()
const;
31 glm::mat3 getRotationMatrix()
const;
32 glm::mat3 getInverseRotationMatrix()
const;
33 glm::mat3 getDilationMatrix()
const;
38 glm::mat3 getInverseCameraMatrix()
const;
41 glm::vec4 getBoundsTopLeft()
const;
44 glm::vec2 getTopLeft()
const;
45 glm::vec2 getDimensions()
const;
46 glm::vec2 getRotatedDimensions()
const;
47 float getOrientation()
const;
49 std::tuple<glm::vec2, glm::vec2>
getAxes()
const;
51 glm::vec2
mouseToGame(crvec2 mouse, crvec2 windowDimensions)
const;
59 bool inBounds(
float x,
float y)
const;
61 bool isVisible(
const std::vector<glm::vec2>& polygon)
const;
65 void setDimensions(crvec2 dimensions);
66 void setDimensions(
float w,
float h);
67 void setOrientation(
float t);
80 #endif // NTA_CAMERA2D_H_INCLUDED
glm::vec2 m_center
center of the camera's view in world coordinates
void scaleDimensions(crvec2 dilation)
scales the camera's field of view
bool inBounds(crvec2 pt) const
Returns true if this pt is contained within the camera.
bool isVisible(const std::vector< glm::vec2 > &polygon) const
Returns ture if this polygon would show up in the camera.
glm::vec2 screenToGame(crvec2 screen) const
glm::vec4 getBoundsCenter() const
returns camera bounds in the given format
void rotate(float dt)
rotates the camera
std::tuple< glm::vec2, glm::vec2 > getAxes() const
returns (normalized) axes aligned with the camera
glm::vec2 m_dimensions
half dimensions of camera's view in world coordinates
float m_orientation
rotation about axis orthogonal to the world
void translateCenter(crvec2 translation, bool move_along_axes=false)
glm::mat3 getCameraMatrix() const
glm::vec2 mouseToGame(crvec2 mouse, crvec2 windowDimensions) const
converts mouse coordinates to world coordinates
void setCenter(crvec2 center)
sets the values of the camera's fields
glm::vec2 getCenter() const
returns the center, top left coordinate, and (half) dimensions of the camera's view