Radium Engine  1.5.20
Loading...
Searching...
No Matches
RenderObject.hpp
1#pragma once
2
3#include <Engine/RaEngine.hpp>
4
5#include <memory>
6#include <mutex>
7#include <string>
8
9#include <Core/Types.hpp>
10#include <Core/Utils/IndexedObject.hpp>
11
12#include <Engine/Data/ShaderProgram.hpp>
13#include <Engine/Rendering/RenderObjectTypes.hpp>
14#include <Engine/Rendering/RenderTechnique.hpp>
15
16namespace Ra {
17namespace Engine {
18
19namespace Scene {
20class Component;
21} // namespace Scene
22
23namespace Data {
24class Displayable;
25class Material;
26struct ViewingParameters;
27class RenderParameters;
28} // namespace Data
29
30namespace Rendering {
31
36class RA_ENGINE_API RenderObject final : public Core::Utils::IndexedObject
37{
38 public:
50 RenderObject( const std::string& name,
51 Scene::Component* comp,
52 const RenderObjectType& type,
53 int lifetime = -1 );
54
55 ~RenderObject() override;
56
83 static RenderObject* createRenderObject(
84 const std::string& name,
85 Scene::Component* comp,
86 const RenderObjectType& type,
88 const RenderTechnique& techniqueConfig = RenderTechnique::createDefaultRenderTechnique() );
89
93 void updateGL();
94
97 const std::string& getName() const;
98 const Scene::Component* getComponent() const;
99 Scene::Component* getComponent();
100
101 const RenderObjectType& getType() const;
102 void setType( const RenderObjectType& t );
103
104 void setVisible( bool visible );
105 void toggleVisible();
106 bool isVisible() const;
107
108 void setPickable( bool pickable );
109 void togglePickable();
110 bool isPickable() const;
111
112 void setXRay( bool xray );
113 void toggleXRay();
114 bool isXRay() const;
115
116 void setTransparent( bool transparent );
117 void toggleTransparent();
118 bool isTransparent() const;
119
121 void setColoredByVertexAttrib( bool state );
123 void toggleColoredByVertexAttrib();
125 bool isColoredByVertexAttrib() const;
126
127 bool isDirty() const;
128
129 void setRenderTechnique( std::shared_ptr<RenderTechnique> technique );
130 std::shared_ptr<const RenderTechnique> getRenderTechnique() const;
131 std::shared_ptr<RenderTechnique> getRenderTechnique();
132
133 void setMaterial( std::shared_ptr<Data::Material> material );
134 std::shared_ptr<const Data::Material> getMaterial() const;
136
137 void setMesh( std::shared_ptr<Data::Displayable> mesh );
139 const std::shared_ptr<Data::Displayable>& getMesh();
140
141 Core::Transform getTransform() const;
142 Core::Matrix4 getTransformAsMatrix() const;
143
144 Core::Aabb computeAabb();
145
146 void setLocalTransform( const Core::Transform& transform );
147 void setLocalTransform( const Core::Matrix4& transform );
148 const Core::Transform& getLocalTransform() const;
149 const Core::Matrix4& getLocalTransformAsMatrix() const;
151
155 void hasBeenRenderedOnce();
156
158 void hasExpired();
159
161 void setLifetime( int t );
162
170 void render( const Data::RenderParameters& lightParams,
171 const Data::ViewingParameters& viewParams,
172 const Data::ShaderProgram* shader,
173 const Data::RenderParameters& shaderParams );
174
182 void render( const Data::RenderParameters& lightParams,
183 const Data::ViewingParameters& viewParams,
184 Core::Utils::Index passId = DefaultRenderingPasses::LIGHTING_OPAQUE );
185
186 void invalidateAabb();
187
188 private:
189 Core::Transform m_localTransform { Core::Transform::Identity() };
190
191 Scene::Component* m_component { nullptr };
192 std::string m_name {};
193
194 RenderObjectType m_type { RenderObjectType::Geometry };
195 std::shared_ptr<RenderTechnique> m_renderTechnique { nullptr };
196 std::shared_ptr<Data::Displayable> m_mesh { nullptr };
197 std::shared_ptr<Data::Material> m_material { nullptr };
198
199 mutable std::mutex m_updateMutex;
200
201 int m_lifetime { -1 };
202 bool m_visible { true };
203 bool m_pickable { true };
204 bool m_xray { false };
205 bool m_transparent { false };
206 bool m_dirty { true };
207 bool m_hasLifetime { false };
208
209 bool m_isAabbValid { false };
210 Core::Aabb m_aabb;
211 int m_aabbObserverIndex { -1 };
212};
213
214} // namespace Rendering
215} // namespace Engine
216} // namespace Ra
Management of shader parameters with automatic binding of a named parameter to the corresponding glsl...
A component is an element that can be updated by a system. It is also linked to some other components...
Definition Component.hpp:31
hepler function to manage enum as underlying types in VariableSet
Definition Cage.cpp:3
the set of viewing parameters extracted from the camera and given to the renderer