本文整理汇总了C++中ogre::TexturePtr类的典型用法代码示例。如果您正苦于以下问题:C++ TexturePtr类的具体用法?C++ TexturePtr怎么用?C++ TexturePtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TexturePtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mSceneManager
SimpleRenderContext::SimpleRenderContext(const std::string& prefix, Ogre::TexturePtr texture) :
mMainLight(0), mSceneManager(0), mWidth(texture->getWidth()), mHeight(texture->getHeight()), mRenderTexture(0), mCameraNode(0), mCameraPitchNode(0), mEntityNode(0), mRootNode(0), mCamera(0), mViewPort(0), mResourceLoader(*this), mBackgroundColour(Ogre::ColourValue::Black), mCameraPositionMode(CPM_OBJECTCENTER), mTextureOwned(false)
{
setupScene(prefix);
setTexture(texture);
Ogre::Real aspectRatio = static_cast<float>(texture->getWidth()) / static_cast<float>(texture->getHeight());
S_LOG_VERBOSE("Setting aspect ratio of camera to " << aspectRatio);
mCamera->setAspectRatio(aspectRatio);
}
示例2: GenerateRelief
void ReliefApp::GenerateRelief()
{
//Get depth data
Ogre::TexturePtr depthTex = Ogre::TextureManager::getSingleton().createManual(
"DepthTexture", // name
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
Ogre::TEX_TYPE_2D, // type
512, // width
512, // height
0, // number of mipmaps
//Ogre::PF_B8G8R8A8, // pixel format
Ogre::PF_FLOAT32_R,
Ogre::TU_RENDERTARGET
);
Ogre::RenderTarget* pTarget = depthTex->getBuffer()->getRenderTarget();
Ogre::Camera* pOrthCam = MagicCore::RenderSystem::GetSingleton()->GetMainCamera();
pOrthCam->setProjectionType(Ogre::PT_ORTHOGRAPHIC);
pOrthCam->setOrthoWindow(3, 3);
pOrthCam->setPosition(0, 0, 3);
pOrthCam->lookAt(0, 0, 0);
pOrthCam->setAspectRatio(1.0);
pOrthCam->setNearClipDistance(0.5);
pOrthCam->setFarClipDistance(5);
Ogre::Viewport* pViewport = pTarget->addViewport(pOrthCam);
pViewport->setDimensions(0, 0, 1, 1);
MagicCore::RenderSystem::GetSingleton()->RenderLightMesh3D("RenderMesh", "Depth", mpLightMesh);
MagicCore::RenderSystem::GetSingleton()->Update();
Ogre::Image img;
depthTex->convertToImage(img);
std::vector<double> heightField(512 * 512);
for(int x = 0; x < 512; x++)
{
for(int y = 0; y < 512; y++)
{
heightField.at(x * 512 + y) = (img.getColourAt(x, 511 - y, 0))[1];
}
}
Ogre::TextureManager::getSingleton().remove("DepthTexture");
//
MagicDGP::LightMesh3D* pReliefMesh = MagicDGP::ReliefGeneration::PlaneReliefFromHeightField(heightField, 511, 511);
//MagicDGP::LightMesh3D* pReliefMesh = MagicDGP::ReliefGeneration::CylinderReliefFromHeightField(heightField, 511, 511);
if (pReliefMesh != NULL)
{
delete mpLightMesh;
mpLightMesh = pReliefMesh;
mpLightMesh->UnifyPosition(2);
mpLightMesh->UpdateNormal();
}
MagicCore::RenderSystem::GetSingleton()->SetupCameraDefaultParameter();
MagicCore::RenderSystem::GetSingleton()->RenderLightMesh3D("RenderMesh", "MyCookTorrance", mpLightMesh);
}
示例3: PrepareRtt
void EC_RttTarget::PrepareRtt()
{
if (!ViewEnabled())
return;
//\todo XXX reconfig via AttributeUpdated when these change
int x = width.Get();
int y = height.Get();
// Get the camera ec
EC_Camera *ec_camera = ParentEntity()->GetComponent<EC_Camera>().get();
if (!ec_camera)
{
LogInfo("No camera for rtt.");
return; //XXX note: doesn't reschedule, so won't start working if cam added afterwards
}
ec_camera->GetCamera()->setAspectRatio(Ogre::Real(x) / Ogre::Real(y));
Ogre::TexturePtr tex = Ogre::TextureManager::getSingleton().getByName(textureName.Get().toStdString());
if (tex.isNull())
{
tex = Ogre::TextureManager::getSingleton().createManual(textureName.Get().toStdString(),
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, x, y, 0,
Ogre::PF_A8R8G8B8, Ogre::TU_RENDERTARGET);
}
Ogre::RenderTexture *render_texture = tex->getBuffer()->getRenderTarget();
if (render_texture)
{
render_texture->removeAllViewports();
Ogre::Viewport *vp = 0;
vp = render_texture->addViewport(ec_camera->GetCamera());
// Exclude ui overlays
vp->setOverlaysEnabled(false);
// Exclude highlight mesh from rendering
vp->setVisibilityMask(0x2);
render_texture->update(false);
tex->getBuffer()->getRenderTarget()->setAutoUpdated(false);
}
else
LogError("render target texture getting failed.");
//create material to show the texture
material_name_ = textureName.Get().toStdString() + "_mat"; //renderer_.lock()->GetUniqueObjectName("EC_BillboardWidget_mat");
OgreRenderer::CloneMaterial("HoveringText", material_name_); //would LitTextured be the right thing? XXX \todo
Ogre::MaterialManager &material_manager = Ogre::MaterialManager::getSingleton();
Ogre::MaterialPtr material = material_manager.getByName(material_name_);
OgreRenderer::SetTextureUnitOnMaterial(material, textureName.Get().toStdString());
}
示例4: getTextureHeight
int GUIHelper::getTextureHeight(const Ogre::String &materialName)
{
Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().getByName(materialName);
if(mat.isNull() || /*!mat->getTechnique(0) ||
!mat->getTechnique(0)->getPass(0) ||*/
!mat->getTechnique(0)->getPass(0)->getTextureUnitState(0))
return -1;
Ogre::TexturePtr text = Ogre::TextureManager::getSingleton().getByName(
mat->getTechnique(0)->getPass(0)->getTextureUnitState(
0)->getTextureName());
if(text.isNull()) return -1;
return text->getHeight();
}
示例5: GetOrCreateLegacyMaterial
Ogre::MaterialPtr GetOrCreateLegacyMaterial(const std::string& texture_name, uint variation)
{
if (variation >= MAX_MATERIAL_VARIATIONS)
{
OgreRenderingModule::LogWarning("Requested suffix for non-existing material variation " + ToString<uint>(variation));
variation = 0;
}
const std::string& suffix = MaterialSuffix[variation];
Ogre::TextureManager &tm = Ogre::TextureManager::getSingleton();
Ogre::MaterialManager &mm = Ogre::MaterialManager::getSingleton();
std::string material_name = texture_name + suffix;
Ogre::MaterialPtr material = mm.getByName(material_name);
if (!material.get())
{
material = mm.create(material_name, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
assert(material.get());
}
else
return material;
Ogre::TexturePtr tex = tm.getByName(texture_name);
bool has_alpha = false;
if (!tex.isNull())
{
// As far as the legacy materials are concerned, DXT1 is not alpha
if (tex->getFormat() == Ogre::PF_DXT1)
has_alpha = false;
else if (Ogre::PixelUtil::hasAlpha(tex->getFormat()))
has_alpha = true;
}
Ogre::MaterialPtr base_material;
if (!has_alpha)
base_material = mm.getByName(BaseMaterials[variation]);
else
base_material = mm.getByName(AlphaBaseMaterials[variation]);
if (!base_material.get())
{
OgreRenderingModule::LogError("Could not find " + MaterialSuffix[variation] + " base material for " + texture_name);
return Ogre::MaterialPtr();
}
base_material->copyDetailsTo(material);
SetTextureUnitOnMaterial(material, texture_name, 0);
return material;
}
示例6: enter
void PlayState::enter()
{
mLuaState = lua_open();
luaL_openlibs(mLuaState);
luabind::open(mLuaState);
LuaBinding binder(mLuaState);
binder.bindLua();
mKeyboard = InputManager::getSingletonPtr()->getKeyboard();
mMouse = InputManager::getSingletonPtr()->getMouse();
mRoot = Root::getSingletonPtr();
mSoundMgr = SoundManager::getSingletonPtr();
mGUI = 0;
mViewport = 0;
//mCurrentLevel = 0;
createSounds();
mContinue = true;
mRotate = 0.13;
mFriendScore = 0;
mFocusActor = 0;
mRivalScore = 0;
mFriendLastScore = 0;
mRivalLastScore = 0;
firstConsoleInit = true;
Ogre::ShadowTextureManager::getSingletonPtr()->clear();
mSceneMgr = mRoot->createSceneManager(Ogre::ST_EXTERIOR_CLOSE, "Default SceneManager");
mSceneMgr->setShadowTechnique(SHADOWTYPE_NONE);
DotLevelLoader loader(mLuaState);
loader.parseLevels("game.levels", mLevels);
createScene();
mViewport = mRoot->getAutoCreatedWindow()->addViewport(mCamera);
initPlayerCam();
mViewport->setBackgroundColour(ColourValue(0.0, 0.0, 0.0));
initGUI();
mWindow = mRoot->getAutoCreatedWindow();
Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton().createManual("RttTex",
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, TEX_TYPE_2D, mWindow->getWidth(), mWindow->getHeight(), 0, PF_R8G8B8,
TU_RENDERTARGET);
mRenderTexture = texture->getBuffer()->getRenderTarget();
mRenderTexture->addViewport(mCamera);
mRenderTexture->getViewport(0)->setBackgroundColour(ColourValue::Black);
mRenderTexture->getViewport(0)->setOverlaysEnabled(true);
}
示例7: setDatablockIdAndTexture
/****************************************************************************
**
** Copyright (C) 2016 - 2017
**
** This file is part of the Magus toolkit
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
****************************************************************************/
#include "constants.h"
#include "texturelayer.h"
#include "OgreHlmsPbs.h"
#include "OgreHlmsManager.h"
#include "OgreLogManager.h"
#include "OgreStringConverter.h"
#include <fstream>
#include <ctime>
//****************************************************************************/
TextureLayer::TextureLayer(void) :
mTextureOnWhichIsPaintedWidth(0),
mTextureOnWhichIsPaintedHeight(0),
mTextureOnWhichIsPaintedHasAlpha(false),
mNumMipMaps(0),
mTextureTypeDefined(false),
mMaxSequence(0)
{
mTextureType = Ogre::PBSM_DIFFUSE;
mDatablockId = "";
mTextureFileName = "";
}
//****************************************************************************/
TextureLayer::~TextureLayer(void)
{
}
//****************************************************************************/
void TextureLayer::setDatablockIdAndTexture (const Ogre::IdString& datablockId,
Ogre::PbsTextureTypes textureType,
const Ogre::String& textureFileName)
{
mDatablockId = datablockId;
mTextureType = textureType;
mTextureFileName = textureFileName;
mTextureTypeDefined = true;
// Load the texture as image; assume it can be loaded, because it was already loaded as part of the material
setFirstTextureGeneration();
// Create the pixelbox of the original texture; this MUST be a separate image
mOriginalTexture.load(textureFileName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
mPixelboxOriginalTexture = mOriginalTexture.getPixelBox(0, 0);
// Debug texture
//Ogre::LogManager::getSingleton().logMessage("Debug texture: " + textureFileName);
//Ogre::LogManager::getSingleton().logMessage("Depth: " + Ogre::StringConverter::toString(mOriginalTexture.getDepth()));
//Ogre::LogManager::getSingleton().logMessage("Pixel format: " + Ogre::StringConverter::toString(mOriginalTexture.getFormat()));
//Ogre::LogManager::getSingleton().logMessage("Alpha: " + Ogre::StringConverter::toString(mOriginalTexture.getHasAlpha()));
//Ogre::LogManager::getSingleton().logMessage("Height: " + Ogre::StringConverter::toString(mOriginalTexture.getHeight()));
//Ogre::LogManager::getSingleton().logMessage("Number of faces: " + Ogre::StringConverter::toString(mOriginalTexture.getNumFaces()));
//Ogre::LogManager::getSingleton().logMessage("Number of mipmaps: " + Ogre::StringConverter::toString(mOriginalTexture.getNumMipmaps()));
//Ogre::LogManager::getSingleton().logMessage("Width: " + Ogre::StringConverter::toString(mOriginalTexture.getWidth()));
}
//****************************************************************************/
void TextureLayer::blitTexture (void)
{
/* Always get the actual pointers, because they may change. That is the reason why the datablock pointer cannot be cached.
* The same seems to apply to the texture pointer.
*/
Ogre::HlmsDatablock* datablock;
Ogre::HlmsPbsDatablock* datablockPbs;
Ogre::TexturePtr texture;
Ogre::HlmsManager* hlmsManager = Ogre::Root::getSingletonPtr()->getHlmsManager();
Ogre::HlmsPbs* hlmsPbs = static_cast<Ogre::HlmsPbs*>(hlmsManager->getHlms(Ogre::HLMS_PBS));
datablock = hlmsPbs->getDatablock(mDatablockId);
if (!datablock)
return;
datablockPbs = static_cast<Ogre::HlmsPbsDatablock*>(datablock);
try
{
// Get texture on GPU
if (!datablockPbs->getTexture(mTextureType).isNull())
{
texture = datablockPbs->getTexture(mTextureType); // TextureType MUST exist, otherwise the application crashes
mNumMipMaps = texture->getNumMipmaps();
}
//.........这里部分代码省略.........
示例8: UpdateOverlayImage
void RenderWindow::UpdateOverlayImage(const QImage &src)
{
if (!overlay)
return;
PROFILE(RenderWindow_UpdateOverlayImage);
Ogre::Box bounds(0, 0, src.width(), src.height());
Ogre::PixelBox bufbox(bounds, Ogre::PF_A8R8G8B8, (void *)src.bits());
Ogre::TextureManager &mgr = Ogre::TextureManager::getSingleton();
Ogre::TexturePtr texture = mgr.getByName(rttTextureName);
assert(texture.get());
texture->getBuffer()->blitFromMemory(bufbox);
}
示例9: createTextureImage
TexturePair AssetsManager::createTextureImage(Ogre::TexturePtr texturePtr, const std::string& imageSetName)
{
// if (mOgreCEGUITexture) {
// GUIManager::getSingleton().getGuiRenderer()->destroyTexture(mOgreCEGUITexture);
// mOgreCEGUITexture = 0;
// }
CEGUI::Imageset* textureImageset;
if (CEGUI::ImagesetManager::getSingleton().isDefined(imageSetName)) {
textureImageset = &CEGUI::ImagesetManager::getSingleton().get(imageSetName);
} else {
//create a CEGUI texture from our Ogre texture
S_LOG_VERBOSE("Creating new CEGUI texture from Ogre texture.");
CEGUI::Texture* ogreCEGUITexture = &GUIManager::getSingleton().getGuiRenderer()->createTexture(texturePtr);
//we need a imageset in order to create GUI elements from the ceguiTexture
S_LOG_VERBOSE("Creating new CEGUI imageset with name " << imageSetName);
textureImageset = &CEGUI::ImagesetManager::getSingleton().create(imageSetName, *ogreCEGUITexture);
//we only want one element: the whole texture
textureImageset->defineImage("full_image", CEGUI::Rect(0, 0, texturePtr->getWidth(), texturePtr->getHeight()), CEGUI::Point(0, 0));
}
//assign our image element to the StaticImage widget
const CEGUI::Image* textureImage = &textureImageset->getImage("full_image");
return TexturePair(texturePtr, textureImage, textureImageset);
}
示例10: _createTexture
bool TextureManager::_createTexture(Ogre::TexturePtr &Texture, const Ogre::String &Name, const Size &Size)
{
try
{
Ogre::TextureManager::getSingleton().remove(Name);
Texture = Ogre::TextureManager::getSingleton().
createManual(Name,
HYDRAX_RESOURCE_GROUP,
Ogre::TEX_TYPE_2D,
Size.Width, Size.Height,
0,
Ogre::PF_BYTE_BGRA,
Ogre::TU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
Texture->load();
}
catch(Ogre::Exception &e)
{
HydraxLOG(e.getFullDescription());
return false;
}
return true;
}
示例11: setTexture
void SimpleRenderContext::setTexture(Ogre::TexturePtr texture)
{
if (texture != mTexture) {
if (mRenderTexture) {
mRenderTexture->removeAllViewports();
}
mTexture = texture;
mRenderTexture = texture->getBuffer()->getRenderTarget();
mRenderTexture->removeAllViewports();
mRenderTexture->setAutoUpdated(false);
//initially deactivate it until setActive(true) is called
mRenderTexture->setActive(false);
S_LOG_VERBOSE("Adding camera.");
mViewPort = mRenderTexture->addViewport(mCamera);
mViewPort->setOverlaysEnabled(false);
mViewPort->setShadowsEnabled(false);
//make sure the camera renders into this new texture
//this should preferrably be a transparent background, so that CEGUI could itself decide what to show behind it, but alas I couldn't get it to work, thus black
mViewPort->setBackgroundColour(mBackgroundColour);
// mViewPort->setBackgroundColour(Ogre::ColourValue::ZERO);
//don't show the CEGUI
mViewPort->setOverlaysEnabled(false);
//the cegui renderer wants a TexturePtr (not a RenderTexturePtr), so we just ask the texturemanager for texture we just created (rttex)
}
}
示例12: addShadow
void Simple::addShadow(Ogre::Technique* technique, const TerrainPageShadow* terrainPageShadow, Ogre::MaterialPtr material, std::set<std::string>& managedTextures) const
{
Ogre::Pass* shadowPass = technique->createPass();
shadowPass->setSceneBlending(Ogre::SBT_MODULATE);
shadowPass->setLightingEnabled(false);
// shadowPass->setFog(true, Ogre::FOG_NONE);
Ogre::TextureUnitState * textureUnitStateSplat = shadowPass->createTextureUnitState();
Ogre::TexturePtr texture = updateShadowTexture(material, terrainPageShadow, managedTextures);
textureUnitStateSplat->setTextureName(texture->getName());
textureUnitStateSplat->setTextureCoordSet(0);
textureUnitStateSplat->setTextureAddressingMode(Ogre::TextureUnitState::TAM_CLAMP);
textureUnitStateSplat->setTextureFiltering(Ogre::TFO_ANISOTROPIC);
}
示例13: getTexture
ITexture* getTexture(const std::string& _name)
{
MapTexture::const_iterator item = mTextures.find(_name);
if (item == mTextures.end())
{
Ogre::TexturePtr texture = (Ogre::TexturePtr)Ogre::TextureManager::getSingleton().getByName(_name);
if (!texture.isNull())
{
ITexture* result = createTexture(_name);
static_cast<OgreTexture*>(result)->setOgreTexture(texture);
return result;
}
return nullptr;
}
return item->second;
}
示例14: GetLocalTexture
Ogre::TexturePtr GetLocalTexture(const std::string& name)
{
Ogre::TextureManager& manager = Ogre::TextureManager::getSingleton();
Ogre::TexturePtr tex = manager.getByName(name);
if (tex.isNull())
{
try
{
manager.load(name, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
tex = manager.getByName(name);
}
catch(...) {}
}
return tex;
}
示例15: CreateLegacyMaterials
void CreateLegacyMaterials(const std::string& texture_name, bool update)
{
Ogre::TextureManager &tm = Ogre::TextureManager::getSingleton();
Ogre::MaterialManager &mm = Ogre::MaterialManager::getSingleton();
Ogre::TexturePtr tex = tm.getByName(texture_name);
bool has_alpha = false;
if (!tex.isNull())
{
if (Ogre::PixelUtil::hasAlpha(tex->getFormat()))
has_alpha = true;
}
// Early out: if texture does not yet exist and materials have already been created once
if (((tex.isNull()) || (!update)) && (!mm.getByName(texture_name).isNull()))
return;
for (uint i = 0; i < MAX_MATERIAL_VARIATIONS; ++i)
{
const std::string& base_material_name = BaseMaterials[i];
const std::string& alpha_base_material_name = AlphaBaseMaterials[i];
std::string material_name = texture_name + MaterialSuffix[i];
Ogre::MaterialPtr material = mm.getByName(material_name);
if (!material.get())
{
material = mm.create(material_name, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
assert(material.get());
}
Ogre::MaterialPtr base_material;
if (!has_alpha)
base_material = mm.getByName(base_material_name);
else
base_material = mm.getByName(alpha_base_material_name);
if (!base_material.get())
{
OgreRenderingModule::LogError("Could not find " + MaterialSuffix[i] + " base material for " + texture_name);
return;
}
base_material->copyDetailsTo(material);
SetTextureUnitOnMaterial(material, texture_name, 0);
}
}