本文整理汇总了C++中ogre::TexturePtr::setNull方法的典型用法代码示例。如果您正苦于以下问题:C++ TexturePtr::setNull方法的具体用法?C++ TexturePtr::setNull怎么用?C++ TexturePtr::setNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::TexturePtr
的用法示例。
在下文中一共展示了TexturePtr::setNull方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createRttCamera
void OgreWidget::createRttCamera(Ogre::Camera** camera, Ogre::RenderTarget** renderTarget, Ogre::SceneNode ** sceneNode, const QString name, const QSize size)
{
Ogre::TexturePtr tex = Ogre::TextureManager::getSingleton().createManual(
QString(name+"_texture").toStdString(),
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME/*"general"*/,
Ogre::TEX_TYPE_2D,
size.width(),
size.height(),
32,
0,
Ogre::PF_R8G8B8A8,
Ogre::TU_RENDERTARGET);
*renderTarget = tex->getBuffer()->getRenderTarget();
tex.setNull();
*camera = mSceneManager->createCamera(QString(name+"_camera").toStdString());
Ogre::Viewport* viewPort = (*renderTarget)->addViewport(*camera);
viewPort->setBackgroundColour(Ogre::ColourValue::Red);
// From: http://www.ogre3d.org/docs/api/html/classOgre_1_1Camera.html:
// Note that a Camera can be attached to a SceneNode, using the method SceneNode::attachObject.
// If this is done the Camera will combine it's own position/orientation settings with it's parent
// SceneNode. This is useful for implementing more complex Camera / object relationships i.e.
// having a camera attached to a world object.
//
// Cameras are attached to the camera-scenenode, which is attached to the vehicle-scenenode
Ogre::Entity *cameraEntity = mSceneManager->createEntity(QString(name + "_entity").toStdString(), "camera.mesh");
*sceneNode = mSceneManager->getSceneNode("vehicleNode")->createChildSceneNode(QString(name + "_node").toStdString());
(*sceneNode)->attachObject(cameraEntity);
(*sceneNode)->attachObject(*camera);
}
示例2: getIcon
Icon* IconManager::getIcon(int, EmberEntity* entity)
{
std::string key = "entity_" + entity->getId();
if (mIconStore.hasIcon(key)) {
return mIconStore.getIcon(key);
} else {
IconActionCreator actionCreator(*entity);
std::unique_ptr<EntityMapping::EntityMapping> modelMapping(Mapping::EmberEntityMappingManager::getSingleton().getManager().createMapping(*entity, actionCreator, &EmberOgre::getSingleton().getWorld()->getView()));
std::string modelName;
if (modelMapping.get()) {
modelMapping->initialize();
modelName = actionCreator.getModelName();
}
//if there's no model defined for this use the placeholder model
if (modelName == "") {
modelName = "placeholder";
}
Ogre::ResourcePtr modelDefPtr = Model::ModelDefinitionManager::getSingleton().getByName(modelName);
if (!modelDefPtr.isNull()) {
Model::ModelDefinition* modelDef = static_cast<Model::ModelDefinition*> (modelDefPtr.get());
const std::string& iconPath(modelDef->getIconPath());
if (iconPath != "") {
Ogre::TexturePtr texPtr;
try {
if (Ogre::TextureManager::getSingleton().resourceExists(iconPath)) {
texPtr = static_cast<Ogre::TexturePtr> (Ogre::TextureManager::getSingleton().getByName(iconPath));
//try to load it to make sure that's it a working image
texPtr->load();
}
if (texPtr.isNull()) {
texPtr = Ogre::TextureManager::getSingleton().load(iconPath, "Gui");
}
} catch (...) {
S_LOG_WARNING("Error when trying to load the icon " << iconPath <<". The icon will be rendered dynamically.");
texPtr.setNull();
}
if (!texPtr.isNull()) {
Icon* icon = mIconStore.createIcon(key, texPtr);
return icon;
}
}
}
Icon* icon = mIconStore.createIcon(key);
if (icon) {
//update the model preview window
// Model::Model* model = Model::Model::createModel(mIconRenderer.getRenderContext()->getSceneManager(), modelName);
render(*icon, modelName);
// mIconRenderer.getRenderContext()->getSceneManager()->destroyMovableObject(model);
}
return icon;
}
return 0;
}
示例3: getTexture
void GUIHelper::getTexture(const Ogre::String &matName, Ogre::TexturePtr &result)
{
Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().getByName(matName);
if(mat.isNull() || /*!mat->getTechnique(0) ||
!mat->getTechnique(0)->getPass(0) ||*/
!mat->getTechnique(0)->getPass(0)->getTextureUnitState(0)){
result.setNull();
return;
}
result = Ogre::TextureManager::getSingleton().getByName(
mat->getTechnique(0)->getPass(0)->getTextureUnitState(
0)->getTextureName());
}
示例4: setWaterColor
void Hydrax::setWaterColor(const Ogre::Vector3 &WaterColor)
{
mWaterColor = WaterColor;
if (!mCreated)
{
return;
}
Ogre::ColourValue WC = Ogre::ColourValue(WaterColor.x, WaterColor.y, WaterColor.z);
Ogre::TexturePtr tex;
if (isComponent(HYDRAX_COMPONENT_UNDERWATER_REFLECTIONS) || !_isCurrentFrameUnderwater())
{
/* Fix from http://www.ogre3d.org/addonforums/viewtopic.php?f=20&t=10925
mRttManager->getTexture(RttManager::RTT_REFLECTION)->
getBuffer()->getRenderTarget()->getViewport(0)->
setBackgroundColour(WC);
*/
tex = mRttManager->getTexture(RttManager::RTT_REFLECTION);
if(!tex.isNull())
{
tex->getBuffer()->getRenderTarget()->getViewport(0)->setBackgroundColour(WC);
tex.setNull();
}
}
/* Fix from http://www.ogre3d.org/addonforums/viewtopic.php?f=20&t=10925
mRttManager->getTexture(RttManager::RTT_REFRACTION)->
getBuffer()->getRenderTarget()->getViewport(0)->
setBackgroundColour(WC);
*/
tex = mRttManager->getTexture(RttManager::RTT_REFRACTION);
if(!tex.isNull())
{
tex->getBuffer()->getRenderTarget()->getViewport(0)->setBackgroundColour(WC);
tex.setNull();
}
if (!isComponent(HYDRAX_COMPONENT_DEPTH))
{
return;
}
mMaterialManager->setGpuProgramParameter(
MaterialManager::GPUP_FRAGMENT, MaterialManager::MAT_WATER,
"uWaterColor", WaterColor);
if (isComponent(HYDRAX_COMPONENT_UNDERWATER))
{
mMaterialManager->setGpuProgramParameter(
MaterialManager::GPUP_FRAGMENT, MaterialManager::MAT_UNDERWATER,
"uWaterColor", WaterColor);
//mMaterialManager->getCompositor(MaterialManager::COMP_UNDERWATER)->
// getTechnique(0)->getTargetPass(0)->getPass(0)->setClearColour(WC);
/* Active creation/destruction
if (getHeigth(mCamera->getDerivedPosition()) > mCamera->getDerivedPosition().y-1.25f)
{
if (mMaterialManager->isCompositorEnable(MaterialManager::COMP_UNDERWATER))
{
mMaterialManager->setCompositorEnable(MaterialManager::COMP_UNDERWATER, false);
mMaterialManager->setCompositorEnable(MaterialManager::COMP_UNDERWATER, true);
}
}
*/
}
}
示例5: renderTextures
//.........这里部分代码省略.........
//Disable fog
Ogre::FogMode oldFogMode = sceneMgr->getFogMode();
Ogre::ColourValue oldFogColor = sceneMgr->getFogColour();
Ogre::Real oldFogDensity = sceneMgr->getFogDensity();
Ogre::Real oldFogStart = sceneMgr->getFogStart();
Ogre::Real oldFogEnd = sceneMgr->getFogEnd();
sceneMgr->setFog(Ogre::FOG_NONE);
// Get current status of the queue mode
Ogre::SceneManager::SpecialCaseRenderQueueMode OldSpecialCaseRenderQueueMode =
sceneMgr->getSpecialCaseRenderQueueMode();
//Only render the entity
sceneMgr->setSpecialCaseRenderQueueMode(Ogre::SceneManager::SCRQM_INCLUDE);
sceneMgr->addSpecialCaseRenderQueue(renderQueueGroup);
Ogre::uint8 oldRenderQueueGroup = entity->getRenderQueueGroup();
entity->setRenderQueueGroup(renderQueueGroup);
bool oldVisible = entity->getVisible();
entity->setVisible(true);
float oldMaxDistance = entity->getRenderingDistance();
entity->setRenderingDistance(0);
//Calculate the filename hash used to uniquely identity this render
std::string strKey = entityKey;
char key[32] = {0};
Ogre::uint32 i = 0;
for (std::string::const_iterator it = entityKey.begin(); it != entityKey.end(); ++it) {
key[i] ^= *it;
i = (i+1) % sizeof(key);
}
for (i = 0; i < sizeof(key); ++i)
key[i] = (key[i] % 26) + 'A';
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
GetUserDir().string(), "FileSystem", "BinFolder");
std::string fileNamePNG =
"Rendered." + std::string(key, sizeof(key)) + '.' +
Ogre::StringConverter::toString(textureSize) + ".png";
//Attempt to load the pre-render file if allowed
bool needsRegen = false;
if (!needsRegen) {
try{
texture = Ogre::TextureManager::getSingleton().load(
fileNamePNG, "BinFolder", Ogre::TEX_TYPE_2D, 0);
} catch (...) {
needsRegen = true;
}
}
if (needsRegen) {
//If this has not been pre-rendered, do so now
//Position camera
camNode->setPosition(0, 0, 0);
// TODO camNode->setOrientation(Quaternion(yaw, Vector3::UNIT_Y) * Quaternion(-pitch, Vector3::UNIT_X));
camNode->translate(Ogre::Vector3(0, 0, objDist), Ogre::Node::TS_LOCAL);
renderTarget->update();
//Save RTT to file
renderTarget->writeContentsToFile((GetUserDir() / fileNamePNG).string());
//Load the render into the appropriate texture view
texture = Ogre::TextureManager::getSingleton().load(fileNamePNG, "BinFolder", Ogre::TEX_TYPE_2D, 0);
ggTexture = ClientUI::GetTexture(GetUserDir() / fileNamePNG);
}
entity->setVisible(oldVisible);
entity->setRenderQueueGroup(oldRenderQueueGroup);
entity->setRenderingDistance(oldMaxDistance);
sceneMgr->removeSpecialCaseRenderQueue(renderQueueGroup);
// Restore original state
sceneMgr->setSpecialCaseRenderQueueMode(OldSpecialCaseRenderQueueMode);
//Re-enable mipmapping
mm->setDefaultTextureFiltering(oldMinFilter, oldMagFilter, oldMipFilter);
//Re-enable fog
sceneMgr->setFog(oldFogMode, oldFogColor, oldFogDensity, oldFogStart, oldFogEnd);
//Delete camera
renderTarget->removeViewport(0);
renderCamera->getSceneManager()->destroyCamera(renderCamera);
//Delete scene node
node->detachAllObjects();
if (oldSceneNode)
oldSceneNode->attachObject(entity);
//Delete RTT texture
assert(!renderTexture.isNull());
std::string texName2(renderTexture->getName());
renderTexture.setNull();
if (Ogre::TextureManager::getSingletonPtr())
Ogre::TextureManager::getSingleton().remove(texName2);
}