本文整理汇总了C++中ogre::SubEntity::setMaterialName方法的典型用法代码示例。如果您正苦于以下问题:C++ SubEntity::setMaterialName方法的具体用法?C++ SubEntity::setMaterialName怎么用?C++ SubEntity::setMaterialName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::SubEntity
的用法示例。
在下文中一共展示了SubEntity::setMaterialName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetUnSelLook
// 设置正常的外观颜色.
void CEditDobject_NT::SetUnSelLook()
{
if(0 == m_materilaOldVector.size())
{
return;
}
int iCount = m_EntityList.size();
Ogre::Entity* pEntity = NULL;
int iIndex = 0;
for(int i = 0; i < iCount; i++)
{
pEntity = m_EntityList[i].pEntity;
if(pEntity)
{
Ogre::SubEntity* pSubEntiy = pEntity->getSubEntity(0);
if(pSubEntiy)
{
if(iIndex >= (int)m_materilaOldVector.size())
{
continue;
}
std::string strMaterialName = m_materilaOldVector[iIndex]->getName();
pSubEntiy->setMaterialName(strMaterialName);
iIndex++;
}
}
}
}
示例2:
void ResourceGroupReloader::UpdateMaterialRenderableVisitor::visit(
Ogre::Renderable *rend, Ogre::ushort lodIndex, bool isDebug, Ogre::Any *pAny)
{
const Ogre::MaterialPtr mat = rend->getMaterial();
if(!mat.isNull())
{
std::string newMatName = mat->getName();
Ogre::MaterialPtr newMat = Ogre::MaterialManager::getSingleton().getByName(newMatName);
if(newMat.isNull())
{
// this can happen if there was error during the reloading of the material.
// in that case, we keep the ancient one.
// Ice::Log::Instance().LogMessage(newMatName+" : new material is null!");
return;
}
// unfortunately, the renderable gives access only to a const MaterialPtr.
// and there is no 'setMaterial' or 'setMaterialName' method on renderables.
// so I have to try to down cast with known classes...
{
Ogre::SubEntity* lRend = dynamic_cast<Ogre::SubEntity*>(rend);
if(lRend){lRend->setMaterialName(newMatName);return;}
}
{
Ogre::SimpleRenderable* lRend = dynamic_cast<Ogre::SimpleRenderable*>(rend);
if(lRend){lRend->setMaterial(newMatName);return;}
}
{
Ogre::ShadowRenderable* lRend = dynamic_cast<Ogre::ShadowRenderable*>(rend);
if(lRend){lRend->setMaterial(newMat);return;}
}
{
Ogre::BillboardChain* lRend = dynamic_cast<Ogre::BillboardChain*>(rend);
if(lRend){lRend->setMaterialName(newMatName);return;}
}
{
Ogre::BillboardSet* lRend = dynamic_cast<Ogre::BillboardSet*>(rend);
if(lRend){lRend->setMaterialName(newMatName);return;}
}
{
Ogre::OverlayElement* lRend = dynamic_cast<Ogre::OverlayElement*>(rend);
if(lRend){lRend->setMaterialName(newMatName);return;}
}
}else{
// was there for debug...
// Ice::Log::Instance().LogMessage("material of renderable is null!");
}
}
示例3: processEntity
void Level::processEntity(TiXmlElement *XMLNode, Ogre::SceneNode *parent)
{
Ogre::String name = getAttribute(XMLNode, "name");
Ogre::String meshFile = getAttribute(XMLNode, "meshFile");
TiXmlElement *element;
Ogre::Entity *entity = 0;
try
{
entity = mSceneMgr->createEntity(name, meshFile);
entity->setCastShadows(true);
PhysicsManager::instance()->createConvexMesh(entity);
element = XMLNode->FirstChildElement("subentities");
if(element)
{
element = element->FirstChildElement("subentity");
while (element)
{
Ogre::SubEntity *subEnt;
Ogre::String materialFile = getAttribute(element, "materialName");
unsigned int index = Ogre::StringConverter::parseInt(getAttribute(element,"index"));
subEnt = entity->getSubEntity(index);
subEnt->setMaterialName(materialFile);
element = element->NextSiblingElement("subentity");
}
}
entity->setRenderingDistance(1000);
parent->attachObject(entity);
}
catch(Ogre::Exception e)
{
Ogre::LogManager::getSingleton().logMessage("Error loading an entity!");
}
element = XMLNode->FirstChildElement("userDataReference");
}
示例4: ReadEntity
void FvXMLAnimationModelSerializerImpl::ReadEntity(
FvXMLSectionPtr spSection, Ogre::SceneNode* pkNode, FvAnimationModel* pkDest )
{
Ogre::SceneManager *pkSceneManager = Ogre::Root::getSingleton().
_getCurrentSceneManager();
FV_ASSERT(pkSceneManager);
FvString kMeshIdentifier = spSection->ReadString("identifier");
FvString kMeshFile = spSection->ReadString("mesh");
Ogre::Entity *pkEntity = pkSceneManager->createEntity(
pkNode->getName() + "_" + kMeshIdentifier,kMeshFile);
FV_ASSERT(pkEntity);
pkEntity->setCastShadows(pkDest->m_bCastShadows);
pkNode->attachObject(pkEntity);
pkDest->m_akNodes[pkDest->m_u32CurrentLodLevel].m_kEntityList.push_back(pkEntity);
pkEntity->setRenderQueueGroup(RENDER_QUEUE_MAX);
AnimationStateSet *pkAnimations = pkEntity->getAllAnimationStates();
if(pkAnimations)
{
AnimationStateIterator kIt = pkAnimations->getAnimationStateIterator();
while (kIt.hasMoreElements())
{
AnimationState *pkAnim= kIt.getNext();
if(pkDest->GetAnimation(pkAnim->getAnimationName()) == NULL)
pkDest->m_kModelAnimations.insert(std::make_pair(pkAnim->getAnimationName(),pkAnim));
}
}
std::vector<FvXMLSectionPtr> kSubentities;
spSection->OpenSections("subentities/subentity",kSubentities);
std::vector<FvXMLSectionPtr>::iterator kSubIt = kSubentities.begin();
for(; kSubIt != kSubentities.end(); ++kSubIt)
{
int iIndex = (*kSubIt)->ReadInt("index",-1);
FvString kMaterialName = (*kSubIt)->ReadString("materialName");
Ogre::SubEntity *pkSubEntity = pkEntity->getSubEntity(iIndex);
if(pkSubEntity && !kMaterialName.empty())
pkSubEntity->setMaterialName(kMaterialName);
}
}
示例5: SetSelectLook
// 设置选中的外观颜色.
void CEditDobject_NT::SetSelectLook(Ogre::ColourValue color)
{
if(0 == m_materialSelVector.size())
{
// 选中材质的名字.
Ogre::String strCloneName;
int iCount = m_EntityList.size();
Ogre::Entity* pEntity = NULL;
for(int i = 0; i < iCount; i++)
{
pEntity = m_EntityList[i].pEntity;
if(pEntity)
{
Ogre::SubEntity* pSubEntiy = pEntity->getSubEntity(0);
if(pSubEntiy)
{
Ogre::MaterialPtr pMaterial = pSubEntiy->getMaterial();
if(pMaterial.isNull())
{
return;
}//
const Ogre::String& strName = pMaterial->getName();
if("BaseWhite" == strName)
{
continue;
}
strCloneName = strName;
strCloneName += "_select";
Ogre::MaterialManager* pMaterialManager = (Ogre::MaterialManager*)(pMaterial->getCreator());
if(NULL == pMaterialManager)
{
return;
}
Ogre::MaterialPtr pMaterialClone = pMaterialManager->getByName(strCloneName);
if(pMaterialClone.isNull())
{
pMaterialClone = pMaterial->clone(strCloneName);
}
//if(!pMaterialClone)
//{
// return;
//}//
Ogre::Technique* pTechnique = pMaterialClone->getBestTechnique();
Ogre::Pass* pPass = pTechnique->getPass(0);
//pPass->setSceneBlending(SBT_ADD);
//pPass->setSceneBlending(SBF_SOURCE_ALPHA , SBF_ONE_MINUS_SOURCE_ALPHA );
//pTextureState->setAlphaOperation(LBX_MODULATE, LBS_TEXTURE, LBS_MANUAL, 1, Transparence, 1);//
Ogre::TextureUnitState* pTextureState = pPass->getTextureUnitState(0);
pTextureState->setColourOperationEx(Ogre::LBX_ADD , Ogre::LBS_TEXTURE , Ogre::LBS_MANUAL, color, color );
pSubEntiy->setMaterialName(strCloneName);
m_materialSelVector.push_back(pMaterialClone);
m_materilaOldVector.push_back(pMaterial);
}
}
}
}
else
{
int iIndex = 0;
int iCount = m_EntityList.size();
Ogre::Entity* pEntity = NULL;
for(int i = 0; i < iCount; i++)
{
pEntity = m_EntityList[i].pEntity;
if(pEntity)
{
Ogre::SubEntity* pSubEntiy = pEntity->getSubEntity(0);
if(pSubEntiy)
{
if(iIndex >= (int)m_materialSelVector.size())
{
continue;
}
std::string strMaterialName = m_materialSelVector[iIndex]->getName();
pSubEntiy->setMaterialName(strMaterialName);
iIndex++;
}
}
//.........这里部分代码省略.........
示例6: processEntityStaticGeoemtry
bool LevelGeometryLoader::processEntityStaticGeoemtry(TiXmlElement *XMLNode,
Ogre::StaticGeometry *sgeo)
{
ASSERT(XMLNode);
ASSERT(sgeo);
// Process attributes
Ogre::String meshFile = Ogre::DotSceneLoader::getAttrib(XMLNode, "meshFile");
Ogre::Vector3 position = Ogre::Vector3::ZERO;
Ogre::Quaternion rotation = Ogre::Quaternion::IDENTITY;
Ogre::Vector3 scale = Ogre::Vector3::UNIT_SCALE;
std::vector<Ogre::String> subEntities;
// parse the entity
// get the origin
TiXmlElement *auxPElem = XMLNode->FirstChildElement("position");
if(auxPElem) {
position = Ogre::DotSceneLoader::parseVector3(auxPElem);
}
// get the rotation
auxPElem = XMLNode->FirstChildElement("rotation");
if(auxPElem) {
rotation = Ogre::DotSceneLoader::parseQuaternion(auxPElem);
}
// get the scale
auxPElem = XMLNode->FirstChildElement("scale");
if(auxPElem) {
scale = Ogre::DotSceneLoader::parseVector3(auxPElem);
}
size_t count = 0;
// load the subentities
TiXmlElement *pElement = XMLNode->FirstChildElement("subentities");
if(pElement){
auxPElem = pElement->FirstChildElement("subentity");
// ugly! very
while(auxPElem) {
auxPElem = auxPElem->NextSiblingElement("subentity");
count++;
}
subEntities.resize(count);
pElement = pElement->FirstChildElement("subentity");
while(pElement){
int index = Ogre::DotSceneLoader::getAttribInt(pElement, "index");
subEntities[index] = Ogre::DotSceneLoader::getAttrib(pElement, "materialName");
pElement = pElement->NextSiblingElement("subentity");
}
}
// creates the entity
Ogre::Entity *ent = 0;
try {
ent = Common::GlobalObjects::sceneManager->createEntity("entity_" + meshFile, meshFile);
} catch (...) {
return false;
}
// set the subentities config
size_t subentityCount = std::min(subEntities.size(), (size_t)ent->getNumSubEntities());
for (size_t subentityIndex = 0; subentityIndex < subentityCount; subentityIndex++)
{
Ogre::SubEntity* subentity = ent->getSubEntity((unsigned int)subentityIndex);
subentity->setMaterialName(subEntities[subentityIndex]);
}
// add the entitie to the static geometry
sgeo->addEntity(ent, position, rotation, scale);
Common::GlobalObjects::sceneManager->destroyEntity(ent);
return true;
}
示例7: _setEntityMaterial
VBOOL VLogicModel::_setEntityMaterial(const VString &entityName, const VString &matName)
{
if (matName.empty())
{
return VTRUE;
}
else
{
VEntityMap::iterator itr = mEntities.find(entityName);
if (itr == mEntities.end())
{
Ogre::LogManager::getSingleton().logMessage( "Logic Model Entity with name '" + entityName + "' dosen't exists! " +
"LogicModel::_setEntityMaterial " + mName );
return VFALSE;
}
VEntityValue &entValue = itr->second;
Ogre::Entity *entity = entValue.mEntity;
assert(entity);
if (matName.find(";") != VString::npos)
{
Ogre::StringVector matNames = Ogre::StringUtil::split(matName, ";");
assert(matName.size() > 1);
for (VUINT32 i = 0; i < entity->getNumSubEntities(); ++i)
{
Ogre::SubEntity *subEntity = entity->getSubEntity(i);
assert(subEntity);
VString subMatName;
if (i < matNames.size())
{
subMatName = matNames[i];
}
else
{
subMatName = matNames[0];
}
const Ogre::MaterialPtr subMat = Ogre::MaterialManager::getSingleton().getByName(subMatName);
if (!subMat.isNull())
{
subEntity->setMaterialName(subMatName);
}
}
}
else
{
const Ogre::MaterialPtr entityMat = Ogre::MaterialManager::getSingleton().getByName(matName);
if (!entityMat.isNull())
{
entity->setMaterialName(matName);
}
}
}
return VTRUE;
}