Merge remote-tracking branch 'origin/RenderTechnique-Update'
Former-commit-id: db5a6503e43615a47e3be4aaaa033899639392b7
This commit is contained in:
@@ -9,14 +9,15 @@
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
#include <Nazara/Math/Box.hpp>
|
||||
#include <Nazara/Math/Matrix4.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
|
||||
class NzDrawable;
|
||||
class NzLight;
|
||||
class NzMaterial;
|
||||
class NzModel;
|
||||
class NzSprite;
|
||||
class NzSubMesh;
|
||||
struct NzMeshData;
|
||||
|
||||
class NAZARA_API NzAbstractRenderQueue : NzNonCopyable
|
||||
{
|
||||
@@ -26,8 +27,8 @@ class NAZARA_API NzAbstractRenderQueue : NzNonCopyable
|
||||
|
||||
virtual void AddDrawable(const NzDrawable* drawable) = 0;
|
||||
virtual void AddLight(const NzLight* light) = 0;
|
||||
virtual void AddMesh(const NzMaterial* material, const NzMeshData& meshData, const NzBoxf& meshAABB, const NzMatrix4f& transformMatrix) = 0;
|
||||
virtual void AddSprite(const NzSprite* sprite) = 0;
|
||||
virtual void AddSubMesh(const NzMaterial* material, const NzSubMesh* subMesh, const NzMatrix4f& transformMatrix) = 0;
|
||||
|
||||
virtual void Clear(bool fully) = 0;
|
||||
};
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <Nazara/Graphics/AbstractRenderQueue.hpp>
|
||||
#include <Nazara/Math/Box.hpp>
|
||||
#include <Nazara/Math/Matrix4.hpp>
|
||||
#include <Nazara/Utility/MeshData.hpp>
|
||||
#include <map>
|
||||
#include <tuple>
|
||||
|
||||
@@ -29,22 +30,11 @@ class NAZARA_API NzDeferredRenderQueue : public NzAbstractRenderQueue, NzResourc
|
||||
|
||||
void AddDrawable(const NzDrawable* drawable) override;
|
||||
void AddLight(const NzLight* light) override;
|
||||
void AddMesh(const NzMaterial* material, const NzMeshData& meshData, const NzBoxf& meshAABB, const NzMatrix4f& transformMatrix) override;
|
||||
void AddSprite(const NzSprite* sprite) override;
|
||||
void AddSubMesh(const NzMaterial* material, const NzSubMesh* subMesh, const NzMatrix4f& transformMatrix) override;
|
||||
|
||||
void Clear(bool fully);
|
||||
|
||||
struct SkeletalData
|
||||
{
|
||||
///TODO
|
||||
NzMatrix4f transformMatrix;
|
||||
};
|
||||
|
||||
struct StaticData
|
||||
{
|
||||
NzMatrix4f transformMatrix;
|
||||
};
|
||||
|
||||
struct BatchedModelMaterialComparator
|
||||
{
|
||||
bool operator()(const NzMaterial* mat1, const NzMaterial* mat2);
|
||||
@@ -55,23 +45,17 @@ class NAZARA_API NzDeferredRenderQueue : public NzAbstractRenderQueue, NzResourc
|
||||
bool operator()(const NzMaterial* mat1, const NzMaterial* mat2);
|
||||
};
|
||||
|
||||
struct BatchedSkeletalMeshComparator
|
||||
struct MeshDataComparator
|
||||
{
|
||||
bool operator()(const NzSkeletalMesh* subMesh1, const NzSkeletalMesh* subMesh2);
|
||||
bool operator()(const NzMeshData& data1, const NzMeshData& data2);
|
||||
};
|
||||
|
||||
struct BatchedStaticMeshComparator
|
||||
{
|
||||
bool operator()(const NzStaticMesh* subMesh1, const NzStaticMesh* subMesh2);
|
||||
};
|
||||
|
||||
typedef std::map<const NzSkeletalMesh*, std::vector<SkeletalData>, BatchedSkeletalMeshComparator> BatchedSkeletalMeshContainer;
|
||||
typedef std::map<const NzStaticMesh*, std::vector<StaticData>, BatchedStaticMeshComparator> BatchedStaticMeshContainer;
|
||||
typedef std::map<const NzMaterial*, std::tuple<bool, bool, BatchedSkeletalMeshContainer, BatchedStaticMeshContainer>, BatchedModelMaterialComparator> BatchedModelContainer;
|
||||
typedef std::map<NzMeshData, std::vector<NzMatrix4f>, MeshDataComparator> MeshInstanceContainer;
|
||||
typedef std::map<const NzMaterial*, std::tuple<bool, bool, MeshInstanceContainer>, BatchedModelMaterialComparator> ModelBatches;
|
||||
typedef std::map<const NzMaterial*, std::vector<const NzSprite*>> BatchedSpriteContainer;
|
||||
typedef std::vector<const NzLight*> LightContainer;
|
||||
|
||||
BatchedModelContainer opaqueModels;
|
||||
ModelBatches opaqueModels;
|
||||
BatchedSpriteContainer sprites;
|
||||
LightContainer directionalLights;
|
||||
LightContainer pointLights;
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <Nazara/Graphics/AbstractRenderQueue.hpp>
|
||||
#include <Nazara/Math/Box.hpp>
|
||||
#include <Nazara/Math/Matrix4.hpp>
|
||||
#include <Nazara/Utility/MeshData.hpp>
|
||||
#include <map>
|
||||
#include <tuple>
|
||||
|
||||
@@ -31,8 +32,8 @@ class NAZARA_API NzForwardRenderQueue : public NzAbstractRenderQueue, NzResource
|
||||
|
||||
void AddDrawable(const NzDrawable* drawable) override;
|
||||
void AddLight(const NzLight* light) override;
|
||||
void AddMesh(const NzMaterial* material, const NzMeshData& meshData, const NzBoxf& meshAABB, const NzMatrix4f& transformMatrix) override;
|
||||
void AddSprite(const NzSprite* sprite) override;
|
||||
void AddSubMesh(const NzMaterial* material, const NzSubMesh* subMesh, const NzMatrix4f& transformMatrix) override;
|
||||
|
||||
void Clear(bool fully);
|
||||
|
||||
@@ -42,35 +43,14 @@ class NAZARA_API NzForwardRenderQueue : public NzAbstractRenderQueue, NzResource
|
||||
bool OnResourceDestroy(const NzResource* resource, int index) override;
|
||||
void OnResourceReleased(const NzResource* resource, int index) override;
|
||||
|
||||
struct SkeletalData
|
||||
{
|
||||
///TODO
|
||||
NzMatrix4f transformMatrix;
|
||||
};
|
||||
|
||||
struct StaticData
|
||||
{
|
||||
NzMatrix4f transformMatrix;
|
||||
};
|
||||
|
||||
struct TransparentModel
|
||||
struct TransparentModelData
|
||||
{
|
||||
NzMatrix4f transformMatrix;
|
||||
NzMeshData meshData;
|
||||
NzSpheref boundingSphere;
|
||||
const NzMaterial* material;
|
||||
};
|
||||
|
||||
struct TransparentSkeletalModel : public TransparentModel
|
||||
{
|
||||
///TODO
|
||||
};
|
||||
|
||||
struct TransparentStaticModel : public TransparentModel
|
||||
{
|
||||
const NzStaticMesh* mesh;
|
||||
};
|
||||
|
||||
|
||||
struct BatchedModelMaterialComparator
|
||||
{
|
||||
bool operator()(const NzMaterial* mat1, const NzMaterial* mat2);
|
||||
@@ -81,28 +61,21 @@ class NAZARA_API NzForwardRenderQueue : public NzAbstractRenderQueue, NzResource
|
||||
bool operator()(const NzMaterial* mat1, const NzMaterial* mat2);
|
||||
};
|
||||
|
||||
struct BatchedSkeletalMeshComparator
|
||||
struct MeshDataComparator
|
||||
{
|
||||
bool operator()(const NzSkeletalMesh* subMesh1, const NzSkeletalMesh* subMesh2);
|
||||
bool operator()(const NzMeshData& data1, const NzMeshData& data2);
|
||||
};
|
||||
|
||||
struct BatchedStaticMeshComparator
|
||||
{
|
||||
bool operator()(const NzStaticMesh* subMesh1, const NzStaticMesh* subMesh2);
|
||||
};
|
||||
|
||||
typedef std::map<const NzSkeletalMesh*, std::vector<SkeletalData>, BatchedSkeletalMeshComparator> BatchedSkeletalMeshContainer;
|
||||
typedef std::map<const NzStaticMesh*, std::pair<NzSpheref, std::vector<StaticData>>, BatchedStaticMeshComparator> BatchedStaticMeshContainer;
|
||||
typedef std::map<const NzMaterial*, std::tuple<bool, bool, BatchedSkeletalMeshContainer, BatchedStaticMeshContainer>, BatchedModelMaterialComparator> BatchedModelContainer;
|
||||
typedef std::map<NzMeshData, std::pair<NzSpheref, std::vector<NzMatrix4f>>, MeshDataComparator> MeshInstanceContainer;
|
||||
typedef std::map<const NzMaterial*, std::tuple<bool, bool, MeshInstanceContainer>, BatchedModelMaterialComparator> ModelBatches;
|
||||
typedef std::map<const NzMaterial*, std::vector<const NzSprite*>> BatchedSpriteContainer;
|
||||
typedef std::vector<const NzLight*> LightContainer;
|
||||
typedef std::vector<std::pair<unsigned int, bool>> TransparentModelContainer;
|
||||
typedef std::vector<unsigned int> TransparentModelContainer;
|
||||
|
||||
BatchedModelContainer opaqueModels;
|
||||
ModelBatches opaqueModels;
|
||||
BatchedSpriteContainer sprites;
|
||||
TransparentModelContainer transparentsModels;
|
||||
std::vector<TransparentSkeletalModel> transparentSkeletalModels;
|
||||
std::vector<TransparentStaticModel> transparentStaticModels;
|
||||
TransparentModelContainer transparentModels;
|
||||
std::vector<TransparentModelData> transparentModelData;
|
||||
std::vector<const NzDrawable*> otherDrawables;
|
||||
LightContainer directionalLights;
|
||||
LightContainer lights;
|
||||
|
||||
@@ -9,19 +9,15 @@
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/ResourceLoader.hpp>
|
||||
#include <Nazara/Core/Updatable.hpp>
|
||||
#include <Nazara/Graphics/Material.hpp>
|
||||
#include <Nazara/Graphics/SceneNode.hpp>
|
||||
#include <Nazara/Utility/Animation.hpp>
|
||||
#include <Nazara/Utility/Mesh.hpp>
|
||||
|
||||
struct NAZARA_API NzModelParameters
|
||||
{
|
||||
NzModelParameters();
|
||||
|
||||
bool loadAnimation = true;
|
||||
bool loadMaterials = true;
|
||||
NzAnimationParams animation;
|
||||
NzMaterialParams material;
|
||||
NzMeshParams mesh;
|
||||
|
||||
@@ -32,7 +28,7 @@ class NzModel;
|
||||
|
||||
using NzModelLoader = NzResourceLoader<NzModel, NzModelParameters>;
|
||||
|
||||
class NAZARA_API NzModel : public NzSceneNode, public NzUpdatable
|
||||
class NAZARA_API NzModel : public NzSceneNode
|
||||
{
|
||||
friend NzModelLoader;
|
||||
friend class NzScene;
|
||||
@@ -41,7 +37,7 @@ class NAZARA_API NzModel : public NzSceneNode, public NzUpdatable
|
||||
NzModel();
|
||||
NzModel(const NzModel& model);
|
||||
NzModel(NzModel&& model);
|
||||
~NzModel();
|
||||
virtual ~NzModel();
|
||||
|
||||
void AddToRenderQueue(NzAbstractRenderQueue* renderQueue) const override;
|
||||
void AdvanceAnimation(float elapsedTime);
|
||||
@@ -65,6 +61,7 @@ class NAZARA_API NzModel : public NzSceneNode, public NzUpdatable
|
||||
bool HasAnimation() const;
|
||||
|
||||
bool IsAnimationEnabled() const;
|
||||
virtual bool IsAnimated() const;
|
||||
bool IsDrawable() const;
|
||||
|
||||
void InvalidateBoundingVolume();
|
||||
@@ -75,12 +72,11 @@ class NAZARA_API NzModel : public NzSceneNode, public NzUpdatable
|
||||
|
||||
void Reset();
|
||||
|
||||
bool SetAnimation(NzAnimation* animation);
|
||||
bool SetMaterial(const NzString& subMeshName, NzMaterial* material);
|
||||
void SetMaterial(unsigned int matIndex, NzMaterial* material);
|
||||
bool SetMaterial(unsigned int skinIndex, const NzString& subMeshName, NzMaterial* material);
|
||||
void SetMaterial(unsigned int skinIndex, unsigned int matIndex, NzMaterial* material);
|
||||
void SetMesh(NzMesh* mesh);
|
||||
virtual void SetMesh(NzMesh* mesh);
|
||||
bool SetSequence(const NzString& sequenceName);
|
||||
void SetSequence(unsigned int sequenceIndex);
|
||||
void SetSkin(unsigned int skin);
|
||||
@@ -89,26 +85,16 @@ class NAZARA_API NzModel : public NzSceneNode, public NzUpdatable
|
||||
NzModel& operator=(const NzModel& node);
|
||||
NzModel& operator=(NzModel&& node);
|
||||
|
||||
private:
|
||||
protected:
|
||||
bool FrustumCull(const NzFrustumf& frustum) override;
|
||||
void InvalidateNode() override;
|
||||
void Register() override;
|
||||
void Unregister() override;
|
||||
void Update() override;
|
||||
void UpdateBoundingVolume() const;
|
||||
virtual void UpdateBoundingVolume() const;
|
||||
|
||||
std::vector<NzMaterialRef> m_materials;
|
||||
NzAnimationRef m_animation;
|
||||
mutable NzBoundingVolumef m_boundingVolume;
|
||||
NzMeshRef m_mesh;
|
||||
NzSkeleton m_skeleton; // Uniquement pour les animations squelettiques
|
||||
const NzSequence* m_currentSequence;
|
||||
bool m_animationEnabled;
|
||||
mutable bool m_boundingVolumeUpdated;
|
||||
float m_interpolation;
|
||||
unsigned int m_currentFrame;
|
||||
unsigned int m_matCount;
|
||||
unsigned int m_nextFrame;
|
||||
unsigned int m_skin;
|
||||
unsigned int m_skinCount;
|
||||
|
||||
|
||||
22
include/Nazara/Utility/MeshData.hpp
Normal file
22
include/Nazara/Utility/MeshData.hpp
Normal file
@@ -0,0 +1,22 @@
|
||||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_MESHDATA_HPP
|
||||
#define NAZARA_MESHDATA_HPP
|
||||
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
|
||||
class NzIndexBuffer;
|
||||
class NzVertexBuffer;
|
||||
|
||||
struct NzMeshData
|
||||
{
|
||||
nzPrimitiveMode primitiveMode;
|
||||
const NzIndexBuffer* indexBuffer;
|
||||
const NzVertexBuffer* vertexBuffer;
|
||||
};
|
||||
|
||||
#endif // NAZARA_MESHDATA_HPP
|
||||
Reference in New Issue
Block a user