看下述代码,可以理清四者的关系:
ResourceGroupManager
ResourceGroup
ResourceLocation、Archive。 这2者应该是并行的关系
void ResourceGroupManager::addResourceLocation(const String& name,
const String& locType, const String& resGroup, bool recursive)
{
ResourceGroup* grp = getResourceGroup(resGroup);
if (!grp)
{
createResourceGroup(resGroup);
grp = getResourceGroup(resGroup);
}
OGRE_LOCK_MUTEX(grp->OGRE_AUTO_MUTEX_NAME) // lock group mutex
// Get archive
Archive* pArch = ArchiveManager::getSingleton().load( name, locType );
// Add to location list
ResourceLocation* loc = OGRE_NEW_T(ResourceLocation, MEMCATEGORY_RESOURCE);
loc->archive = pArch;
loc->recursive = recursive;
grp->locationList.push_back(loc);
// Index resources
StringVectorPtr vec = pArch->find("*", recursive);
for( StringVector::iterator it = vec->begin(); it != vec->end(); ++it )
grp->addToIndex(*it, pArch);
StringUtil::StrStreamType msg;
msg << "Added resource location '" << name << "' of type '" << locType
<< "' to resource group '" << resGroup << "'";
if (recursive)
msg << " with recursive option";
LogManager::getSingleton().logMessage(msg.str());
}