Rewritted rendersystem
Former-commit-id: 9cbc601413e057047b94b8b872ee2316a86638c4
This commit is contained in:
30
include/Nazara/Graphics/AbstractRenderQueue.hpp
Normal file
30
include/Nazara/Graphics/AbstractRenderQueue.hpp
Normal 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
|
||||
29
include/Nazara/Graphics/AbstractRenderTechnique.hpp
Normal file
29
include/Nazara/Graphics/AbstractRenderTechnique.hpp
Normal 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
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
33
include/Nazara/Graphics/ForwardRenderTechnique.hpp
Normal file
33
include/Nazara/Graphics/ForwardRenderTechnique.hpp
Normal 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
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user