本文整理汇总了C++中ogre::ResourcePtr::get方法的典型用法代码示例。如果您正苦于以下问题:C++ ResourcePtr::get方法的具体用法?C++ ResourcePtr::get怎么用?C++ ResourcePtr::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::ResourcePtr
的用法示例。
在下文中一共展示了ResourcePtr::get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2: 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);
}
}
示例3: OpenOgreTexture
void TexturePreviewEditor::OpenOgreTexture(const QString& name)
{
if (name.contains(".dds"))
{
LogWarning("currently cannot show .dds files. ");
// Set black background image that will be replaced once the real image has been received.
QImage emptyImage = QImage(QSize(256, 256), QImage::Format_ARGB32);
emptyImage.fill(qRgba(0,0,0,0));
if ( imageLabel_ != 0)
imageLabel_->setPixmap(QPixmap::fromImage(emptyImage));
return;
}
Ogre::ResourcePtr res = Ogre::TextureManager::getSingleton().getByName(name.toStdString().c_str());
Ogre::Texture* tex = static_cast<Ogre::Texture* >(res.get());
if (!tex)
{
LogWarning("Failed to open Ogre texture " + name.toStdString() + " .");
return;
}
int width = tex->getWidth();
int height = tex->getHeight();
Ogre::Box bounds(0, 0, width, height);
Ogre::uchar* pixelData = new Ogre::uchar[width * height * 4];
Ogre::PixelBox pixels(bounds, Ogre::PF_A8R8G8B8, pixelData);
tex->getBuffer()->blitToMemory(pixels);
// Create image of texture, and show it into label.
u8* p = static_cast<u8 *>(pixels.data);
int widthPixels = pixels.getWidth();
int heightPixels= pixels.getHeight();
QImage img = ConvertToQImage(p, widthPixels, heightPixels, 4);
if(!img.isNull() && imageLabel_ != 0)
{
imageLabel_->setPixmap(QPixmap::fromImage(img));
imageLabel_->show();
}
delete[] pixelData;
}
示例4: 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;
}
示例5: run
void run(){
boost::unique_lock<boost::mutex> lock(OgreFramework::getSingletonPtr()->mutex);
OgreFramework::getSingletonPtr()->m_pLog->logMessage("Start main loop...");
//float fps_limit = 70.0;
double timeSinceLastFrame = 0;
double startTime = 0;
OgreFramework::getSingletonPtr()->m_pRenderWnd->resetStatistics();
lock.unlock();
while(!m_bShutdown && !OgreFramework::getSingletonPtr()->isOgreToBeShutDown())
{
boost::unique_lock<boost::mutex> lock(OgreFramework::getSingletonPtr()->mutex);
if(OgreFramework::getSingletonPtr()->m_pRenderWnd->isClosed())m_bShutdown = true;
Ogre::WindowEventUtilities::messagePump();
if(OgreFramework::getSingletonPtr()->m_pRenderWnd->isActive())
{
startTime = OgreFramework::getSingletonPtr()->m_pTimer->getMillisecondsCPU();
OgreFramework::getSingletonPtr()->m_pKeyboard->capture();
OgreFramework::getSingletonPtr()->m_pMouse->capture();
OgreFramework::getSingletonPtr()->updateCaption();
//update mouse selection to shaders
Ogre::ResourcePtr r = Ogre::MaterialManager::getSingletonPtr()->getByName("MultiTextureEditor");
if(!r.isNull()){
float mx=OgreFramework::getSingletonPtr()->cursor_x+OgreFramework::getSingletonPtr()->m_pCamera->getPosition().x;
float my=OgreFramework::getSingletonPtr()->cursor_y+OgreFramework::getSingletonPtr()->m_pCamera->getPosition().z;
//float my=OgreFramework::getSingletonPtr()->cursor_y+sqrt(OgreFramework::getSingletonPtr()->m_pCamera->getPosition().z);
/*//std::cout<<((Ogre::Material*)r.get())->getTechnique(0)->getPass(0)->getVertexProgramParameters()->getSharedParameters().size()<<"\n";//->setNamedConstant("pointer", Ogre::Vector3(OgreFramework::getSingletonPtr()->cursor_x,OgreFramework::getSingletonPtr()->cursor_y,OgreFramework::getSingletonPtr()->cursor_r));
float mx=(OgreFramework::getSingletonPtr()->cursor_x-OgreFramework::getSingletonPtr()->cursror_e_w/2.0)/OgreFramework::getSingletonPtr()->cursror_e_w;
float my=(-OgreFramework::getSingletonPtr()->cursor_y+OgreFramework::getSingletonPtr()->cursror_e_h/2.0)/OgreFramework::getSingletonPtr()->cursror_e_h;
Ogre::Ray ray=OgreFramework::getSingletonPtr()->m_pCamera->getCameraToViewportRay(mx,my);
Ogre::Vector3 cam = OgreFramework::getSingletonPtr()->m_pCamera->getDirection();
float factor = ray.getDirection().dotProduct(cam) / (cam.length() * ray.getDirection().length());
Ogre::Vector3 point = ray.getPoint(OgreFramework::getSingletonPtr()->m_pCamera->getPosition().y*factor);
*/
switch(OgreFramework::getSingletonPtr()->mode){
case 0:
((Ogre::Material*)r.get())->getTechnique(0)->getPass(0)->getVertexProgramParameters()->setNamedConstant("pointer", Ogre::Vector4(mx,my,OgreFramework::getSingletonPtr()->cursor_r,OgreFramework::getSingletonPtr()->cursor_rb));
break;
case 1:
((Ogre::Material*)r.get())->getTechnique(0)->getPass(0)->getVertexProgramParameters()->setNamedConstant("pointer", Ogre::Vector4(mx,my,OgreFramework::getSingletonPtr()->cursor_r,0));
break;
case 2:
((Ogre::Material*)r.get())->getTechnique(0)->getPass(0)->getVertexProgramParameters()->setNamedConstant("pointer", Ogre::Vector4(mx,my,2,0));
break;
default:
((Ogre::Material*)r.get())->getTechnique(0)->getPass(0)->getVertexProgramParameters()->setNamedConstant("pointer", Ogre::Vector4(-20,-20,0,0));
}
}
else{
//TODO error!
}
OgreFramework::getSingletonPtr()->updateOgre(timeSinceLastFrame);
OgreFramework::getSingletonPtr()->m_pRoot->renderOneFrame();
/* while(OgreFramework::getSingletonPtr()->chunksToAdd.size()>0){//adding chunks
ChunkAdding* ch = OgreFramework::getSingletonPtr()->chunksToAdd.front();
OgreFramework::getSingletonPtr()->chunksToAdd.pop();
Ogre::ManualObject* ogreMesh = OgreFramework::getSingletonPtr()->m_pSceneMgr->createManualObject(std::string("Chunk")+(char)ch->x+(char)ch->y+(char)ch->z);
ogreMesh->setDynamic(true);
ogreMesh->setCastShadows(true);
ogreMesh->begin("MultiTexture", Ogre::RenderOperation::OT_TRIANGLE_LIST);
{
for(int i=0;i<ch->size;++i){
ogreMesh->position(ch->pos[i]);
ogreMesh->normal(ch->normal[i]);
ogreMesh->colour(ch->color[i]);
}
}
ogreMesh->end();
Ogre::SceneNode* ogreNode = OgreFramework::getSingletonPtr()->m_pSceneMgr->getRootSceneNode()->createChildSceneNode(std::string("NChunk")+(char)ch->x+(char)ch->y+(char)ch->z, Ogre::Vector3(0, 0, 0));
ogreNode->setVisible(true);
ogreNode->attachObject(ogreMesh);
ogreNode->setPosition(ch->x*CHUNK_SIZE,ch->z*(CHUNK_SIZE),ch->y*CHUNK_SIZE);
delete ch;
}*/
//update chunks
/*Pos* pos=NULL;
unsigned int chunksUpdated=0;
float cx=OgreFramework::getSingletonPtr()->m_pCamera->getPosition().x,cy=OgreFramework::getSingletonPtr()->m_pCamera->getPosition().z;
while(chunksUpdated<8 and (pos=OgreFramework::getSingletonPtr()->map->getNextUpdatedChunk())!=NULL){
int xx=pos->x*128-cx;
int yy=pos->y*128-cy;
if(xx*xx+yy*yy<1280){
std::cout<<"Updating chunk\n";
chunksUpdated++;
try{
OgreFramework::getSingletonPtr()->m_pSceneMgr->getSceneNode(std::string("NChunk")+(char)pos->x+(char)pos->y)->removeAndDestroyAllChildren();
}
catch(...){}
OgreFramework::getSingletonPtr()->map->getChunk(pos->x,pos->y);
delete pos;
}
//.........这里部分代码省略.........