Debian Codegraph @

include/irenderable.h

raw
1 #pragma once
2
3 #include <memory>
4 #include "math/Vector3.h"
5
6 class MeshVertex;
7 class Shader;
8 typedef std::shared_ptr<Shader> ShaderPtr;
9
10 class RenderSystem;
11 typedef std::shared_ptr<RenderSystem> RenderSystemPtr;
12
13 class OpenGLRenderable;
14 class Matrix4;
15 class IRenderEntity;
16 class RendererLight;
17 class Renderable;
18 class VolumeTest;
19
20 /**
21 * \brief Class used during the front-end render pass.
22 *
23 * Each node in the scenegraph is visited and is asked to get ready for rendering
24 * by calling Renderable.onPreRender() method.
25 *
26 * If a node's highlight flags (which combined with their parents flags) indicates
27 * that the node needs to render special visual aids like selection overlays,
28 * the node's Renderable::renderHighlights() method is invoked.
29 */
30 class IRenderableCollector
31 {
32 public:
33 virtual ~IRenderableCollector() {}
34
35 /**
36 * Submits a renderable object that is used for highlighting an object.
37 * Depending on the view, this might be a coloured, transparent overlay
38 * or a wireframe outline.
39 */
40 virtual void addHighlightRenderable(const OpenGLRenderable& renderable, const Matrix4& localToWorld) = 0;
41
42 /**
43 * \brief Determine if this RenderableCollector can accept renderables for
44 * full materials rendering, or just wireframe rendering.
45 *
46 * \return
47 * true if full materials are supported, false if only wireframe rendering
48 * is supported.
49 */
50 virtual bool supportsFullMaterials() const = 0;
51
52 struct Highlight
53 {
54 enum Flags
55 {
56 NoHighlight = 0,
57 Faces = 1 << 0, /// Highlight faces of subsequently-submitted objects, if supported
58 Primitives = 1 << 1, /// Highlight primitives of subsequently-submitted objects, if supported
59 GroupMember = 1 << 2, /// Highlight as member of group, if supported
60 MergeAction = 1 << 3, /// Highlight as merge action (combined with the flags below)
61 MergeActionAdd = 1 << 4, /// Highlight as merge action that is adding something
62 MergeActionRemove = 1 << 5, /// Highlight as merge action that is removing something
63 MergeActionChange = 1 << 6, /// Highlight as merge action that is changing something
64 MergeActionConflict = 1 << 7, /// Highlight as merge action conflict
65 };
66 };
67
68 virtual bool hasHighlightFlag(Highlight::Flags flags) const = 0;
69
70 virtual void setHighlightFlag(Highlight::Flags flags, bool enabled) = 0;
71
72 // Returns true if the current set of highlight flags is not empty
73 virtual bool hasHighlightFlags() const = 0;
74 };
75
76 /**
77 * \brief
78 * Main interface for Renderable scene objects.
79 *
80 * All objects which wish to be rendered need to implement this interface.
81 * During the scenegraph traversal for rendering, each Renderable object is
82 * passed a RenderableCollector object which it can use to submit its geometry
83 * and state parameters.
84 */
85 class Renderable
86 {
87 public:
88 /// Destroy the Renderable
89 virtual ~Renderable() {}
90
91 /**
92 * Sets the rendersystem this renderable is attached to. This is necessary
93 * for this object to request Materials/Shaders for rendering.
94 */
95 virtual void setRenderSystem(const RenderSystemPtr& renderSystem) = 0;
96
97 /**
98 * Front-end rendering / preparation phase. The node prepares for rendering
99 * by attaching their geometry or surface data to the necessary shader instances.
100 **/
101 virtual void onPreRender(const VolumeTest& volume) = 0;
102
103 // Submit renderable geometry for highlighting the object
104 virtual void renderHighlights(IRenderableCollector& collector, const VolumeTest& volume) = 0;
105
106 struct Highlight
107 {
108 enum Flags
109 {
110 NoHighlight = 0,
111 Selected = 1 << 0,
112 GroupMember = 1 << 1,
113 };
114 };
115
116 /**
117 * Returns information about whether the renderer should highlight this node and how.
118 */
119 virtual std::size_t getHighlightFlags() = 0;
120 };
121 typedef std::shared_ptr<Renderable> RenderablePtr;