Former-commit-id: 51b2eb160cee64341f659cb9233f7323648196ff [formerly eed84804d642972f3952ed5ea5c3991afb6c9657] [formerly 9eb1f9d149bf3eb9beeea950d780e713acbd34b1 [formerly eec842ec8bcebc5e04f2b48c18ec608ae5a82014]] Former-commit-id: 82dee95422af697ba8319c53a60f32bf98ff31da [formerly c797b9f8a5964390dcdd2a55271e7a18896a8d8f] Former-commit-id: 8c5e34da6e3686be332a84613230a6734b58966a
96 lines
3.0 KiB
C++
96 lines
3.0 KiB
C++
// Copyright (C) 2015 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_MODEL_HPP
|
|
#define NAZARA_MODEL_HPP
|
|
|
|
#include <Nazara/Prerequesites.hpp>
|
|
#include <Nazara/Core/Resource.hpp>
|
|
#include <Nazara/Core/ResourceLoader.hpp>
|
|
#include <Nazara/Core/ResourceParameters.hpp>
|
|
#include <Nazara/Graphics/InstancedRenderable.hpp>
|
|
#include <Nazara/Graphics/Material.hpp>
|
|
#include <Nazara/Utility/Mesh.hpp>
|
|
|
|
namespace Nz
|
|
{
|
|
struct NAZARA_GRAPHICS_API ModelParameters : ResourceParameters
|
|
{
|
|
ModelParameters();
|
|
|
|
bool loadMaterials = true;
|
|
MaterialParams material;
|
|
MeshParams mesh;
|
|
|
|
bool IsValid() const;
|
|
};
|
|
|
|
class Model;
|
|
|
|
using ModelConstRef = ObjectRef<const Model>;
|
|
using ModelLoader = ResourceLoader<Model, ModelParameters>;
|
|
using ModelRef = ObjectRef<Model>;
|
|
|
|
class NAZARA_GRAPHICS_API Model : public InstancedRenderable, public Resource
|
|
{
|
|
friend ModelLoader;
|
|
|
|
public:
|
|
Model();
|
|
Model(const Model& model) = default;
|
|
Model(Model&& model) = default;
|
|
virtual ~Model();
|
|
|
|
void AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData) const override;
|
|
inline void AddToRenderQueue(AbstractRenderQueue* renderQueue, const Matrix4f& transformMatrix, unsigned int renderOrder = 0);
|
|
|
|
Material* GetMaterial(const String& subMeshName) const;
|
|
Material* GetMaterial(unsigned int matIndex) const;
|
|
Material* GetMaterial(unsigned int skinIndex, const String& subMeshName) const;
|
|
Material* GetMaterial(unsigned int skinIndex, unsigned int matIndex) const;
|
|
unsigned int GetMaterialCount() const;
|
|
unsigned int GetSkin() const;
|
|
unsigned int GetSkinCount() const;
|
|
Mesh* GetMesh() const;
|
|
|
|
virtual bool IsAnimated() const;
|
|
|
|
bool LoadFromFile(const String& filePath, const ModelParameters& params = ModelParameters());
|
|
bool LoadFromMemory(const void* data, std::size_t size, const ModelParameters& params = ModelParameters());
|
|
bool LoadFromStream(Stream& stream, const ModelParameters& params = ModelParameters());
|
|
|
|
void Reset();
|
|
|
|
bool SetMaterial(const String& subMeshName, Material* material);
|
|
void SetMaterial(unsigned int matIndex, Material* material);
|
|
bool SetMaterial(unsigned int skinIndex, const String& subMeshName, Material* material);
|
|
void SetMaterial(unsigned int skinIndex, unsigned int matIndex, Material* material);
|
|
virtual void SetMesh(Mesh* mesh);
|
|
void SetSkin(unsigned int skin);
|
|
void SetSkinCount(unsigned int skinCount);
|
|
|
|
Model& operator=(const Model& node) = default;
|
|
Model& operator=(Model&& node) = default;
|
|
|
|
template<typename... Args> static ModelRef New(Args&&... args);
|
|
|
|
protected:
|
|
void MakeBoundingVolume() const override;
|
|
|
|
std::vector<MaterialRef> m_materials;
|
|
MeshRef m_mesh;
|
|
unsigned int m_matCount;
|
|
unsigned int m_skin;
|
|
unsigned int m_skinCount;
|
|
|
|
static ModelLoader::LoaderList s_loaders;
|
|
};
|
|
}
|
|
|
|
#include <Nazara/Graphics/Model.inl>
|
|
|
|
#endif // NAZARA_MODEL_HPP
|