Graphics/Model: Update to Renderable

(Note: this branch doesn't compile right now, this is normal)


Former-commit-id: 8c7e823122744394dda31db9acbfe2823c6f29e2
This commit is contained in:
Lynix 2015-05-26 14:16:05 +02:00
parent f181d0f2df
commit e1a25a8885
2 changed files with 6 additions and 56 deletions

View File

@ -11,7 +11,7 @@
#include <Nazara/Core/Resource.hpp>
#include <Nazara/Core/ResourceLoader.hpp>
#include <Nazara/Graphics/Material.hpp>
#include <Nazara/Graphics/SceneNode.hpp>
#include <Nazara/Graphics/Renderable.hpp>
#include <Nazara/Utility/Mesh.hpp>
struct NAZARA_API NzModelParameters
@ -29,17 +29,17 @@ class NzModel;
using NzModelLoader = NzResourceLoader<NzModel, NzModelParameters>;
class NAZARA_API NzModel : public NzResource, public NzSceneNode
class NAZARA_API NzModel : public NzRenderable, public NzResource
{
friend NzModelLoader;
friend class NzScene;
public:
NzModel();
NzModel(const NzModel& model);
NzModel(const NzModel& model) = default;
virtual ~NzModel();
void AddToRenderQueue(NzAbstractRenderQueue* renderQueue) const override;
void AddToRenderQueue(NzAbstractRenderQueue* renderQueue, const NzMatrix4f& transformMatrix) const override;
NzModel* Clone() const;
NzModel* Create() const;
@ -52,12 +52,8 @@ class NAZARA_API NzModel : public NzResource, public NzSceneNode
unsigned int GetSkin() const;
unsigned int GetSkinCount() const;
NzMesh* GetMesh() const;
nzSceneNodeType GetSceneNodeType() const override;
virtual bool IsAnimated() const;
bool IsDrawable() const;
void InvalidateBoundingVolume();
bool LoadFromFile(const NzString& filePath, const NzModelParameters& params = NzModelParameters());
bool LoadFromMemory(const void* data, std::size_t size, const NzModelParameters& params = NzModelParameters());
@ -75,7 +71,7 @@ class NAZARA_API NzModel : public NzResource, public NzSceneNode
void SetSkin(unsigned int skin);
void SetSkinCount(unsigned int skinCount);
NzModel& operator=(const NzModel& node);
NzModel& operator=(const NzModel& node) = default;
protected:
void MakeBoundingVolume() const override;

View File

@ -31,27 +31,13 @@ m_skinCount(1)
{
}
NzModel::NzModel(const NzModel& model) :
NzResource(model),
NzSceneNode(model),
m_materials(model.m_materials),
m_mesh(model.m_mesh),
m_matCount(model.m_matCount),
m_skin(model.m_skin),
m_skinCount(model.m_skinCount)
{
SetParent(model.GetParent());
}
NzModel::~NzModel()
{
Reset();
}
void NzModel::AddToRenderQueue(NzAbstractRenderQueue* renderQueue) const
void NzModel::AddToRenderQueue(NzAbstractRenderQueue* renderQueue, const NzMatrix4f& transformMatrix) const
{
const NzMatrix4f& transformMatrix = GetTransformMatrix();
unsigned int submeshCount = m_mesh->GetSubMeshCount();
for (unsigned int i = 0; i < submeshCount; ++i)
{
@ -173,11 +159,6 @@ NzMesh* NzModel::GetMesh() const
return m_mesh;
}
nzSceneNodeType NzModel::GetSceneNodeType() const
{
return nzSceneNodeType_Model;
}
unsigned int NzModel::GetSkin() const
{
return m_skin;
@ -193,17 +174,6 @@ bool NzModel::IsAnimated() const
return false;
}
bool NzModel::IsDrawable() const
{
return m_mesh != nullptr && m_mesh->GetSubMeshCount() >= 1;
}
void NzModel::InvalidateBoundingVolume()
{
m_boundingVolume.MakeNull();
m_boundingVolumeUpdated = false;
}
bool NzModel::LoadFromFile(const NzString& filePath, const NzModelParameters& params)
{
return NzModelLoader::LoadFromFile(this, filePath, params);
@ -389,22 +359,6 @@ void NzModel::SetSkinCount(unsigned int skinCount)
m_skinCount = skinCount;
}
NzModel& NzModel::operator=(const NzModel& node)
{
NzResource::operator=(node);
NzSceneNode::operator=(node);
m_boundingVolume = node.m_boundingVolume;
m_boundingVolumeUpdated = node.m_boundingVolumeUpdated;
m_matCount = node.m_matCount;
m_materials = node.m_materials;
m_mesh = node.m_mesh;
m_skin = node.m_skin;
m_skinCount = node.m_skinCount;
return *this;
}
void NzModel::MakeBoundingVolume() const
{
if (m_mesh)