Merge remote-tracking branch 'origin/Graphics-update'

Former-commit-id: 6050b694c2c97ec65e7573d729985e5b7aacec84
This commit is contained in:
Lynix
2013-05-30 13:17:23 +02:00
36 changed files with 802 additions and 586 deletions

View File

@@ -38,7 +38,6 @@
#include <Nazara/Graphics/Graphics.hpp>
#include <Nazara/Graphics/Light.hpp>
#include <Nazara/Graphics/Model.hpp>
#include <Nazara/Graphics/RenderQueue.hpp>
#include <Nazara/Graphics/Scene.hpp>
#include <Nazara/Graphics/SceneNode.hpp>
#include <Nazara/Graphics/SceneRoot.hpp>

View File

@@ -0,0 +1,30 @@
// Copyright (C) 2013 Jérôme Leclercq
// This file is part of the "Nazara Engine - Graphics module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_ABSTRACTRENDERQUEUE_HPP
#define NAZARA_ABSTRACTRENDERQUEUE_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/NonCopyable.hpp>
class NzDrawable;
class NzLight;
class NzModel;
class NAZARA_API NzAbstractRenderQueue : NzNonCopyable
{
public:
NzAbstractRenderQueue() = default;
virtual ~NzAbstractRenderQueue();
virtual void AddDrawable(const NzDrawable* drawable) = 0;
virtual void AddLight(const NzLight* light) = 0;
virtual void AddModel(const NzModel* model) = 0;
virtual void Clear() = 0;
};
#endif // NAZARA_ABSTRACTRENDERQUEUE_HPP

View File

@@ -0,0 +1,29 @@
// Copyright (C) 2013 Jérôme Leclercq
// This file is part of the "Nazara Engine - Graphics module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_ABSTRACTRENDERTECHNIQUE_HPP
#define NAZARA_ABSTRACTRENDERTECHNIQUE_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/NonCopyable.hpp>
#include <Nazara/Graphics/AbstractRenderQueue.hpp>
class NzBackground;
class NzScene;
class NAZARA_API NzAbstractRenderTechnique : NzNonCopyable
{
public:
NzAbstractRenderTechnique() = default;
virtual ~NzAbstractRenderTechnique();
virtual void Clear(const NzScene* scene) = 0;
virtual void Draw(const NzScene* scene) = 0;
virtual NzAbstractRenderQueue* GetRenderQueue() = 0;
};
#endif // NAZARA_ABSTRACTRENDERTECHNIQUE_HPP

View File

@@ -22,7 +22,7 @@ class NAZARA_API NzCamera : public NzSceneNode
NzCamera();
~NzCamera();
void Activate() const;
void Activate();
void EnsureFrustumUpdate() const;
void EnsureProjectionMatrixUpdate() const;
@@ -50,7 +50,7 @@ class NAZARA_API NzCamera : public NzSceneNode
void SetZNear(float zNear);
private:
void AddToRenderQueue(NzRenderQueue& renderQueue) const;
void AddToRenderQueue(NzAbstractRenderQueue* renderQueue) const override;
void Invalidate();
void Register();
void Unregister();

View File

@@ -2,60 +2,49 @@
// This file is part of the "Nazara Engine - Graphics module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#ifndef NAZARA_RENDERQUEUE_HPP
#define NAZARA_RENDERQUEUE_HPP
#pragma once
#ifndef NAZARA_FORWARDRENDERQUEUE_HPP
#define NAZARA_FORWARDRENDERQUEUE_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Graphics/AbstractRenderQueue.hpp>
#include <Nazara/Math/Matrix4.hpp>
#include <Nazara/Utility/Mesh.hpp>
#include <map>
#include <vector>
class NzDrawable;
class NzLight;
class NzCamera;
class NzMaterial;
class NzModel;
class NzSkeletalMesh;
class NzStaticMesh;
class NAZARA_API NzRenderQueue
class NAZARA_API NzForwardRenderQueue : public NzAbstractRenderQueue
{
friend class NzForwardRenderTechnique;
public:
NzRenderQueue() = default;
~NzRenderQueue() = default;
NzForwardRenderQueue() = default;
~NzForwardRenderQueue() = default;
void AddDrawable(const NzDrawable* drawable);
void AddLight(const NzLight* light);
void AddModel(const NzModel* model);
void Clear();
struct SkeletalData
{
NzMatrix4f transformMatrix;
///TODO: Déplacer vers un container séparé qui ne serait pas sujet à Clear();
std::vector<NzMeshVertex> skinnedVertices;
};
struct TransparentModel
{
NzMatrix4f transformMatrix;
NzMaterial* material;
};
struct TransparentSkeletalModel : public TransparentModel
{
///TODO: Déplacer vers un container séparé qui ne serait pas sujet à Clear();
std::vector<NzMeshVertex> skinnedVertices;
};
struct TransparentStaticModel : public TransparentModel
{
NzStaticMesh* mesh;
};
void Sort(const NzCamera& camera);
private:
struct MaterialComparator
{
bool operator()(const NzMaterial* mat1, const NzMaterial* mat2);
};
struct SkeletalData
{
///TODO
NzMatrix4f transformMatrix;
};
struct SkeletalMeshComparator
{
bool operator()(const NzSkeletalMesh* subMesh1, const NzSkeletalMesh* subMesh2);
@@ -66,16 +55,32 @@ class NAZARA_API NzRenderQueue
bool operator()(const NzStaticMesh* subMesh1, const NzStaticMesh* subMesh2);
};
struct TransparentModel
{
NzMatrix4f transformMatrix;
NzMaterial* material;
};
struct TransparentSkeletalModel : public TransparentModel
{
///TODO
};
struct TransparentStaticModel : public TransparentModel
{
NzStaticMesh* mesh;
};
typedef std::map<NzSkeletalMesh*, std::vector<SkeletalData>, SkeletalMeshComparator> SkeletalMeshContainer;
typedef std::map<NzStaticMesh*, std::vector<NzMatrix4f>, StaticMeshComparator> StaticMeshContainer;
std::map<NzMaterial*, SkeletalMeshContainer, MaterialComparator> visibleSkeletalModels;
std::map<NzMaterial*, StaticMeshContainer, MaterialComparator> visibleStaticModels;
std::vector<TransparentSkeletalModel> visibleTransparentSkeletalModels;
std::vector<TransparentStaticModel> visibleTransparentStaticModels;
std::map<NzMaterial*, std::pair<SkeletalMeshContainer, StaticMeshContainer>, MaterialComparator> visibleModels;
std::vector<std::pair<unsigned int, bool>> visibleTransparentsModels;
std::vector<TransparentSkeletalModel> transparentSkeletalModels;
std::vector<TransparentStaticModel> transparentStaticModels;
std::vector<const NzDrawable*> otherDrawables;
std::vector<const NzLight*> directionnalLights;
std::vector<const NzLight*> visibleLights;
};
#endif // NAZARA_RENDERQUEUE_HPP
#endif // NAZARA_FORWARDRENDERQUEUE_HPP

View File

@@ -0,0 +1,33 @@
// Copyright (C) 2013 Jérôme Leclercq
// This file is part of the "Nazara Engine - Graphics module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_FORWARDRENDERTECHNIQUE_HPP
#define NAZARA_FORWARDRENDERTECHNIQUE_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Graphics/AbstractRenderTechnique.hpp>
#include <Nazara/Graphics/ForwardRenderQueue.hpp>
class NAZARA_API NzForwardRenderTechnique : public NzAbstractRenderTechnique
{
public:
NzForwardRenderTechnique();
~NzForwardRenderTechnique() = default;
void Clear(const NzScene* scene);
void Draw(const NzScene* scene);
unsigned int GetMaxLightsPerObject() const;
NzAbstractRenderQueue* GetRenderQueue() override;
void SetMaxLightsPerObject(unsigned int lightCount);
private:
NzForwardRenderQueue m_renderQueue;
unsigned int m_maxLightsPerObject;
};
#endif // NAZARA_FORWARDRENDERTECHNIQUE_HPP

View File

@@ -19,9 +19,9 @@ class NAZARA_API NzLight : public NzSceneNode
public:
NzLight(nzLightType type);
NzLight(const NzLight& light);
~NzLight();
~NzLight() = default;
void AddToRenderQueue(NzRenderQueue& renderQueue) const;
void AddToRenderQueue(NzAbstractRenderQueue* renderQueue) const override;
void Apply(const NzShader* shader, unsigned int lightUnit) const;

View File

@@ -41,7 +41,7 @@ class NAZARA_API NzModel : public NzSceneNode, public NzUpdatable
NzModel(NzModel&& model);
~NzModel();
void AddToRenderQueue(NzRenderQueue& renderQueue) const;
void AddToRenderQueue(NzAbstractRenderQueue* renderQueue) const override;
void AdvanceAnimation(float elapsedTime);
void EnableAnimation(bool animation);
@@ -64,6 +64,7 @@ class NAZARA_API NzModel : public NzSceneNode, public NzUpdatable
bool HasAnimation() const;
bool IsAnimationEnabled() const;
bool IsDrawable() const;
bool IsDrawEnabled() const;
bool LoadFromFile(const NzString& filePath, const NzModelParameters& params = NzModelParameters());

View File

@@ -10,9 +10,11 @@
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Color.hpp>
#include <Nazara/Core/Updatable.hpp>
#include <Nazara/Graphics/AbstractRenderTechnique.hpp>
#include <Nazara/Graphics/Background.hpp>
#include <Nazara/Math/Frustum.hpp>
class NzAbstractRenderQueue;
class NzCamera;
class NzLight;
class NzModel;
@@ -34,8 +36,10 @@ class NAZARA_API NzScene
void Cull();
void Draw();
const NzCamera* GetActiveCamera() const;
NzCamera* GetActiveCamera() const;
NzColor GetAmbientColor() const;
NzBackground* GetBackground() const;
NzAbstractRenderTechnique* GetRenderTechnique() const;
NzSceneNode& GetRoot() const;
float GetUpdateTime() const;
unsigned int GetUpdatePerSecond() const;
@@ -44,6 +48,7 @@ class NAZARA_API NzScene
void SetAmbientColor(const NzColor& color);
void SetBackground(NzBackground* background);
void SetRenderTechnique(NzAbstractRenderTechnique* renderTechnique);
void SetUpdatePerSecond(unsigned int updatePerSecond);
void UnregisterForUpdate(NzUpdatable* object);
@@ -54,8 +59,8 @@ class NAZARA_API NzScene
operator const NzSceneNode&() const;
private:
void RecursiveFrustumCull(NzRenderQueue& renderQueue, const NzFrustumf& frustum, NzNode* node);
void SetActiveCamera(const NzCamera* camera);
void RecursiveFrustumCull(NzAbstractRenderQueue* renderQueue, const NzFrustumf& frustum, NzNode* node);
void SetActiveCamera(NzCamera* camera);
NzSceneImpl* m_impl;
};

View File

@@ -9,7 +9,6 @@
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Graphics/Enums.hpp>
#include <Nazara/Graphics/RenderQueue.hpp>
#include <Nazara/Graphics/Scene.hpp>
#include <Nazara/Math/BoundingBox.hpp>
#include <Nazara/Math/Frustum.hpp>
@@ -24,7 +23,7 @@ class NAZARA_API NzSceneNode : public NzNode
NzSceneNode(const NzSceneNode& node);
virtual ~NzSceneNode();
virtual void AddToRenderQueue(NzRenderQueue& renderQueue) const = 0;
virtual void AddToRenderQueue(NzAbstractRenderQueue* renderQueue) const = 0;
virtual const NzBoundingBoxf& GetBoundingBox() const = 0;
nzNodeType GetNodeType() const final;

View File

@@ -17,7 +17,7 @@ class NAZARA_API NzSceneRoot : public NzSceneNode
friend struct NzSceneImpl;
public:
void AddToRenderQueue(NzRenderQueue& renderQueue) const override;
void AddToRenderQueue(NzAbstractRenderQueue* renderQueue) const override;
const NzBoundingBoxf& GetBoundingBox() const override;
nzSceneNodeType GetSceneNodeType() const override;

View File

@@ -30,7 +30,7 @@
/// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci
// Le nombre maximum d'instances pouvant être géré par le Renderer
#define NAZARA_RENDERER_INSTANCING_MAX 8192
#define NAZARA_RENDERER_MAX_INSTANCES 8192
// Utilise un tracker pour repérer les éventuels leaks (Ralentit l'exécution)
#define NAZARA_RENDERER_MEMORYLEAKTRACKER 0
@@ -41,4 +41,7 @@
// Active les tests de sécurité basés sur le code (Conseillé pour le développement)
#define NAZARA_RENDERER_SAFE 1
// Le nombre maximum de lumières qu'un forward shader supportera
#define NAZARA_RENDERER_SHADER_MAX_LIGHTCOUNT 8
#endif // NAZARA_CONFIG_MODULENAME_HPP

View File

@@ -107,7 +107,7 @@ class NAZARA_API NzOpenGL
static GLenum ElementType[nzElementType_Max+1];
static GLenum FaceCulling[nzFaceCulling_Max+1];
static GLenum FaceFilling[nzFaceFilling_Max+1];
static GLenum PrimitiveType[nzPrimitiveType_Max+1];
static GLenum PrimitiveMode[nzPrimitiveMode_Max+1];
static GLenum RendererComparison[nzRendererComparison_Max+1];
static GLenum RendererParameter[nzRendererParameter_Max+1];
static GLenum SamplerWrapMode[nzSamplerWrap_Max+1];

View File

@@ -36,10 +36,10 @@ class NAZARA_API NzRenderer
static void Clear(unsigned long flags = nzRendererClear_Color | nzRendererClear_Depth);
static void DrawIndexedPrimitives(nzPrimitiveType primitive, unsigned int firstIndex, unsigned int indexCount);
static void DrawIndexedPrimitivesInstanced(unsigned int instanceCount, nzPrimitiveType primitive, unsigned int firstIndex, unsigned int indexCount);
static void DrawPrimitives(nzPrimitiveType primitive, unsigned int firstVertex, unsigned int vertexCount);
static void DrawPrimitivesInstanced(unsigned int instanceCount, nzPrimitiveType primitive, unsigned int firstVertex, unsigned int vertexCount);
static void DrawIndexedPrimitives(nzPrimitiveMode mode, unsigned int firstIndex, unsigned int indexCount);
static void DrawIndexedPrimitivesInstanced(unsigned int instanceCount, nzPrimitiveMode mode, unsigned int firstIndex, unsigned int indexCount);
static void DrawPrimitives(nzPrimitiveMode mode, unsigned int firstVertex, unsigned int vertexCount);
static void DrawPrimitivesInstanced(unsigned int instanceCount, nzPrimitiveMode mode, unsigned int firstVertex, unsigned int vertexCount);
NAZARA_DEPRECATED("Don't use this or you will have cancer") static void DrawTexture(unsigned int unit, const NzRectf& rect, const NzVector2f& uv0, const NzVector2f& uv1, float z = 0.f);
static void Enable(nzRendererParameter parameter, bool enable);

View File

@@ -205,16 +205,16 @@ enum nzPixelFlipping
nzPixelFlipping_Max = nzPixelFlipping_Vertically
};
enum nzPrimitiveType
enum nzPrimitiveMode
{
nzPrimitiveType_LineList,
nzPrimitiveType_LineStrip,
nzPrimitiveType_PointList,
nzPrimitiveType_TriangleList,
nzPrimitiveType_TriangleStrip,
nzPrimitiveType_TriangleFan,
nzPrimitiveMode_LineList,
nzPrimitiveMode_LineStrip,
nzPrimitiveMode_PointList,
nzPrimitiveMode_TriangleList,
nzPrimitiveMode_TriangleStrip,
nzPrimitiveMode_TriangleFan,
nzPrimitiveType_Max = nzPrimitiveType_TriangleFan
nzPrimitiveMode_Max = nzPrimitiveMode_TriangleFan
};
enum nzWindowCursor

View File

@@ -39,17 +39,17 @@ class NAZARA_API NzSubMesh : public NzResource
virtual const NzIndexBuffer* GetIndexBuffer() const = 0;
unsigned int GetMaterialIndex() const;
const NzMesh* GetParent() const;
nzPrimitiveType GetPrimitiveType() const;
nzPrimitiveMode GetPrimitiveMode() const;
unsigned int GetTriangleCount() const;
virtual unsigned int GetVertexCount() const = 0;
virtual bool IsAnimated() const = 0;
void SetMaterialIndex(unsigned int matIndex);
void SetPrimitiveType(nzPrimitiveType primitiveType);
void SetPrimitiveMode(nzPrimitiveMode mode);
protected:
nzPrimitiveType m_primitiveType;
nzPrimitiveMode m_primitiveMode;
const NzMesh* m_parent;
unsigned int m_matIndex;
};

View File

@@ -37,7 +37,7 @@ class NAZARA_API NzTriangleIterator
void Unmap();
private:
nzPrimitiveType m_primitiveType;
nzPrimitiveMode m_primitiveMode;
nzUInt32 m_triangleIndices[3];
NzIndexMapper m_indexMapper;
NzVertexMapper m_vertexMapper;