本文整理汇总了C++中ogre::SubEntity::setMaterial方法的典型用法代码示例。如果您正苦于以下问题:C++ SubEntity::setMaterial方法的具体用法?C++ SubEntity::setMaterial怎么用?C++ SubEntity::setMaterial使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::SubEntity
的用法示例。
在下文中一共展示了SubEntity::setMaterial方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: replace_texture_now
void LIRenAttachmentEntity::replace_texture_now (const Ogre::String& name, Ogre::TexturePtr& texture)
{
if (mesh.isNull () || entity == NULL)
return;
// Translate the name if already replaced before.
std::map<Ogre::String, Ogre::String>::const_iterator iter;
iter = applied_texture_replaces.find(name);
Ogre::String real_name;
if (iter != applied_texture_replaces.end())
real_name = iter->second;
else
real_name = name;
// Save the replaced name for future translations.
applied_texture_replaces[name] = texture->getName ();
// Replace in each submesh.
for (size_t subent_idx = 0 ; subent_idx < entity->getNumSubEntities () ; ++subent_idx)
{
// Get the material of the subent.
Ogre::SubEntity* subent = entity->getSubEntity (subent_idx);
Ogre::MaterialPtr submat = subent->getMaterial ();
if (submat.isNull ())
continue;
// Check if there are replaceable textures.
if (!render->material_utils->has_overridable_texture (submat, real_name))
continue;
// Create a modified version of the material.
Ogre::String new_name = render->id.next ();
Ogre::MaterialPtr material = submat->clone (new_name, true, LIREN_RESOURCES_TEMPORARY);
render->material_utils->replace_texture (material, real_name, texture->getName ());
subent->setMaterial (material);
}
}