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