本文整理汇总了C++中ogre::ResourcePtr类的典型用法代码示例。如果您正苦于以下问题:C++ ResourcePtr类的具体用法?C++ ResourcePtr怎么用?C++ ResourcePtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ResourcePtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GameState
IntroState::IntroState(Engine* p_engine) :
GameState(p_engine),
m_totalMilliseconds(std::time_t(2000)),
m_elapsedMilliseconds(0)
{
std::clog << "Entering intro state..." << std::endl;
// do one input state capture just to hide the mouse cursor
InputSystem* inputSystem = m_engine->getInputSystem();
inputSystem->capture();
// get the material by name
std::clog << "Loading fade overlay material..." << std::endl;
Ogre::ResourcePtr resptr = Ogre::MaterialManager::getSingleton().
getByName("Materials/FadeOverlay");
Ogre::Material* material = dynamic_cast<Ogre::Material*>(resptr.getPointer());
Ogre::Technique* tech = material->getTechnique(0);
Ogre::Pass* pass = tech->getPass(0);
m_textureUnitState = pass->getTextureUnitState(0);
// get the overlay
std::clog << "Loading fade overlay..." << std::endl;
m_fadeOverlay = Ogre::OverlayManager::getSingleton().getByName("Overlays/FadeOverlay");
m_alpha = 1.0;
m_fadeOverlay->show();
}
示例2: loadCaelumSystemFromScript
void CaelumPlugin::loadCaelumSystemFromScript(CaelumSystem* sys, const Ogre::String& objectName, const Ogre::String& groupName)
{
assert(sys);
assert(this->isInstalled () && "Must install CaelumPlugin before loading scripts");
// Fetch raw resource ptr. Attempt to support explicit resource groups currently in Ogre trunk.
#if OGRE_VERSION >= 0x00010700
Ogre::ResourcePtr res = getPropScriptResourceManager()->getByName(objectName, groupName);
#else
Ogre::ResourcePtr res = getPropScriptResourceManager ()->getByName (objectName);
#endif
// Check a PropScriptResource was found.
PropScriptResource* propRes = static_cast<PropScriptResource*>(res.get());
if (!propRes) {
OGRE_EXCEPT(Ogre::Exception::ERR_ITEM_NOT_FOUND, "Could not find caelum_sky_system " + objectName, "CaelumPlugin::loadCaelumSystemFromScript");
}
// Fetch the resource stream. Look in the actual group of the resource!
const Ogre::String& scriptFileName = propRes->getOrigin();
const Ogre::String& scriptFileGroup = propRes->getGroup();
Ogre::DataStreamPtr streamPtr = Ogre::ResourceGroupManager::getSingleton().openResource(scriptFileName, scriptFileGroup, false);
// Feed it into the compiler.
this->getScriptTranslatorManager()->getCaelumSystemTranslator()->setTranslationTarget(sys, objectName);
Ogre::ScriptCompilerManager::getSingleton().parseScript(streamPtr, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
bool found = this->getScriptTranslatorManager()->getCaelumSystemTranslator()->foundTranslationTarget();
// This shouldn't normally happen.
if (!found) {
OGRE_EXCEPT(Ogre::Exception::ERR_ITEM_NOT_FOUND, "Could not find caelum_sky_system " + objectName + " in file " + scriptFileName + " on reparsing. "
"Perhaps information in PropScriptResourceManager is out of date?", "CaelumPlugin::loadCaelumSystemFromScript");
}
this->getScriptTranslatorManager()->getCaelumSystemTranslator()->clearTranslationTarget();
}
示例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: 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);
}
示例5: 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();
}
示例6: mCompletedSlot
void ResourceManager::ResourcesLoader::loadingComplete( Ogre::ResourcePtr pResource )
{
mResources.erase( std::make_pair( pResource->getCreator()->getResourceType(),
pResource->getHandle() ) );
if( !mResources.size() )
{
mCompletedSlot();
delete this;
}
}
示例7: name
Ogre::ResourcePtr
FLevelFileSerializer::createResource( FLevelFile *pDest, const String &extension )
{
assert( pDest );
Ogre::ResourceManager &mgr( ResourceManagerType::getSingleton() );
String name( getBaseName( pDest ) + extension );
Ogre::ResourcePtr resource = mgr.createResource( name, pDest->getGroup(), true );
resource->_notifyOrigin( pDest->getName() );
return resource;
}
示例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: 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());
}
}
示例10: 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 ) );
}
}
示例11: 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();
}
示例12: loadLod
void LodManager::loadLod(Ogre::MeshPtr mesh)
{
assert(mesh->getNumLodLevels() == 1);
std::string lodDefName = convertMeshNameToLodName(mesh->getName());
try {
Ogre::ResourcePtr resource = LodDefinitionManager::getSingleton().load(lodDefName, "General");
const LodDefinition& def = *static_cast<const LodDefinition*>(resource.get());
loadLod(mesh, def);
} catch (Ogre::FileNotFoundException ex) {
// Exception is thrown if a mesh hasn't got a loddef.
// By default, use the automatic mesh lod management system.
loadAutomaticLod(mesh);
}
}
示例13: 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();
}
}
示例14: File
//.........这里部分代码省略.........
// It is a PBS; Note, that there is also a default (so always 1)
Ogre::Hlms::HlmsDatablockMap::const_iterator itor = hlmsPbs->getDatablockMap().begin();
Ogre::Hlms::HlmsDatablockMap::const_iterator end = hlmsPbs->getDatablockMap().end();
Ogre::HlmsPbsDatablock* newDatablock;
Ogre::String newDatablockName;
while( itor != end )
{
newDatablock = static_cast<Ogre::HlmsPbsDatablock*>(itor->second.datablock);
if (newDatablock != hlmsPbs->getDefaultDatablock() && newDatablock != hlmsUnlit->getDefaultDatablock())
{
// Get the first datablock
newDatablockName = *newDatablock->getFullName();
if (oldDatablockName != newDatablockName)
{
// Assign the datablock to the item (and destroy the items' old datablock, if still available)
item->setDatablock(newDatablock);
if (oldDatablock != hlmsPbs->getDefaultDatablock() && oldDatablock != hlmsUnlit->getDefaultDatablock())
{
if (oldDatablock->getCreator()->getType() == Ogre::HLMS_PBS)
hlmsPbs->destroyDatablock(oldDatablockId);
else if (hlmsUnlit && oldDatablock->getCreator()->getType() == Ogre::HLMS_UNLIT)
hlmsUnlit->destroyDatablock(oldDatablockId);
}
// Create the node structure
QString s = newDatablockName.c_str();
mNodeEditorDockWidget->createPbsNodeStructure(s);
mPropertiesDockWidget->setTextureTypePropertyVisible(true);
mPropertiesDockWidget->setMapWeightPropertyVisible(true);
break;
}
}
++itor;
}
return;
}
}
if (hlmsUnlit)
{
int size = hlmsUnlit->getDatablockMap().size();
//QMessageBox::information(0, QString("info"), QVariant(size).toString());
if (size > 1)
{
// It is an Unlit; Note, that there is also a default (so always 1)
Ogre::Hlms::HlmsDatablockMap::const_iterator itor = hlmsUnlit->getDatablockMap().begin();
Ogre::Hlms::HlmsDatablockMap::const_iterator end = hlmsUnlit->getDatablockMap().end();
Ogre::HlmsUnlitDatablock* newDatablock;
Ogre::String newDatablockName;
while( itor != end )
{
newDatablock = static_cast<Ogre::HlmsUnlitDatablock*>(itor->second.datablock);
if (newDatablock != hlmsPbs->getDefaultDatablock() && newDatablock != hlmsUnlit->getDefaultDatablock())
{
// Get the first datablock
newDatablockName = *newDatablock->getFullName();
if (oldDatablockName != newDatablockName)
{
// Assign the datablock to the item (and destroy the items' old datablock, if still available)
item->setDatablock(newDatablock);
if (oldDatablock != hlmsPbs->getDefaultDatablock() && oldDatablock != hlmsUnlit->getDefaultDatablock())
{
if (oldDatablock->getCreator()->getType() == Ogre::HLMS_UNLIT)
hlmsUnlit->destroyDatablock(oldDatablockId);
else if (hlmsPbs && oldDatablock->getCreator()->getType() == Ogre::HLMS_PBS)
hlmsPbs->destroyDatablock(oldDatablockId);
}
// Create the node structure
QString s = newDatablockName.c_str();
mNodeEditorDockWidget->createUnlitNodeStructure(s);
mPropertiesDockWidget->setTextureTypePropertyVisible(false);
mPropertiesDockWidget->setMapWeightPropertyVisible(false);
break;
}
}
++itor;
}
return;
}
}
}
//****************************************************************************/
void MainWindow::getListOfResources(void)
{
Ogre::ResourceGroupManager::ResourceManagerIterator it =
Ogre::ResourceGroupManager::getSingletonPtr()->getResourceManagerIterator();
while (it.hasMoreElements())
{
Ogre::ResourceManager* man = it.getNext();
Ogre::LogManager::getSingleton().logMessage("Resource Type = " + man->getResourceType());
Ogre::ResourceManager::ResourceMapIterator mapit = man->getResourceIterator() ;
while (mapit.hasMoreElements())
{
Ogre::ResourcePtr ptr = mapit.getNext();
Ogre::LogManager::getSingleton().logMessage("Resource Name = " + ptr->getName());
}
}
}
示例15: 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);
}