Switch from Nz prefix to namespace Nz
What a huge commit Former-commit-id: 38ac5eebf70adc1180f571f6006192d28fb99897
This commit is contained in:
@@ -22,127 +22,130 @@
|
||||
#include <Nazara/Utility/SubMesh.hpp>
|
||||
#include <Nazara/Utility/VertexStruct.hpp>
|
||||
|
||||
struct NAZARA_UTILITY_API NzMeshParams
|
||||
namespace Nz
|
||||
{
|
||||
NzMeshParams(); // Vérifie que le storage par défaut est supporté (software autrement)
|
||||
struct NAZARA_UTILITY_API MeshParams
|
||||
{
|
||||
MeshParams(); // Vérifie que le storage par défaut est supporté (software autrement)
|
||||
|
||||
// La mise à l'échelle éventuelle que subira le mesh
|
||||
NzVector3f scale = NzVector3f::Unit();
|
||||
// La mise à l'échelle éventuelle que subira le mesh
|
||||
Vector3f scale = Vector3f::Unit();
|
||||
|
||||
// Si ceci sera le stockage utilisé par les buffers
|
||||
nzUInt32 storage = nzDataStorage_Hardware;
|
||||
// Si ceci sera le stockage utilisé par les buffers
|
||||
UInt32 storage = DataStorage_Hardware;
|
||||
|
||||
// Charger une version animée du mesh si possible ?
|
||||
bool animated = true;
|
||||
// Charger une version animée du mesh si possible ?
|
||||
bool animated = true;
|
||||
|
||||
// Faut-il centrer le mesh autour de l'origine ?
|
||||
bool center = false;
|
||||
// Faut-il centrer le mesh autour de l'origine ?
|
||||
bool center = false;
|
||||
|
||||
// Faut-il retourner les UV ?
|
||||
bool flipUVs = false;
|
||||
// Faut-il retourner les UV ?
|
||||
bool flipUVs = false;
|
||||
|
||||
// Faut-il optimiser les index buffers ? (Rendu plus rapide, mais le chargement dure plus longtemps)
|
||||
bool optimizeIndexBuffers = true;
|
||||
// Faut-il optimiser les index buffers ? (Rendu plus rapide, mais le chargement dure plus longtemps)
|
||||
bool optimizeIndexBuffers = true;
|
||||
|
||||
bool IsValid() const;
|
||||
};
|
||||
|
||||
class NzMesh;
|
||||
class NzPrimitiveList;
|
||||
|
||||
typedef NzVertexStruct_XYZ_Normal_UV_Tangent NzMeshVertex;
|
||||
typedef NzVertexStruct_XYZ_Normal_UV_Tangent_Skinning NzSkeletalMeshVertex;
|
||||
|
||||
using NzMeshConstRef = NzObjectRef<const NzMesh>;
|
||||
using NzMeshLibrary = NzObjectLibrary<NzMesh>;
|
||||
using NzMeshLoader = NzResourceLoader<NzMesh, NzMeshParams>;
|
||||
using NzMeshManager = NzResourceManager<NzMesh, NzMeshParams>;
|
||||
using NzMeshRef = NzObjectRef<NzMesh>;
|
||||
|
||||
struct NzMeshImpl;
|
||||
|
||||
class NAZARA_UTILITY_API NzMesh : public NzRefCounted, public NzResource
|
||||
{
|
||||
friend NzMeshLibrary;
|
||||
friend NzMeshLoader;
|
||||
friend NzMeshManager;
|
||||
friend class NzUtility;
|
||||
|
||||
public:
|
||||
NzMesh() = default;
|
||||
~NzMesh();
|
||||
|
||||
void AddSubMesh(NzSubMesh* subMesh);
|
||||
void AddSubMesh(const NzString& identifier, NzSubMesh* subMesh);
|
||||
|
||||
NzSubMesh* BuildSubMesh(const NzPrimitive& primitive, const NzMeshParams& params = NzMeshParams());
|
||||
void BuildSubMeshes(const NzPrimitiveList& list, const NzMeshParams& params = NzMeshParams());
|
||||
|
||||
bool CreateSkeletal(unsigned int jointCount);
|
||||
bool CreateStatic();
|
||||
void Destroy();
|
||||
|
||||
void GenerateNormals();
|
||||
void GenerateNormalsAndTangents();
|
||||
void GenerateTangents();
|
||||
|
||||
const NzBoxf& GetAABB() const;
|
||||
NzString GetAnimation() const;
|
||||
nzAnimationType GetAnimationType() const;
|
||||
unsigned int GetJointCount() const;
|
||||
NzString GetMaterial(unsigned int index) const;
|
||||
unsigned int GetMaterialCount() const;
|
||||
NzSkeleton* GetSkeleton();
|
||||
const NzSkeleton* GetSkeleton() const;
|
||||
NzSubMesh* GetSubMesh(const NzString& identifier);
|
||||
NzSubMesh* GetSubMesh(unsigned int index);
|
||||
const NzSubMesh* GetSubMesh(const NzString& identifier) const;
|
||||
const NzSubMesh* GetSubMesh(unsigned int index) const;
|
||||
unsigned int GetSubMeshCount() const;
|
||||
int GetSubMeshIndex(const NzString& identifier) const;
|
||||
unsigned int GetTriangleCount() const;
|
||||
unsigned int GetVertexCount() const;
|
||||
|
||||
bool HasSubMesh(const NzString& identifier) const;
|
||||
bool HasSubMesh(unsigned int index = 0) const;
|
||||
|
||||
void InvalidateAABB() const;
|
||||
|
||||
bool IsAnimable() const;
|
||||
bool IsValid() const;
|
||||
};
|
||||
|
||||
bool LoadFromFile(const NzString& filePath, const NzMeshParams& params = NzMeshParams());
|
||||
bool LoadFromMemory(const void* data, std::size_t size, const NzMeshParams& params = NzMeshParams());
|
||||
bool LoadFromStream(NzInputStream& stream, const NzMeshParams& params = NzMeshParams());
|
||||
class Mesh;
|
||||
class PrimitiveList;
|
||||
|
||||
void Recenter();
|
||||
typedef VertexStruct_XYZ_Normal_UV_Tangent MeshVertex;
|
||||
typedef VertexStruct_XYZ_Normal_UV_Tangent_Skinning SkeletalMeshVertex;
|
||||
|
||||
void RemoveSubMesh(const NzString& identifier);
|
||||
void RemoveSubMesh(unsigned int index);
|
||||
using MeshConstRef = ObjectRef<const Mesh>;
|
||||
using MeshLibrary = ObjectLibrary<Mesh>;
|
||||
using MeshLoader = ResourceLoader<Mesh, MeshParams>;
|
||||
using MeshManager = ResourceManager<Mesh, MeshParams>;
|
||||
using MeshRef = ObjectRef<Mesh>;
|
||||
|
||||
void SetAnimation(const NzString& animationPath);
|
||||
void SetMaterial(unsigned int matIndex, const NzString& materialPath);
|
||||
void SetMaterialCount(unsigned int matCount);
|
||||
struct MeshImpl;
|
||||
|
||||
void Transform(const NzMatrix4f& matrix);
|
||||
class NAZARA_UTILITY_API Mesh : public RefCounted, public Resource
|
||||
{
|
||||
friend MeshLibrary;
|
||||
friend MeshLoader;
|
||||
friend MeshManager;
|
||||
friend class Utility;
|
||||
|
||||
template<typename... Args> static NzMeshRef New(Args&&... args);
|
||||
public:
|
||||
Mesh() = default;
|
||||
~Mesh();
|
||||
|
||||
// Signals:
|
||||
NazaraSignal(OnMeshDestroy, const NzMesh* /*mesh*/);
|
||||
NazaraSignal(OnMeshRelease, const NzMesh* /*mesh*/);
|
||||
void AddSubMesh(SubMesh* subMesh);
|
||||
void AddSubMesh(const String& identifier, SubMesh* subMesh);
|
||||
|
||||
private:
|
||||
NzMeshImpl* m_impl = nullptr;
|
||||
SubMesh* BuildSubMesh(const Primitive& primitive, const MeshParams& params = MeshParams());
|
||||
void BuildSubMeshes(const PrimitiveList& list, const MeshParams& params = MeshParams());
|
||||
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
bool CreateSkeletal(unsigned int jointCount);
|
||||
bool CreateStatic();
|
||||
void Destroy();
|
||||
|
||||
static NzMeshLibrary::LibraryMap s_library;
|
||||
static NzMeshLoader::LoaderList s_loaders;
|
||||
static NzMeshManager::ManagerMap s_managerMap;
|
||||
static NzMeshManager::ManagerParams s_managerParameters;
|
||||
};
|
||||
void GenerateNormals();
|
||||
void GenerateNormalsAndTangents();
|
||||
void GenerateTangents();
|
||||
|
||||
const Boxf& GetAABB() const;
|
||||
String GetAnimation() const;
|
||||
AnimationType GetAnimationType() const;
|
||||
unsigned int GetJointCount() const;
|
||||
String GetMaterial(unsigned int index) const;
|
||||
unsigned int GetMaterialCount() const;
|
||||
Skeleton* GetSkeleton();
|
||||
const Skeleton* GetSkeleton() const;
|
||||
SubMesh* GetSubMesh(const String& identifier);
|
||||
SubMesh* GetSubMesh(unsigned int index);
|
||||
const SubMesh* GetSubMesh(const String& identifier) const;
|
||||
const SubMesh* GetSubMesh(unsigned int index) const;
|
||||
unsigned int GetSubMeshCount() const;
|
||||
int GetSubMeshIndex(const String& identifier) const;
|
||||
unsigned int GetTriangleCount() const;
|
||||
unsigned int GetVertexCount() const;
|
||||
|
||||
bool HasSubMesh(const String& identifier) const;
|
||||
bool HasSubMesh(unsigned int index = 0) const;
|
||||
|
||||
void InvalidateAABB() const;
|
||||
|
||||
bool IsAnimable() const;
|
||||
bool IsValid() const;
|
||||
|
||||
bool LoadFromFile(const String& filePath, const MeshParams& params = MeshParams());
|
||||
bool LoadFromMemory(const void* data, std::size_t size, const MeshParams& params = MeshParams());
|
||||
bool LoadFromStream(InputStream& stream, const MeshParams& params = MeshParams());
|
||||
|
||||
void Recenter();
|
||||
|
||||
void RemoveSubMesh(const String& identifier);
|
||||
void RemoveSubMesh(unsigned int index);
|
||||
|
||||
void SetAnimation(const String& animationPath);
|
||||
void SetMaterial(unsigned int matIndex, const String& materialPath);
|
||||
void SetMaterialCount(unsigned int matCount);
|
||||
|
||||
void Transform(const Matrix4f& matrix);
|
||||
|
||||
template<typename... Args> static MeshRef New(Args&&... args);
|
||||
|
||||
// Signals:
|
||||
NazaraSignal(OnMeshDestroy, const Mesh* /*mesh*/);
|
||||
NazaraSignal(OnMeshRelease, const Mesh* /*mesh*/);
|
||||
|
||||
private:
|
||||
MeshImpl* m_impl = nullptr;
|
||||
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
|
||||
static MeshLibrary::LibraryMap s_library;
|
||||
static MeshLoader::LoaderList s_loaders;
|
||||
static MeshManager::ManagerMap s_managerMap;
|
||||
static MeshManager::ManagerParams s_managerParameters;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/Mesh.inl>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user