gramods
Viewpoint.hh
1 
2 #ifndef GRAMODS_GRAPHICS_VIEWPOINT
3 #define GRAMODS_GRAPHICS_VIEWPOINT
4 
5 #include <gmGraphics/config.hh>
6 #include <gmGraphics/Eye.hh>
7 
8 // Required before gmCore/OFactory.hh for some compilers
9 #include <gmCore/io_eigen.hh>
10 
11 #include <gmCore/Object.hh>
12 #include <gmCore/OFactory.hh>
13 
14 #include <optional>
15 
16 BEGIN_NAMESPACE_GMGRAPHICS;
17 
27 class Viewpoint
28  : public gmCore::Object {
29 
30 public:
31 
38  virtual Eigen::Vector3f getPosition(Eye eye = Eye::MONO);
39 
48  virtual Eigen::Quaternionf getOrientation(Eye eye = Eye::MONO);
49 
59  virtual void setPosition(Eigen::Vector3f p);
60 
68  void setEyeSeparation(float e) {
69  eye_separation = e;
70  }
71 
82  virtual void setOrientation(Eigen::Quaternionf q);
83 
92  virtual void setUpDirection(Eigen::Vector3f up);
93 
105  virtual void setLookAt(Eigen::Vector3f p) { look_at = p; }
106 
111  virtual void unsetLookAt() { look_at = std::nullopt; }
112 
117  virtual std::string getDefaultKey() override { return "viewpoint"; }
118 
119  GM_OFI_DECLARE;
120 
121 protected:
122 
123  Eigen::Vector3f position = Eigen::Vector3f::Zero();
124  Eigen::Quaternionf orientation = Eigen::Quaternionf::Identity();
125 
126  Eigen::Vector3f up_direction = Eigen::Vector3f(0, 1, 0);
127  std::optional<Eigen::Vector3f> look_at;
128 
129  float eye_separation = 0.06f;
130 
131 };
132 
133 END_NAMESPACE_GMGRAPHICS;
134 
135 #endif
Base type for objects in the Gramods package for standardized handling of construction,...
Definition: Object.hh:42
The viewpoint represents a point in space from which the view is to be rendered, and an orientation.
Definition: Viewpoint.hh:28
virtual void unsetLookAt()
Unsets the look-at point so that the viewpoint orientation is no longer automatically rotated.
Definition: Viewpoint.hh:111
virtual std::string getDefaultKey() override
Returns the default key, in Configuration, for the Object.
Definition: Viewpoint.hh:117
virtual void setLookAt(Eigen::Vector3f p)
Sets a point that the viewpoint should be rotated towards.
Definition: Viewpoint.hh:105
void setEyeSeparation(float e)
Sets the distance between the eyes for stereoscopic (or multiscopic) rendering, in internal units,...
Definition: Viewpoint.hh:68
An indexed eye that can be rendered.
Definition: Eye.hh:20