Nazara Engine  0.4
A fast, complete, cross-platform API designed for game development
RenderSystem.hpp
1 // Copyright (C) 2017 Jérôme Leclercq
2 // This file is part of the "Nazara Development Kit"
3 // For conditions of distribution and use, see copyright notice in Prerequesites.hpp
4 
5 #pragma once
6 
7 #ifndef NDK_SERVER
8 #ifndef NDK_SYSTEMS_RENDERSYSTEM_HPP
9 #define NDK_SYSTEMS_RENDERSYSTEM_HPP
10 
11 #include <Nazara/Graphics/AbstractBackground.hpp>
12 #include <Nazara/Graphics/CullingList.hpp>
13 #include <Nazara/Graphics/DepthRenderTechnique.hpp>
14 #include <Nazara/Renderer/RenderTexture.hpp>
15 #include <NDK/EntityList.hpp>
16 #include <NDK/System.hpp>
17 #include <NDK/Components/GraphicsComponent.hpp>
18 #include <vector>
19 
20 namespace Ndk
21 {
22  class AbstractViewer;
23 
24  class NDK_API RenderSystem : public System<RenderSystem>
25  {
26  public:
27  RenderSystem();
28  inline RenderSystem(const RenderSystem& renderSystem);
29  ~RenderSystem() = default;
30 
31  template<typename T> T& ChangeRenderTechnique();
32  inline Nz::AbstractRenderTechnique& ChangeRenderTechnique(std::unique_ptr<Nz::AbstractRenderTechnique>&& renderTechnique);
33 
34  inline const Nz::BackgroundRef& GetDefaultBackground() const;
35  inline const Nz::Matrix4f& GetCoordinateSystemMatrix() const;
36  inline Nz::Vector3f GetGlobalForward() const;
37  inline Nz::Vector3f GetGlobalRight() const;
38  inline Nz::Vector3f GetGlobalUp() const;
39  inline Nz::AbstractRenderTechnique& GetRenderTechnique() const;
40 
41  inline void SetDefaultBackground(Nz::BackgroundRef background);
42  inline void SetGlobalForward(const Nz::Vector3f& direction);
43  inline void SetGlobalRight(const Nz::Vector3f& direction);
44  inline void SetGlobalUp(const Nz::Vector3f& direction);
45 
46  static SystemIndex systemIndex;
47 
48  private:
49  inline void InvalidateCoordinateSystem();
50 
51  void OnEntityRemoved(Entity* entity) override;
52  void OnEntityValidation(Entity* entity, bool justAdded) override;
53  void OnUpdate(float elapsedTime) override;
54 
55  void UpdateDynamicReflections();
56  void UpdateDirectionalShadowMaps(const Nz::AbstractViewer& viewer);
57  void UpdatePointSpotShadowMaps();
58 
59  std::unique_ptr<Nz::AbstractRenderTechnique> m_renderTechnique;
60  std::vector<GraphicsComponentCullingList::VolumeEntry> m_volumeEntries;
61  std::vector<EntityHandle> m_cameras;
62  EntityList m_drawables;
63  EntityList m_directionalLights;
64  EntityList m_lights;
65  EntityList m_pointSpotLights;
66  EntityList m_particleGroups;
67  EntityList m_realtimeReflected;
68  GraphicsComponentCullingList m_drawableCulling;
69  Nz::BackgroundRef m_background;
70  Nz::DepthRenderTechnique m_shadowTechnique;
71  Nz::Matrix4f m_coordinateSystemMatrix;
72  Nz::RenderTexture m_shadowRT;
73  bool m_coordinateSystemInvalidated;
74  bool m_forceRenderQueueInvalidation;
75  };
76 }
77 
78 #include <NDK/Systems/RenderSystem.inl>
79 
80 #endif // NDK_SYSTEMS_RENDERSYSTEM_HPP
81 #endif // NDK_SERVER
TODO: For now is unable to display different color in the history, it needs a RichTextDrawer to do so...
Definition: Algorithm.hpp:12
NDK class that represents an entity in a world.
Definition: Entity.hpp:28
Graphics class that represents the viewer for our scene.
Definition: AbstractViewer.hpp:21
Graphics class that represents the technique used in depth rendering.
Definition: DepthRenderTechnique.hpp:20
Core class that represents a reference to an object.
Definition: ObjectRef.hpp:18
Graphics class that represents the rendering technique for our scene.
Definition: AbstractRenderTechnique.hpp:20
NDK class that represents the rendering system.
Definition: RenderSystem.hpp:24
NDK class that represents a set of entities to help performing batch operations.
Definition: EntityList.hpp:16