本文整理汇总了C++中SubMesh::GetMaterialIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ SubMesh::GetMaterialIndex方法的具体用法?C++ SubMesh::GetMaterialIndex怎么用?C++ SubMesh::GetMaterialIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SubMesh
的用法示例。
在下文中一共展示了SubMesh::GetMaterialIndex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetMaterial
bool Model::SetMaterial(unsigned int skinIndex, const String& subMeshName, Material* material)
{
#if NAZARA_GRAPHICS_SAFE
if (skinIndex >= m_skinCount)
{
NazaraError("Skin index out of range (" + String::Number(skinIndex) + " >= " + String::Number(m_skinCount));
return false;
}
#endif
SubMesh* 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 (" + String::Number(matIndex) + " >= " + String::Number(m_matCount));
return false;
}
unsigned int index = skinIndex * m_matCount + matIndex;
if (material)
m_materials[index] = material;
else
m_materials[index] = Material::GetDefault();
return true;
}
示例2: GetMaterial
Material* Model::GetMaterial(const String& subMeshName) const
{
#if NAZARA_GRAPHICS_SAFE
if (!m_mesh)
{
NazaraError("Model has no mesh");
return nullptr;
}
#endif
SubMesh* 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 (" + String::Number(matIndex) + " >= " + String::Number(m_matCount) + ')');
return nullptr;
}
return m_materials[m_skin * m_matCount + matIndex];
}