本文整理汇总了C++中ogre::ResourcePtr::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ ResourcePtr::getName方法的具体用法?C++ ResourcePtr::getName怎么用?C++ ResourcePtr::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::ResourcePtr
的用法示例。
在下文中一共展示了ResourcePtr::getName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: File
//.........这里部分代码省略.........
hlmsJson.loadMaterials(fname, jsonChar);
}
catch (Ogre::Exception e)
{
Ogre::LogManager::getSingleton().logMessage("MainWindow::doOpenDatablockMenuAction(); Could not load the materials\n");
}
file.close();
mHlmsName = jsonFileName;
// Get the (list of) datablocks and assign the first one to the current 'item' to be rendered
getAndSetFirstDatablock();
}
}
//****************************************************************************/
void MainWindow::destroyAllDatablocks(void)
{
// Get the datablock from the item and remove it
mOgreManager->getOgreWidget(OGRE_WIDGET_RENDERWINDOW)->setDefaultDatablockItem();
Ogre::HlmsManager* hlmsManager = mOgreManager->getOgreRoot()->getHlmsManager();
Ogre::HlmsPbs* hlmsPbs = static_cast<Ogre::HlmsPbs*>( hlmsManager->getHlms(Ogre::HLMS_PBS));
Ogre::HlmsUnlit* hlmsUnlit = static_cast<Ogre::HlmsUnlit*>( hlmsManager->getHlms(Ogre::HLMS_UNLIT));
// Iterate through all pbs datablocks and remove them
Ogre::Hlms::HlmsDatablockMap::const_iterator itorPbs = hlmsPbs->getDatablockMap().begin();
Ogre::Hlms::HlmsDatablockMap::const_iterator endPbs = hlmsPbs->getDatablockMap().end();
Ogre::HlmsPbsDatablock* pbsDatablock;
while( itorPbs != endPbs)
{
pbsDatablock = static_cast<Ogre::HlmsPbsDatablock*>(itorPbs->second.datablock);
if (pbsDatablock != hlmsPbs->getDefaultDatablock() &&
pbsDatablock != hlmsUnlit->getDefaultDatablock())
{
hlmsPbs->destroyDatablock(pbsDatablock->getName());
itorPbs = hlmsPbs->getDatablockMap().begin(); // Start from the beginning again
}
else
++itorPbs;
}
// Iterate through all unlit datablocks and remove them
Ogre::Hlms::HlmsDatablockMap::const_iterator itorUnlit = hlmsUnlit->getDatablockMap().begin();
Ogre::Hlms::HlmsDatablockMap::const_iterator endUnlit = hlmsUnlit->getDatablockMap().end();
Ogre::HlmsUnlitDatablock* unlitDatablock;
while( itorUnlit != endUnlit)
{
unlitDatablock = static_cast<Ogre::HlmsUnlitDatablock*>(itorUnlit->second.datablock);
if (unlitDatablock != hlmsPbs->getDefaultDatablock() &&
unlitDatablock != hlmsUnlit->getDefaultDatablock())
{
hlmsUnlit->destroyDatablock(unlitDatablock->getName());
itorUnlit = hlmsUnlit->getDatablockMap().begin(); // Start from the beginning again
}
else
++itorUnlit;
}
}
//****************************************************************************/
void MainWindow::getAndSetFirstDatablock(void)
{
// Get the name/fullname from the current item in the renderwindow
Ogre::Item* item = mOgreManager->getOgreWidget(OGRE_WIDGET_RENDERWINDOW)->getItem();
Ogre::HlmsDatablock* oldDatablock = item->getSubItem(0)->getDatablock();
Ogre::String oldDatablockName = *oldDatablock->getFullName();
Ogre::IdString oldDatablockId = oldDatablock->getName();
示例2: resourceLoaded
void Audio::resourceLoaded( Ogre::ResourcePtr pResource )
{
if( mAudioSource )
{
TransitionBase<cAudio::IAudioSource, Audio>::stop( mInstanceNumber );
mAudioSource->stop();
GlobalsBase::mAudio->getAudioManager()->release( mAudioSource );
}
mAudioSource = GlobalsBase::mAudio->getAudioManager()->create(
Component::getGUIDString().c_str(), pResource->getName().c_str() );
if( !mAudioSource )
{
CLOGE << "Could not load audio file.";
mTransformSignal.disconnect();
}
else
{
TransitionBase<cAudio::IAudioSource, Audio>::setUpdateSignal( *GlobalsBase::mFrameSignal );
TransitionBase<cAudio::IAudioSource, Audio>::setInstanceNumberFunction(
&Audio::getInstanceNumber );
PropertySynchronization::processQueuedConstruction();
PropertySynchronization::processQueue();
// TODO: Store and load properties when reloading the audio file so all the properties from
// previous audio component also get set onto the new audio component.
mAudioSource->setPosition( toVector3<cAudio::cVector3>(
Component::getObject()._getDerivedPosition() ) );
if( mAutoPlay )
mAudioSource->play();
if( mTransformSignal.empty() )
mTransformSignal = Component::getObject().connectTransformChange( sigc::mem_fun( this,
&Audio::transformChange ) );
}
}
示例3: registerCompositors
//-----------------------------------------------------------------------------------
void CompositorDemo_FrameListener::registerCompositors(void)
{
Ogre::Viewport *vp = mMain->getRenderWindow()->getViewport(0);
mCompositorSelectorViewManager = new ItemSelectorViewManager("CompositorSelectorWin");
// tell view manager to notify us when an item changes selection state
mCompositorSelectorViewManager->setItemSelectorController(this);
//iterate through Compositor Managers resources and add name keys ast Item selectors to Compositor selector view manager
Ogre::CompositorManager::ResourceMapIterator resourceIterator =
Ogre::CompositorManager::getSingleton().getResourceIterator();
// add all compositor resources to the view container
while (resourceIterator.hasMoreElements())
{
Ogre::ResourcePtr resource = resourceIterator.getNext();
const Ogre::String& compositorName = resource->getName();
// Don't add base Ogre/Scene compositor to view
if (compositorName == "Ogre/Scene")
continue;
// Don't add the deferred shading compositors, thats a different demo.
if (Ogre::StringUtil::startsWith(compositorName, "DeferredShading", false))
continue;
mCompositorSelectorViewManager->addItemSelector(compositorName);
int addPosition = -1;
if (compositorName == "HDR")
{
// HDR must be first in the chain
addPosition = 0;
}
try
{
Ogre::CompositorInstance *instance = Ogre::CompositorManager::getSingleton().addCompositor(vp, compositorName, addPosition);
Ogre::CompositorManager::getSingleton().setCompositorEnabled(vp, compositorName, false);
} catch (...) {
}
}
}
示例4: registerCompositors
//-----------------------------------------------------------------------------------
void Sample_Compositor::registerCompositors(void)
{
Ogre::Viewport *vp = mViewport;
//iterate through Compositor Managers resources and add name keys to menu
Ogre::CompositorManager::ResourceMapIterator resourceIterator =
Ogre::CompositorManager::getSingleton().getResourceIterator();
// add all compositor resources to the view container
while (resourceIterator.hasMoreElements())
{
Ogre::ResourcePtr resource = resourceIterator.getNext();
const Ogre::String& compositorName = resource->getName();
// Don't add base Ogre/Scene compositor to view
if (compositorName == "Ogre/Scene")
continue;
// Don't add the deferred shading compositors, thats a different demo.
if (Ogre::StringUtil::startsWith(compositorName, "DeferredShading", false))
continue;
mCompositorNames.push_back(compositorName);
int addPosition = -1;
if (compositorName == "HDR")
{
// HDR must be first in the chain
addPosition = 0;
}
try
{
Ogre::CompositorManager::getSingleton().addCompositor(vp, compositorName, addPosition);
Ogre::CompositorManager::getSingleton().setCompositorEnabled(vp, compositorName, false);
} catch (...) {
}
}
mNumCompositorPages = (mCompositorNames.size() / COMPOSITORS_PER_PAGE) +
((mCompositorNames.size() % COMPOSITORS_PER_PAGE == 0) ? 0 : 1);
}
示例5: diagnose
void OgreInfo::diagnose(std::ostream& outputStream)
{
Ogre::SceneManagerEnumerator::SceneManagerIterator sceneManagerI = Ogre::Root::getSingleton().getSceneManagerIterator();
while (sceneManagerI.hasMoreElements()) {
Ogre::SceneManager* sceneManager = sceneManagerI.getNext();
outputStream << "Scenemanager(" << sceneManager->getTypeName() << ") " << sceneManager->getName() << std::endl;
outputStream << " Number of scene nodes: " << countNodes(sceneManager->getRootSceneNode()) << std::endl;
outputStream << " Movable objects:" << std::endl;
unsigned int movableObjectCounter = 0;
Ogre::Root::MovableObjectFactoryIterator movableObjectFactoryI = Ogre::Root::getSingleton().getMovableObjectFactoryIterator();
while (movableObjectFactoryI.hasMoreElements()) {
Ogre::MovableObjectFactory* factory = movableObjectFactoryI.getNext();
std::string type(factory->getType());
{
Ogre::SceneManager::MovableObjectIterator I = sceneManager->getMovableObjectIterator(type);
while (I.hasMoreElements()) {
movableObjectCounter++;
Ogre::MovableObject* movable = I.getNext();
if (movable->getMovableType() == "Light") {
Ogre::Light* light = static_cast<Ogre::Light*> (movable);
outputStream << " * Light " << light->getName() << "(" << (light->isInScene() ? "in scene" : "not in scene") << ")" << std::endl;
outputStream << " Pos: " << light->getDerivedPosition() << std::endl;
outputStream << " Direction: " << light->getDerivedDirection() << std::endl;
} else {
std::stringstream ssPosAndOrientation;
if (movable->getParentSceneNode() && movable->isInScene()) {
ssPosAndOrientation << " pos: " << movable->getParentSceneNode()->getPosition() << " orientation: " << movable->getParentSceneNode()->getOrientation();
}
outputStream << " * " << type << " " << movable->getName() << "(" << (movable->isInScene() ? "in scene" : "not in scene") << ")" << ssPosAndOrientation.str() << std::endl;
// outputStream << " Pos: " << light->getDerivedPosition() << std::endl;
// outputStream << " Direction: " << light->getDerivedDirection() << std::endl;
}
}
}
}
outputStream << " Number of movable objects: " << movableObjectCounter << std::endl;
outputStream << " Cameras:" << std::endl;
{
Ogre::SceneManager::CameraIterator I = sceneManager->getCameraIterator();
while (I.hasMoreElements()) {
Ogre::Camera* camera = I.getNext();
outputStream << " Camera " << camera->getName() << "(" << (camera->isInScene() ? "in scene" : "not in scene") << ")" << std::endl;
outputStream << " Pos: " << camera->getDerivedPosition() << std::endl;
outputStream << " Direction: " << camera->getDerivedDirection() << std::endl;
outputStream << " Clip distances: " << camera->getNearClipDistance() << " - " << camera->getFarClipDistance() << std::endl;
}
}
}
size_t resourceMemoryUsage = 0;
outputStream << "Resource Managers:" << std::endl;
Ogre::ResourceGroupManager::ResourceManagerIterator I = Ogre::ResourceGroupManager::getSingleton().getResourceManagerIterator();
while (I.hasMoreElements()) {
std::string name = I.peekNextKey();
Ogre::ResourceManager* manager = I.getNext();
outputStream << " Resource Manager: " << name << std::endl;
if (manager->getMemoryBudget() == std::numeric_limits<size_t>::max()) {
outputStream << " Memory budget: not set" << std::endl;
} else {
outputStream << " Memory budget: " << manager->getMemoryBudget() << " bytes" << std::endl;
}
outputStream << " Memory usage: " << manager->getMemoryUsage() << " bytes" << std::endl;
resourceMemoryUsage += manager->getMemoryUsage();
Ogre::ResourceManager::ResourceMapIterator resourceI = manager->getResourceIterator();
if (resourceI.hasMoreElements()) {
outputStream << " Resources: " << std::endl;
int resourceCount = 0;
int loadedResourceCount = 0;
while (resourceI.hasMoreElements()) {
Ogre::ResourcePtr resource = resourceI.getNext();
if (resource->isLoaded()) {
std::string reloadable = resource->isReloadable() ? " reloadable" : "";
outputStream << " " << resource->getName() << " ( " << resource->getSize() << " bytes)" << reloadable;
Ogre::Texture* texture = dynamic_cast<Ogre::Texture*>(resource.get());
if (texture) {
outputStream << texture->getWidth() << "x" << texture->getHeight() << " ";
}
outputStream << std::endl;
loadedResourceCount++;
}
resourceCount++;
}
outputStream << " Total number of resources: " << resourceCount << std::endl;
outputStream << " Number of loaded resources: " << loadedResourceCount << std::endl;
}
}
outputStream << "Total memory usage for all resource manager: " << resourceMemoryUsage << " bytes" << std::endl;
outputStream << std::flush;
}