2 #ifndef GRAMODS_GRAPHICS_CAMERA
3 #define GRAMODS_GRAPHICS_CAMERA
5 #include <gmGraphics/config.hh>
7 #include <gmGraphics/Eye.hh>
8 #include <gmCore/Console.hh>
10 #include <Eigen/Eigen>
14 BEGIN_NAMESPACE_GMGRAPHICS;
25 Camera(
size_t frame_number) : frame_number(frame_number) {}
28 : frame_number(other.frame_number),
35 position(other.position),
36 orientation(other.orientation),
39 Camera &operator=(
const Camera &other) {
40 if (frame_number != other.frame_number)
42 GM_STR(
"Cannot assign with camera from different frame ("
43 << frame_number <<
" != " << other.frame_number <<
")"));
47 bottom = other.bottom;
51 position = other.position;
52 orientation = other.orientation;
62 Camera(
const T &
object) : frame_number(object.frame_number) {}
68 Eigen::Matrix4f getProjectionMatrix()
const;
73 Eigen::Affine3f getViewMatrix()
const;
122 void setFieldOfView(
float fov_h,
float fov_v);
130 void setClipAngles(
float l,
float r,
float b,
float t);
135 void setPose(Eigen::Vector3f p, Eigen::Quaternionf r) {
145 bool setLookAtPoints(Eigen::Vector3f p,
146 const std::vector<Eigen::Vector3f> &pts,
147 bool symmetric =
true,
148 Eigen::Vector3f up = Eigen::Vector3f::Zero());
178 float left = -1.f, right = 1.f, bottom = -1.f, top = 1.f;
183 std::optional<float> near, far;
188 Eigen::Vector3f position = Eigen::Vector3f::Zero();
193 Eigen::Quaternionf orientation = Eigen::Quaternionf::Identity();
201 END_NAMESPACE_GMGRAPHICS;
The base of graphics Camera implementations.
Definition: Camera.hh:19
const size_t frame_number
The frame currently being rendered.
Definition: Camera.hh:172
void setOrientation(Eigen::Quaternionf q)
Set the orientation of the camera.
Definition: Camera.hh:93
void getClipPlanes(float &l, float &r, float &b, float &t) const
Gets the frustum clip planes at a distance of 1.
Definition: Camera.hh:110
void setClipPlanes(float l, float r, float b, float t)
Explicitly sets the frustum clip planes at a distance of 1.
Definition: Camera.hh:100
Eigen::Vector3f getPosition() const
Get the position of the camera.
Definition: Camera.hh:78
Eye getEye() const
Sets which eye the camera is supposed to render.
Definition: Camera.hh:167
Camera(size_t frame_number)
Creates a camera for rendering the specified frame number.
Definition: Camera.hh:25
void setPose(Eigen::Vector3f p, Eigen::Quaternionf r)
Sets the pose of the camera.
Definition: Camera.hh:135
void setPosition(Eigen::Vector3f p)
Set the position of the camera.
Definition: Camera.hh:83
void setEye(Eye e)
Sets which eye the camera is supposed to render.
Definition: Camera.hh:161
void setNearFar(float near, float far)
Sets the near and far planes.
Definition: Camera.hh:153
Eigen::Quaternionf getOrientation() const
Get the orientation of the camera.
Definition: Camera.hh:88
Camera(const T &object)
Creates a camera copying frame number from another object.
Definition: Camera.hh:62
Standard exception for invalid arguments in a call to a function or object.
Definition: InvalidArgument.hh:15
An indexed eye that can be rendered.
Definition: Eye.hh:20