本文整理汇总了C++中SimSet::findObjectByInternalName方法的典型用法代码示例。如果您正苦于以下问题:C++ SimSet::findObjectByInternalName方法的具体用法?C++ SimSet::findObjectByInternalName怎么用?C++ SimSet::findObjectByInternalName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimSet
的用法示例。
在下文中一共展示了SimSet::findObjectByInternalName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findOrCreate
TerrainMaterial* TerrainMaterial::findOrCreate( const char *nameOrPath )
{
SimSet *set = Sim::getTerrainMaterialSet();
if ( !nameOrPath || !nameOrPath[0] )
nameOrPath = "warning_material";
// See if we can just find it.
TerrainMaterial *mat = dynamic_cast<TerrainMaterial*>( set->findObjectByInternalName( StringTable->insert( nameOrPath ) ) );
if ( mat )
return mat;
// We didn't find it... so see if its a path to a
// file. If it is lets assume its the texture.
if ( GBitmap::sFindFiles( nameOrPath, NULL ) )
{
mat = new TerrainMaterial();
mat->setInternalName( nameOrPath );
mat->mDiffuseMap = nameOrPath;
mat->registerObject();
Sim::getRootGroup()->addObject( mat );
return mat;
}
// Ok... return a debug material then.
mat = dynamic_cast<TerrainMaterial*>( set->findObjectByInternalName( StringTable->insert( "warning_material" ) ) );
if ( !mat )
{
// This shouldn't happen.... the warning_texture should
// have already been defined in script, but we put this
// fallback here just in case it gets "lost".
mat = new TerrainMaterial();
mat->setInternalName( "warning_material" );
mat->mDiffuseMap = GFXTextureManager::getWarningTexturePath();
mat->mDiffuseSize = 500;
mat->mDetailMap = GFXTextureManager::getWarningTexturePath();
mat->mDetailSize = 5;
mat->mMacroMap = GFXTextureManager::getWarningTexturePath();
mat->mMacroSize = 200;
mat->registerObject();
Sim::getRootGroup()->addObject( mat );
}
return mat;
}
示例2: onAdd
bool TerrainMaterial::onAdd()
{
if ( !Parent::onAdd() )
return false;
SimSet *set = Sim::getTerrainMaterialSet();
// Make sure we have an internal name set.
if ( !mInternalName || !mInternalName[0] )
Con::warnf( "TerrainMaterial::onAdd() - No internal name set!" );
else
{
SimObject *object = set->findObjectByInternalName( mInternalName );
if ( object )
Con::warnf( "TerrainMaterial::onAdd() - Internal name collision; '%s' already exists!", mInternalName );
}
set->addObject( this );
return true;
}
示例3: findObjectByInternalName
SimObject* SimSet::findObjectByInternalName(StringTableEntry internalName, bool searchChildren)
{
iterator i;
for (i = begin(); i != end(); i++)
{
SimObject *childObj = static_cast<SimObject*>(*i);
if(childObj->getInternalName() == internalName)
return childObj;
else if (searchChildren)
{
SimSet* childSet = dynamic_cast<SimSet*>(*i);
if (childSet)
{
SimObject* found = childSet->findObjectByInternalName(internalName, searchChildren);
if (found) return found;
}
}
}
return NULL;
}