gramods
ObjRenderer.hh
1 
2 #ifndef GRAMODS_GRAPHICS_OBJRENDERER
3 #define GRAMODS_GRAPHICS_OBJRENDERER
4 
5 #include <gmGraphics/Renderer.hh>
6 #include <gmGraphics/ImageTexture.hh>
7 
8 #include <gmCore/io_eigen.hh>
9 #include <gmCore/OFactory.hh>
10 
11 BEGIN_NAMESPACE_GMGRAPHICS;
12 
17  : public Renderer {
18 
19 public:
26  struct Material {
27 
28  // Ambient color component. Default (0.0, 0.0, 0.0)
29  Eigen::Vector3f color_ambient;
30  // Diffuse color component. Default (0.8, 0.8, 0.8)
31  Eigen::Vector3f color_diffuse;
32  // Specular color component. Default (0.0, 0.0, 0.0)
33  Eigen::Vector3f color_specular;
34  // Emissive color component. Default (0.0, 0.0, 0.0)
35  Eigen::Vector3f color_emissive;
36 
41  float shininess;
42 
43  // Ambient texture
44  std::shared_ptr<gmGraphics::ImageTexture> texture_ambient = 0;
45  // Diffuse texture
46  std::shared_ptr<gmGraphics::ImageTexture> texture_diffuse = 0;
47  // Specular texture
48  std::shared_ptr<gmGraphics::ImageTexture> texture_specular = 0;
49  // Emissive texture
50  std::shared_ptr<gmGraphics::ImageTexture> texture_emissive = 0;
51  };
52 
53  ObjRenderer();
54  ~ObjRenderer();
55 
59  void initialize() override;
60 
64  void render(const Camera &camera, const Eigen::Affine3f &Mm) override;
65 
72  void getNearFar(const Camera &camera,
73  const Eigen::Affine3f &Mm,
74  float &near,
75  float &far) override;
76 
82  void setFile(std::filesystem::path file);
83 
90  void setRecenter(bool on);
91 
95  std::vector<Material> getMaterials() const;
96 
101  void setMaterials(const std::vector<Material> &materials);
102 
107  std::vector<float> getIntersections(const IntersectionLine &line) override;
108 
109  GM_OFI_DECLARE;
110 
111 private:
112 
113  struct Impl;
114  std::unique_ptr<Impl> _impl;
115 
116 };
117 
118 END_NAMESPACE_GMGRAPHICS;
119 
120 #endif
The base of graphics Camera implementations.
Definition: Camera.hh:19
A renderer that draws an obj file.
Definition: ObjRenderer.hh:17
The base of graphics Renderer implementations.
Definition: Renderer.hh:17
Line for intersection with ray or segment.
Definition: IntersectionLine.hh:15
Definition: ObjRenderer.cpp:29
Data struct for material data used in the obj file rendering.
Definition: ObjRenderer.hh:26
float shininess
Shininess, i.e.
Definition: ObjRenderer.hh:41