-
Notifications
You must be signed in to change notification settings - Fork 47
/
irenderable.h
169 lines (149 loc) · 5.9 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#pragma once
#include <memory>
class Shader;
typedef std::shared_ptr<Shader> ShaderPtr;
class RenderSystem;
typedef std::shared_ptr<RenderSystem> RenderSystemPtr;
class OpenGLRenderable;
class LightSources;
class Matrix4;
class IRenderEntity;
class RendererLight;
class LitObject;
/**
* \brief Class which accepts OpenGLRenderable objects during the first pass of
* rendering.
*
* Each Renderable in the scenegraph is passed a reference to a
* RenderableCollector, to which the Renderable submits its OpenGLRenderable(s)
* for later rendering. A single Renderable may submit more than one
* OpenGLRenderable, with different options each time -- for instance a
* Renderable model class may submit each of its material surfaces separately
* with different shaders.
*/
class RenderableCollector
{
public:
virtual ~RenderableCollector() {}
/**
* \brief Submit a renderable object.
*
* This method allows renderable geometry to be submitted under the control
* of a LitObject which will determine whether and how the renderable is
* illuminated by scene lights. Each objected submitted with this method
* will be considered for lighting by the lights which are submitted to the
* same RenderableCollector using addLight().
*
* Objects may be submitted without a LitObject if they are not affected by
* scene lights.
*
* \param shader
* The Shader object this Renderable will be attached to.
*
* \param renderable
* The renderable object to submit.
*
* \param localToWorld
* The local to world transform that should be applied to this object when
* it is rendered.
*
* \param entity
* Optional IRenderEntity exposing parameters which affect the rendering of
* this Renderable.
*
* \param litObject
* Optional LitObject determining lighting interactions for this
* renderable. This may or may not be the same actual object as the
* OpenGLRenderable, depending on how the object class hierarchy is set up.
* If a single LitObject contains multiple renderables, a separate call to
* this method must be made for each renderable (with the same litObject
* parameter).
*/
virtual void addRenderable(Shader& shader,
const OpenGLRenderable& renderable,
const Matrix4& localToWorld,
const LitObject* litObject = nullptr,
const IRenderEntity* entity = nullptr) = 0;
/**
* \brief Submit a light source for the render operation.
*
* This is the entry point for lights into the render front-end. Each light
* in the scene graph must be submitted through this method in order to
* provide light for the final render. If the render is in wireframe mode,
* light sources can still be submitted but they will not have any effect.
*/
virtual void addLight(const RendererLight& light) = 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 void setHighlightFlag(Highlight::Flags flags, bool enabled) = 0;
};
class VolumeTest;
/**
* \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;
// Called in preparation of rendering this node
virtual void onPreRender(const VolumeTest& volume)
{}
/// Submit renderable geometry when rendering in Solid mode.
virtual void renderSolid(RenderableCollector& collector,
const VolumeTest& volume) const = 0;
/// Submit renderable geometry when rendering in Wireframe mode.
virtual void renderWireframe(RenderableCollector& collector,
const VolumeTest& volume) const = 0;
virtual void renderComponents(RenderableCollector&, const VolumeTest&) const
{ }
virtual void viewChanged() const
{ }
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;