Added user-friendly method for accessing materials
Former-commit-id: 6f254ea6e324b3467a811ba5282f67b6ea078d51
This commit is contained in:
parent
f8e942af65
commit
36f8631028
|
|
@ -49,7 +49,9 @@ class NAZARA_API NzModel : public NzSceneNode, public NzUpdatable
|
||||||
|
|
||||||
NzAnimation* GetAnimation() const;
|
NzAnimation* GetAnimation() const;
|
||||||
const NzBoundingBoxf& GetBoundingBox() const;
|
const NzBoundingBoxf& GetBoundingBox() const;
|
||||||
|
NzMaterial* GetMaterial(const NzString& subMeshName) const;
|
||||||
NzMaterial* GetMaterial(unsigned int matIndex) const;
|
NzMaterial* GetMaterial(unsigned int matIndex) const;
|
||||||
|
NzMaterial* GetMaterial(unsigned int skinIndex, const NzString& subMeshName) const;
|
||||||
NzMaterial* GetMaterial(unsigned int skinIndex, unsigned int matIndex) const;
|
NzMaterial* GetMaterial(unsigned int skinIndex, unsigned int matIndex) const;
|
||||||
unsigned int GetMaterialCount() const;
|
unsigned int GetMaterialCount() const;
|
||||||
unsigned int GetSkin() const;
|
unsigned int GetSkin() const;
|
||||||
|
|
@ -71,7 +73,9 @@ class NAZARA_API NzModel : public NzSceneNode, public NzUpdatable
|
||||||
void Reset();
|
void Reset();
|
||||||
|
|
||||||
bool SetAnimation(NzAnimation* animation);
|
bool SetAnimation(NzAnimation* animation);
|
||||||
|
bool SetMaterial(const NzString& subMeshName, NzMaterial* material);
|
||||||
void SetMaterial(unsigned int matIndex, 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 SetMaterial(unsigned int skinIndex, unsigned int matIndex, NzMaterial* material);
|
||||||
void SetMesh(NzMesh* mesh);
|
void SetMesh(NzMesh* mesh);
|
||||||
bool SetSequence(const NzString& sequenceName);
|
bool SetSequence(const NzString& sequenceName);
|
||||||
|
|
|
||||||
|
|
@ -179,6 +179,33 @@ const NzBoundingBoxf& NzModel::GetBoundingBox() const
|
||||||
return m_boundingBox;
|
return m_boundingBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NzMaterial* NzModel::GetMaterial(const NzString& subMeshName) const
|
||||||
|
{
|
||||||
|
#if NAZARA_GRAPHICS_SAFE
|
||||||
|
if (!m_mesh)
|
||||||
|
{
|
||||||
|
NazaraError("Model has no mesh");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
NzSubMesh* subMesh = m_mesh->GetSubMesh(subMeshName);
|
||||||
|
if (!subMesh)
|
||||||
|
{
|
||||||
|
NazaraError("Mesh has no submesh \"" + subMeshName + '"');
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int matIndex = subMesh->GetMaterialIndex();
|
||||||
|
if (matIndex >= m_matCount)
|
||||||
|
{
|
||||||
|
NazaraError("Material index out of range (" + NzString::Number(matIndex) + " >= " + NzString::Number(m_matCount));
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_materials[m_skin*m_matCount + matIndex];
|
||||||
|
}
|
||||||
|
|
||||||
NzMaterial* NzModel::GetMaterial(unsigned int matIndex) const
|
NzMaterial* NzModel::GetMaterial(unsigned int matIndex) const
|
||||||
{
|
{
|
||||||
#if NAZARA_GRAPHICS_SAFE
|
#if NAZARA_GRAPHICS_SAFE
|
||||||
|
|
@ -192,6 +219,33 @@ NzMaterial* NzModel::GetMaterial(unsigned int matIndex) const
|
||||||
return m_materials[m_skin*m_matCount + matIndex];
|
return m_materials[m_skin*m_matCount + matIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NzMaterial* NzModel::GetMaterial(unsigned int skinIndex, const NzString& subMeshName) const
|
||||||
|
{
|
||||||
|
#if NAZARA_GRAPHICS_SAFE
|
||||||
|
if (skinIndex >= m_skinCount)
|
||||||
|
{
|
||||||
|
NazaraError("Skin index out of range (" + NzString::Number(skinIndex) + " >= " + NzString::Number(m_skinCount));
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
NzSubMesh* subMesh = m_mesh->GetSubMesh(subMeshName);
|
||||||
|
if (!subMesh)
|
||||||
|
{
|
||||||
|
NazaraError("Mesh has no submesh \"" + subMeshName + '"');
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int matIndex = subMesh->GetMaterialIndex();
|
||||||
|
if (matIndex >= m_matCount)
|
||||||
|
{
|
||||||
|
NazaraError("Material index out of range (" + NzString::Number(matIndex) + " >= " + NzString::Number(m_matCount));
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_materials[skinIndex*m_matCount + matIndex];
|
||||||
|
}
|
||||||
|
|
||||||
NzMaterial* NzModel::GetMaterial(unsigned int skinIndex, unsigned int matIndex) const
|
NzMaterial* NzModel::GetMaterial(unsigned int skinIndex, unsigned int matIndex) const
|
||||||
{
|
{
|
||||||
#if NAZARA_GRAPHICS_SAFE
|
#if NAZARA_GRAPHICS_SAFE
|
||||||
|
|
@ -342,6 +396,32 @@ bool NzModel::SetAnimation(NzAnimation* animation)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool NzModel::SetMaterial(const NzString& subMeshName, NzMaterial* material)
|
||||||
|
{
|
||||||
|
NzSubMesh* subMesh = m_mesh->GetSubMesh(subMeshName);
|
||||||
|
if (!subMesh)
|
||||||
|
{
|
||||||
|
NazaraError("Mesh has no submesh \"" + subMeshName + '"');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int matIndex = subMesh->GetMaterialIndex();
|
||||||
|
if (matIndex >= m_matCount)
|
||||||
|
{
|
||||||
|
NazaraError("Material index out of range (" + NzString::Number(matIndex) + " >= " + NzString::Number(m_matCount));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int index = m_skin*m_matCount + matIndex;
|
||||||
|
|
||||||
|
if (material)
|
||||||
|
m_materials[index] = material;
|
||||||
|
else
|
||||||
|
m_materials[index] = NzMaterial::GetDefault();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void NzModel::SetMaterial(unsigned int matIndex, NzMaterial* material)
|
void NzModel::SetMaterial(unsigned int matIndex, NzMaterial* material)
|
||||||
{
|
{
|
||||||
#if NAZARA_GRAPHICS_SAFE
|
#if NAZARA_GRAPHICS_SAFE
|
||||||
|
|
@ -360,6 +440,40 @@ void NzModel::SetMaterial(unsigned int matIndex, NzMaterial* material)
|
||||||
m_materials[index] = NzMaterial::GetDefault();
|
m_materials[index] = NzMaterial::GetDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool NzModel::SetMaterial(unsigned int skinIndex, const NzString& subMeshName, NzMaterial* material)
|
||||||
|
{
|
||||||
|
#if NAZARA_GRAPHICS_SAFE
|
||||||
|
if (skinIndex >= m_skinCount)
|
||||||
|
{
|
||||||
|
NazaraError("Skin index out of range (" + NzString::Number(skinIndex) + " >= " + NzString::Number(m_skinCount));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
NzSubMesh* subMesh = m_mesh->GetSubMesh(subMeshName);
|
||||||
|
if (!subMesh)
|
||||||
|
{
|
||||||
|
NazaraError("Mesh has no submesh \"" + subMeshName + '"');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int matIndex = subMesh->GetMaterialIndex();
|
||||||
|
if (matIndex >= m_matCount)
|
||||||
|
{
|
||||||
|
NazaraError("Material index out of range (" + NzString::Number(matIndex) + " >= " + NzString::Number(m_matCount));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int index = skinIndex*m_matCount + matIndex;
|
||||||
|
|
||||||
|
if (material)
|
||||||
|
m_materials[index] = material;
|
||||||
|
else
|
||||||
|
m_materials[index] = NzMaterial::GetDefault();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void NzModel::SetMaterial(unsigned int skinIndex, unsigned int matIndex, NzMaterial* material)
|
void NzModel::SetMaterial(unsigned int skinIndex, unsigned int matIndex, NzMaterial* material)
|
||||||
{
|
{
|
||||||
#if NAZARA_GRAPHICS_SAFE
|
#if NAZARA_GRAPHICS_SAFE
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue