Nazara Engine  0.4
A fast, complete, cross-platform API designed for game development
AbstractRenderQueue.hpp
1 // Copyright (C) 2017 Jérôme Leclercq
2 // This file is part of the "Nazara Engine - Graphics module"
3 // For conditions of distribution and use, see copyright notice in Config.hpp
4 
5 #pragma once
6 
7 #ifndef NAZARA_ABSTRACTRENDERQUEUE_HPP
8 #define NAZARA_ABSTRACTRENDERQUEUE_HPP
9 
10 #include <Nazara/Prerequesites.hpp>
11 #include <Nazara/Core/Color.hpp>
12 #include <Nazara/Core/SparsePtr.hpp>
13 #include <Nazara/Graphics/Config.hpp>
14 #include <Nazara/Math/Box.hpp>
15 #include <Nazara/Math/Matrix4.hpp>
16 #include <vector>
17 
18 namespace Nz
19 {
20  class Drawable;
21  class Material;
22  class Texture;
23  struct MeshData;
24  struct VertexStruct_XYZ_Color_UV;
25 
26  class NAZARA_GRAPHICS_API AbstractRenderQueue
27  {
28  public:
29  struct DirectionalLight;
30  struct PointLight;
31  struct SpotLight;
32 
33  AbstractRenderQueue() = default;
36  virtual ~AbstractRenderQueue();
37 
38  // Je ne suis vraiment pas fan du nombre de surcharges pour AddBillboards,
39  // mais je n'ai pas d'autre solution tout aussi performante pour le moment...
40  virtual void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const Vector2f> sinCosPtr = nullptr, SparsePtr<const Color> colorPtr = nullptr) = 0;
41  virtual void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const Vector2f> sinCosPtr, SparsePtr<const float> alphaPtr) = 0;
42  virtual void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const Color> colorPtr = nullptr) = 0;
43  virtual void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const Vector2f> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const float> alphaPtr) = 0;
44  virtual void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const float> sizePtr, SparsePtr<const Vector2f> sinCosPtr = nullptr, SparsePtr<const Color> colorPtr = nullptr) = 0;
45  virtual void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const float> sizePtr, SparsePtr<const Vector2f> sinCosPtr, SparsePtr<const float> alphaPtr) = 0;
46  virtual void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const float> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const Color> colorPtr = nullptr) = 0;
47  virtual void AddBillboards(int renderOrder, const Material* material, unsigned int count, SparsePtr<const Vector3f> positionPtr, SparsePtr<const float> sizePtr, SparsePtr<const float> anglePtr, SparsePtr<const float> alphaPtr) = 0;
48  virtual void AddDrawable(int renderOrder, const Drawable* drawable) = 0;
49  virtual void AddDirectionalLight(const DirectionalLight& light);
50  virtual void AddMesh(int renderOrder, const Material* material, const MeshData& meshData, const Boxf& meshAABB, const Matrix4f& transformMatrix) = 0;
51  virtual void AddPointLight(const PointLight& light);
52  virtual void AddSpotLight(const SpotLight& light);
53  virtual void AddSprites(int renderOrder, const Material* material, const VertexStruct_XYZ_Color_UV* vertices, std::size_t spriteCount, const Texture* overlay = nullptr) = 0;
54 
55  virtual void Clear(bool fully = false);
56 
57  AbstractRenderQueue& operator=(const AbstractRenderQueue&) = delete;
58  AbstractRenderQueue& operator=(AbstractRenderQueue&&) = default;
59 
60  struct DirectionalLight
61  {
62  Color color;
63  Matrix4f transformMatrix;
64  Vector3f direction;
65  Texture* shadowMap;
66  float ambientFactor;
67  float diffuseFactor;
68  };
69 
70  struct PointLight
71  {
72  Color color;
73  Vector3f position;
74  Texture* shadowMap;
75  float ambientFactor;
76  float attenuation;
77  float diffuseFactor;
78  float invRadius;
79  float radius;
80  };
81 
82  struct SpotLight
83  {
84  Color color;
85  Matrix4f transformMatrix;
86  Vector3f direction;
87  Vector3f position;
88  Texture* shadowMap;
89  float ambientFactor;
90  float attenuation;
91  float diffuseFactor;
92  float innerAngleCosine;
93  float invRadius;
94  float outerAngleCosine;
95  float outerAngleTangent;
96  float radius;
97  };
98 
99  std::vector<DirectionalLight> directionalLights;
100  std::vector<PointLight> pointLights;
101  std::vector<SpotLight> spotLights;
102  };
103 }
104 
105 #endif // NAZARA_ABSTRACTRENDERQUEUE_HPP
Core class that represents a color.
Definition: Color.hpp:18
TODO: Inherit SoundEmitter from Node.
Definition: Algorithm.hpp:12
Graphics class that represents the rendering queue for our scene.
Definition: AbstractRenderQueue.hpp:26
Core class that represents a pointer and the step between two elements.
Definition: SparsePtr.hpp:19
Graphics class that represents a material.
Definition: Material.hpp:51
Graphics class that represents something drawable for our scene.
Definition: Drawable.hpp:15