本文整理汇总了C++中ogre::ResourcePtr::isNull方法的典型用法代码示例。如果您正苦于以下问题:C++ ResourcePtr::isNull方法的具体用法?C++ ResourcePtr::isNull怎么用?C++ ResourcePtr::isNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::ResourcePtr
的用法示例。
在下文中一共展示了ResourcePtr::isNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadResource
Ogre::ResourcePtr ResourceManager::loadResource( const ResourceInfo& rResource,
const ResourceCallback& rCallbackSlot )
{
Ogre::ResourcePtr resource = ResourceManager::getResource( rResource, true );
if( !resource.isNull() && resource->isLoaded() )
{
CLOGD << "Resource " << rResource << " already loaded.";
// If the resource is already loaded, callback immediately.
rCallbackSlot( resource );
}
else if( !resource.isNull() && mHandleTickets.count( std::make_pair(
resource->getCreator()->getResourceType(), resource->getHandle() ) ) )
{
// If the resource is loading, add a callback.
HandleTickets::iterator i = mHandleTickets.find( std::make_pair(
resource->getCreator()->getResourceType(), resource->getHandle() ) );
if( i != mHandleTickets.end() )
{
mTicketCallbacks.insert( TicketCallbacks::value_type( i->second, rCallbackSlot ) );
CLOGD << "Resource " << rResource << " is loading, ticket callback: " << i->second;
}
else
{
DIVERSIA_EXCEPT( Exception::ERR_INTERNAL_ERROR,
"Could not find ticket for resource that is loading in the background.",
"ResourceManager::loadResource" );
}
}
else if( !resource.isNull() )
{
// Load the resource in the background and register the callback.
resource = ResourceManager::getResource( rResource, true );
Ogre::BackgroundProcessTicket ticket =
mRBQ.load( ResourceManager::getResourceManagerName( rResource.mType ),
rResource.mFile.string(), mGroup, false, 0, 0, this );
mTicketCallbacks.insert( TicketCallbacks::value_type( ticket, rCallbackSlot ) );
mHandleTickets.insert( std::make_pair( std::make_pair(
resource->getCreator()->getResourceType(), resource->getHandle() ), ticket ) );
mTicketResources.insert( std::make_pair( ticket, resource ) );
CLOGD << "Resource " << rResource << " will be loaded, ticket: " << ticket;
}
else
{
DIVERSIA_EXCEPT( Exception::ERR_FILE_NOT_FOUND, "Cannot load resource " +
rResource.mFile.string() + ", file does not exist.",
"ResourceManager::loadResource" );
}
return resource;
}
示例2: UnloadResource
void UnloadResource(Ogre::ResourceManager* resMgr, const std::string& resourceName)
{
Ogre::ResourcePtr rPtr = resMgr->getResourceByName(resourceName);
if (rPtr.isNull())
{
StringUtil::StrStreamType msg;
msg << "Resource no longer exists: " << resourceName;
Ogre::LogManager::getSingleton().logMessage(msg.str());
return;
}
rPtr->unload();
if (rPtr->isLoaded())
{
StringUtil::StrStreamType msg;
msg << "Resource was not unloaded: " << resourceName;
Ogre::LogManager::getSingleton().logMessage(msg.str());
}
else
{
StringUtil::StrStreamType msg;
msg << "Resource was unloaded: " << resourceName;
Ogre::LogManager::getSingleton().logMessage(msg.str());
}
resMgr->remove(resourceName);
rPtr = resMgr->getResourceByName(resourceName);
if (rPtr.isNull())
{
StringUtil::StrStreamType msg;
msg << "Resource was removed: " << resourceName;
Ogre::LogManager::getSingleton().logMessage(msg.str());
}
else
{
StringUtil::StrStreamType msg;
msg << "Resource was not removed: " << resourceName;
Ogre::LogManager::getSingleton().logMessage(msg.str());
}
if (resMgr->resourceExists(resourceName))
{
StringUtil::StrStreamType msg;
msg << "Resource still exists: " << resourceName;
Ogre::LogManager::getSingleton().logMessage(msg.str());
}
else
{
StringUtil::StrStreamType msg;
msg << "Resource no longer exists: " << resourceName;
Ogre::LogManager::getSingleton().logMessage(msg.str());
}
}
示例3: runCommand
void GUIManager::runCommand(const std::string &command, const std::string &args)
{
if (command == ToggleInputMode.getCommand()) {
getInput().toggleInputMode();
} else if (command == ToggleGui.getCommand()) {
S_LOG_VERBOSE("Toggle Gui Initiated -- " << getInput().getInputMode());
if (mEnabled) {
S_LOG_INFO("Disabling GUI");
mEnabled = false;
getInput().removeAdapter(mCEGUIAdapter);
} else {
S_LOG_INFO("Enabling GUI");
mEnabled = true;
getInput().addAdapter(mCEGUIAdapter);
}
} else if (command == ReloadGui.getCommand()) {
Ogre::TextureManager* texMgr = Ogre::TextureManager::getSingletonPtr();
Ogre::ResourcePtr resource = texMgr->getByName("cegui/" + getDefaultScheme() + ".png");
if (!resource.isNull()) {
resource->reload();
}
}
}
示例4: tryLoadResource
Ogre::ResourcePtr
loadCorrelativeResource(const Ogre::String& resourceName, const Ogre::String& groupName,
const Ogre::String& baseResourceName, const Ogre::String& baseGroupName,
Ogre::ResourceManager& resourceManager)
{
Ogre::ResourcePtr res;
Ogre::String name, path;
Ogre::StringUtil::splitFilename(resourceName, name, path);
bool existsPath = !path.empty();
// First, load in correlatived group and path if resource name doesn't exists path
if (!existsPath)
{
Ogre::StringUtil::splitFilename(baseResourceName, name, path);
if (!path.empty())
{
name = path + resourceName;
res = tryLoadResource(resourceManager, name, baseGroupName);
if (!res.isNull())
return res;
}
}
// Second, load in correlatived group
res = tryLoadResource(resourceManager, resourceName, baseGroupName);
if (!res.isNull())
return res;
// Three, load in user given group
if (!groupName.empty())
{
res = tryLoadResource(resourceManager, resourceName, groupName);
if (!res.isNull())
return res;
}
// Four, load in global default group
if (groupName != DEFAULT_RESOURCE_GROUP_NAME)
{
res = tryLoadResource(resourceManager, resourceName, groupName);
if (!res.isNull())
return res;
}
return res;
}
示例5: load
void ManualBulletShapeLoader::load(const std::string &name,const std::string &group)
{
// Check if the resource already exists
Ogre::ResourcePtr ptr = BulletShapeManager::getSingleton().getByName(name, group);
if (!ptr.isNull())
return;
BulletShapeManager::getSingleton().create(name,group,true,this);
}
示例6: unloadResource
void ResourceManager::unloadResource(Ogre::ResourceManager* resMgr, const std::string& resourceName)
{
Ogre::ResourcePtr rPtr = resMgr->getByName(resourceName);
if (rPtr.isNull()) return
rPtr->unload();
if (rPtr->isLoaded())
LOG_META(FORMAT("The resource '%1%' wasn`t unloaded!", resourceName));
else
LOG_META(FORMAT("The resource '%1%' was unloaded!", resourceName));
resMgr->remove(resourceName);
rPtr = resMgr->getByName(resourceName);
if (!rPtr.isNull())
LOG_META(FORMAT("The resource '%1%' wasn`t removed!", resourceName));
else
LOG_META(FORMAT("The resource '%1%' was removed!", resourceName));
}
示例7: create
Ogre::ResourcePtr EntityRecipeManager::create(const Ogre::String& name, const Ogre::String& group, bool isManual, Ogre::ManualResourceLoader* loader, const Ogre::NameValuePairList* createParams)
{
Ogre::ResourcePtr ret = getByName(name);
if (ret.isNull()) {
return Ogre::ResourceManager::create(name, group, isManual, loader, createParams);
}
S_LOG_WARNING("EntityRecipe with name " << name << " already exists.");
return Ogre::ResourcePtr();
}
示例8: reloadResource
void ResourceManager::reloadResource(Ogre::ResourceManager* resMgr, const std::string& resourceName, const std::string& resourceGroup)
{
Ogre::ResourcePtr rPtr = resMgr->load(resourceName, resourceGroup);
if (rPtr.isNull()) LOG_META(FORMAT("The resource '%1%' no longer exists!", resourceName));
rPtr->reload();
if (rPtr->isLoaded())
LOG_META(FORMAT("The resource '%1%' wasn`t unloaded!", resourceName));
else
LOG_META(FORMAT("The resource '%1%' was unloaded!", resourceName));
}
示例9: loadResources
void ResourceManager::loadResources( const ResourceList& rResources,
const SimpleResourceCallback& rCallbackSlot )
{
// Convert to set to remove duplicates.
ResourceSet resources = ResourceInfo::toResourceSet( rResources );
if( resources.empty() )
{
// If there are no resources to be loaded, call the slot and return immediately.
rCallbackSlot();
return;
}
ResourceManager::ResourcesLoader* resourceLoader =
ResourceManager::ResourcesLoader::create( rCallbackSlot );
unsigned short loaded = 0;
for( ResourceSet::const_iterator i = resources.begin(); i != resources.end(); ++i )
{
// Add resources to resource loader.
Ogre::ResourcePtr resource = ResourceManager::getResource( *i, true );
if( resource.isNull() )
{
DIVERSIA_EXCEPT( Exception::ERR_FILE_NOT_FOUND, "Cannot load resource " +
(*i).mFile.string() + ", file does not exist.",
"ResourceManager::loadResource" );
}
if( resource->isLoaded() )
loaded++;
else
resourceLoader->addResource( resource );
}
// All resources are already loaded.
if( loaded == resources.size() )
{
rCallbackSlot();
delete resourceLoader;
return;
}
for( ResourceSet::const_iterator j = resources.begin(); j != resources.end(); ++j )
{
// Load all resources and callback to the resource loader. If all resources are loaded
// the rCallbackSlot will be called and the resource loader will be destroyed.
ResourceManager::loadResource( *j, sigc::mem_fun( resourceLoader,
&ResourceManager::ResourcesLoader::loadingComplete ) );
}
}
示例10: create
Ogre::ResourcePtr ModelDefinitionManager::create(const Ogre::String& name, const Ogre::String& group,
bool isManual, Ogre::ManualResourceLoader* loader,
const Ogre::NameValuePairList* createParams)
{
Ogre::ResourcePtr ret = getByName(name);
if (ret.isNull())
{
return Ogre::ResourceManager::create(name, group, isManual, loader, createParams);
}
//Report this. We count on this happening a lot (user media overriding shared media for example), so we will not consider it a failure.
S_LOG_INFO("ModelDefinition with name " << name << " already exists.");
return Ogre::ResourcePtr();
}
示例11: run
void run()
{
Meru::ResourceLoadingQueue *queue = &ResourceLoadingQueue::getSingleton();
Ogre::ResourcePtr skeletonPtr = Ogre::SkeletonManager::getSingleton().getByName(mName);
if (skeletonPtr.isNull() || !skeletonPtr->isLoaded()) {
SILOG(resource,insane, "Skeleton Load Task run(), waiting for " << mName << " To queue");
SILOG(resource,debug,"Queueing " << mName << " for OGRE load ");
queue->load(Ogre::SkeletonManager::getSingleton().getResourceType(), mName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, false, NULL, NULL, this);
}
else {
SILOG(resource,insane, "Skeleton Load Task run() AND complete, waited for " << mName << " To queue");
signalCompletion();
}
}
示例12: mainThreadUnload
/*
bool MeshUnloadTask::mainThreadUnload(String name)
{
Ogre::MeshManager::getSingleton().unload(name);
// operationCompleted(Ogre::BackgroundProcessTicket(), Ogre::BackgroundProcessResult());
return false;
}
*/
void MeshUnloadTask::doRun()
{
/*I REALLY wish this were true*/
// SequentialWorkQueue::getSingleton().queueWork(std::tr1::bind(&MeshUnloadTask::mainThreadUnload, this, mHash));
String hash = mHash; //CDNArchive::canonicalMhashName(mHash);
Ogre::MeshManager* meshManager = Ogre::MeshManager::getSingletonPtr();
meshManager->remove(hash);
Ogre::ResourcePtr meshResource = meshManager->getByName(hash);
assert(meshResource.isNull());
SharedResourcePtr resource = mResource.lock();
if (resource)
resource->unloaded(true, mEpoch);
}
示例13: getResource
Ogre::ResourcePtr ResourceManager::getResource( const ResourceInfo& rResource,
bool create /*= false*/ ) const
{
Ogre::ResourcePtr resource = mRGM._getResourceManager(
ResourceManager::getResourceManagerName( rResource.mType ) )->getByName(
rResource.mFile.string(), mGroup );
if( !create ) return resource;
if( resource.isNull() )
{
if( !mRGM.findResourceNames( mGroup, rResource.mFile.string() )->size() )
return resource;
resource = mRGM._getResourceManager( ResourceManager::getResourceManagerName(
rResource.mType ) )->create( rResource.mFile.string(), mGroup );
}
return resource;
}
示例14:
Ogre::MaterialPtr
IntersectGrid::_createIntersectGridMaterial(void)
{
String name = "IntersectGridMaterial";
Ogre::ResourcePtr res = Ogre::MaterialManager::getSingleton().getByName(name);
if (!res.isNull())
return res;
Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create(name, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
material->setLightingEnabled(false);
material->setSceneBlending(Ogre::SBF_SOURCE_ALPHA, Ogre::SBF_ONE_MINUS_SOURCE_ALPHA);
material->setDepthWriteEnabled(false);
// Use wireframe polygon mode
material->getTechnique(0)->getPass(0)->setPolygonMode(Ogre::PM_WIREFRAME);
return material;
}
示例15:
SoundTrackPtr::SoundTrackPtr(const Ogre::ResourcePtr &resourcePtr)
{
Log *errorLog = OGF::LogFactory::getSingletonPtr()->get(OGF::LOG_ERR);
if (resourcePtr.isNull()) {
return;
}
OGRE_LOCK_MUTEX(*resourcePtr.OGRE_AUTO_MUTEX_NAME)
OGRE_COPY_AUTO_SHARED_MUTEX(resourcePtr.OGRE_AUTO_MUTEX_NAME)
pRep = static_cast<SoundTrack *>(resourcePtr.getPointer());
pUseCount = resourcePtr.useCountPointer();
useFreeMethod = resourcePtr.freeMethod();
// Incremento del contador de referencias.
if (pUseCount)
++(*pUseCount);
}