gramods
Loading...
Searching...
No Matches
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
11BEGIN_NAMESPACE_GMGRAPHICS;
12
17 : public Renderer {
18
19public:
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
46 float dissolve;
47
48 // Ambient texture
49 std::shared_ptr<gmGraphics::ImageTexture> texture_ambient = 0;
50 // Diffuse texture
51 std::shared_ptr<gmGraphics::ImageTexture> texture_diffuse = 0;
52 // Specular texture
53 std::shared_ptr<gmGraphics::ImageTexture> texture_specular = 0;
54 // Emissive texture
55 std::shared_ptr<gmGraphics::ImageTexture> texture_emissive = 0;
56 // Alpha texture (map_d)
57 std::shared_ptr<gmGraphics::ImageTexture> texture_alpha = 0;
58 };
59
62
66 void initialize() override;
67
71 void render(const Camera &camera, const Eigen::Affine3f &Mm) override;
72
79 void getNearFar(const Camera &camera,
80 const Eigen::Affine3f &Mm,
81 float &near,
82 float &far) override;
83
89 void setFile(std::filesystem::path file);
90
97 void setRecenter(bool on);
98
105 void setMipmaps(bool on);
106
110 std::vector<Material> getMaterials() const;
111
116 void setMaterials(const std::vector<Material> &materials);
117
122 std::vector<float> getIntersections(const IntersectionLine &line) override;
123
124 GM_OFI_DECLARE;
125
126private:
127
128 struct Impl;
129 std::unique_ptr<Impl> _impl;
130
131};
132
133END_NAMESPACE_GMGRAPHICS;
134
135#endif
The base of graphics Camera implementations.
Definition Camera.hh:19
A renderer that draws a Wavefront 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:30
Data struct for material data used in the obj file rendering.
Definition ObjRenderer.hh:26
float dissolve
Dissolve, i.e.
Definition ObjRenderer.hh:46
float shininess
Shininess, i.e.
Definition ObjRenderer.hh:41