本文整理汇总了C++中ogre::TextureUnitState::setTextureName方法的典型用法代码示例。如果您正苦于以下问题:C++ TextureUnitState::setTextureName方法的具体用法?C++ TextureUnitState::setTextureName怎么用?C++ TextureUnitState::setTextureName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::TextureUnitState
的用法示例。
在下文中一共展示了TextureUnitState::setTextureName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReplaceTextureOnMaterial
void ReplaceTextureOnMaterial(Ogre::MaterialPtr material, const std::string& original_name, const std::string& texture_name)
{
if (material.isNull())
return;
Ogre::TextureManager &tm = Ogre::TextureManager::getSingleton();
Ogre::TexturePtr tex = tm.getByName(texture_name);
Ogre::Material::TechniqueIterator iter = material->getTechniqueIterator();
while(iter.hasMoreElements())
{
Ogre::Technique *tech = iter.getNext();
assert(tech);
Ogre::Technique::PassIterator passIter = tech->getPassIterator();
while(passIter.hasMoreElements())
{
Ogre::Pass *pass = passIter.getNext();
Ogre::Pass::TextureUnitStateIterator texIter = pass->getTextureUnitStateIterator();
while(texIter.hasMoreElements())
{
Ogre::TextureUnitState *texUnit = texIter.getNext();
if (texUnit->getTextureName() == original_name)
{
if (tex.get())
texUnit->setTextureName(texture_name);
else
texUnit->setTextureName("TextureMissing.png");
}
}
}
}
}
示例2: CreateVertexBuffers
//------------------------------------------------------------------------------
Background2D::Background2D():
m_AlphaMaxVertexCount( 0 ),
m_AddMaxVertexCount( 0 ),
m_ScrollEntity( NULL ),
m_ScrollPositionStart( Ogre::Vector2::ZERO ),
m_ScrollPositionEnd( Ogre::Vector2::ZERO ),
m_ScrollType( Background2D::NONE ),
m_ScrollSeconds( 0 ),
m_ScrollCurrentSeconds( 0 ),
m_Position( Ogre::Vector2::ZERO ),
m_PositionReal( Ogre::Vector2::ZERO )
,m_range( Ogre::AxisAlignedBox::BOX_INFINITE )
// for ffvii
,m_virtual_screen_size( 320, 240 )
{
m_SceneManager = Ogre::Root::getSingleton().getSceneManager( "Scene" );
m_RenderSystem = Ogre::Root::getSingletonPtr()->getRenderSystem();
CreateVertexBuffers();
m_AlphaMaterial = Ogre::MaterialManager::getSingleton().create( "Background2DAlpha", "General" );
Ogre::Pass* pass = m_AlphaMaterial->getTechnique( 0 )->getPass( 0 );
pass->setVertexColourTracking( Ogre::TVC_AMBIENT );
pass->setCullingMode( Ogre::CULL_NONE );
pass->setDepthCheckEnabled( true );
pass->setDepthWriteEnabled( true );
pass->setLightingEnabled( false );
pass->setSceneBlending( Ogre::SBT_TRANSPARENT_ALPHA );
pass->setAlphaRejectFunction( Ogre::CMPF_GREATER );
pass->setAlphaRejectValue( 0 );
Ogre::TextureUnitState* tex = pass->createTextureUnitState();
tex->setTextureName( "system/blank.png" );
tex->setNumMipmaps( -1 );
tex->setTextureFiltering( Ogre::TFO_NONE );
m_AddMaterial = Ogre::MaterialManager::getSingleton().create( "Background2DAdd", "General" );
pass = m_AddMaterial->getTechnique( 0 )->getPass( 0 );
pass->setVertexColourTracking( Ogre::TVC_AMBIENT );
pass->setCullingMode( Ogre::CULL_NONE );
pass->setDepthCheckEnabled( true );
pass->setDepthWriteEnabled( true );
pass->setLightingEnabled( false );
pass->setSceneBlending( Ogre::SBT_ADD );
pass->setAlphaRejectFunction( Ogre::CMPF_GREATER );
pass->setAlphaRejectValue( 0 );
tex = pass->createTextureUnitState();
tex->setTextureName( "system/blank.png" );
tex->setNumMipmaps( -1 );
tex->setTextureFiltering( Ogre::TFO_NONE );
m_SceneManager->addRenderQueueListener( this );
}
示例3:
//------------------------------------------------------------------------------
void
Background2D::SetImage( const Ogre::String& image )
{
Ogre::LogManager::getSingleton().stream()
<< "Background2D::SetImage " << image;
Ogre::Pass* pass = m_AlphaMaterial->getTechnique( 0 )->getPass( 0 );
Ogre::TextureUnitState* tex = pass->getTextureUnitState( 0 );
tex->setTextureName( image );
pass = m_AddMaterial->getTechnique( 0 )->getPass( 0 );
tex = pass->getTextureUnitState( 0 );
tex->setTextureName( image );
}
示例4: setSkyGradientsImage
void SkyDome::setSkyGradientsImage (const Ogre::String& gradients)
{
Ogre::TextureUnitState* gradientsTus =
mMaterial->getTechnique (0)->getPass (0)->getTextureUnitState(0);
gradientsTus->setTextureAddressingMode (Ogre::TextureUnitState::TAM_CLAMP);
// Per 1.4 compatibility. Not tested with recent svn.
#if OGRE_VERSION < ((1 << 16) | (3 << 8))
gradientsTus->setTextureName (gradients, Ogre::TEX_TYPE_2D, -1, true);
#else
gradientsTus->setTextureName (gradients, Ogre::TEX_TYPE_2D);
gradientsTus->setIsAlpha (true);
#endif
}
示例5: compileMaterial
bool Simple::compileMaterial(Ogre::MaterialPtr material, std::set<std::string>& managedTextures) const
{
material->removeAllTechniques();
Ogre::Technique* technique = material->createTechnique();
if (!mTerrainPageSurfaces.empty()) {
//First add a base pass
auto surfaceLayer = mTerrainPageSurfaces.begin()->second;
Ogre::Pass* pass = technique->createPass();
pass->setLightingEnabled(false);
Ogre::TextureUnitState * textureUnitState = pass->createTextureUnitState();
textureUnitState->setTextureScale(1.0f / surfaceLayer->getScale(), 1.0f / surfaceLayer->getScale());
textureUnitState->setTextureName(surfaceLayer->getDiffuseTextureName());
textureUnitState->setTextureCoordSet(0);
for (auto& layer : mLayers) {
addPassToTechnique(*mGeometry, technique, layer, managedTextures);
}
}
if (mTerrainPageShadow) {
addShadow(technique, mTerrainPageShadow, material, managedTextures);
}
// addLightingPass(technique, managedTextures);
material->load();
if (material->getNumSupportedTechniques() == 0) {
S_LOG_WARNING("The material '" << material->getName() << "' has no supported techniques. The reason for this is: \n" << material->getUnsupportedTechniquesExplanation());
return false;
}
return true;
}
示例6: makeOgreMaterial
Ogre::MaterialPtr TextureManager::makeOgreMaterial(int16_t MaterialTypeID, int16_t TextureID)
{
Ogre::MaterialPtr NewMaterial = Ogre::MaterialManager::getSingleton().create("GrassMaterial", "General", true);
Ogre::Image* NewImage = new Ogre::Image(); // Delete?
uint16_t ImageID = IMAGE->GenerateMaterialImage(MaterialTypeID, TextureID);
uint8_t* iData = IMAGE->getImageData(ImageID);
uint16_t Width = IMAGE->getImageWidth(ImageID);
uint16_t Height = IMAGE->getImageHeight(ImageID);
NewImage->loadDynamicImage(iData, Width, Height, Ogre::PF_A8R8G8B8);
Ogre::TexturePtr NewTex = Ogre::TextureManager::getSingleton().loadImage("TextureX", "General", *NewImage, Ogre::TEX_TYPE_2D, 1);
Ogre::Technique* FirstTechnique = NewMaterial->getTechnique(0);
Ogre::Pass* FirstPass = FirstTechnique->getPass(0);
FirstPass->setLightingEnabled(false);
Ogre::TextureUnitState* TextureUnit = FirstPass->createTextureUnitState();
TextureUnit->setTextureName("TextureX", Ogre::TEX_TYPE_2D);
delete NewImage;
return NewMaterial;
}
示例7: compileMaterial
bool Simple::compileMaterial(Ogre::MaterialPtr material)
{
material->removeAllTechniques();
Ogre::Technique* technique = material->createTechnique();
for (SurfaceLayerStore::const_iterator I = mTerrainPageSurfaces.begin(); I != mTerrainPageSurfaces.end(); ++I) {
const TerrainPageSurfaceLayer* surfaceLayer = I->second;
if (I == mTerrainPageSurfaces.begin()) {
Ogre::Pass* pass = technique->createPass();
pass->setLightingEnabled(false);
//add the first layer of the terrain, no alpha or anything
Ogre::TextureUnitState * textureUnitState = pass->createTextureUnitState();
textureUnitState->setTextureScale(1.0f / surfaceLayer->getScale(), 1.0f / surfaceLayer->getScale());
textureUnitState->setTextureName(surfaceLayer->getDiffuseTextureName());
textureUnitState->setTextureCoordSet(0);
} else {
if (surfaceLayer->intersects(*mGeometry)) {
addPassToTechnique(*mGeometry, technique, surfaceLayer);
}
}
}
if (mTerrainPageShadow) {
addShadow(technique, mTerrainPageShadow, material);
}
material->load();
if (material->getNumSupportedTechniques() == 0) {
S_LOG_WARNING("The material '" << material->getName() << "' has no supported techniques. The reason for this is: \n" << material->getUnsupportedTechniquesExplanation());
return false;
}
return true;
}
示例8: onInitialize
void ImageDisplay::onInitialize()
{
ImageDisplayBase::onInitialize();
{
static uint32_t count = 0;
std::stringstream ss;
ss << "ImageDisplay" << count++;
img_scene_manager_ = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC, ss.str());
}
img_scene_node_ = img_scene_manager_->getRootSceneNode()->createChildSceneNode();
{
static int count = 0;
std::stringstream ss;
ss << "ImageDisplayObject" << count++;
screen_rect_ = new Ogre::Rectangle2D(true);
screen_rect_->setRenderQueueGroup(Ogre::RENDER_QUEUE_OVERLAY - 1);
screen_rect_->setCorners(-1.0f, 1.0f, 1.0f, -1.0f);
ss << "Material";
material_ = Ogre::MaterialManager::getSingleton().create( ss.str(), Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
material_->setSceneBlending( Ogre::SBT_REPLACE );
material_->setDepthWriteEnabled(false);
material_->setReceiveShadows(false);
material_->setDepthCheckEnabled(false);
material_->getTechnique(0)->setLightingEnabled(false);
Ogre::TextureUnitState* tu = material_->getTechnique(0)->getPass(0)->createTextureUnitState();
tu->setTextureName(texture_.getTexture()->getName());
tu->setTextureFiltering( Ogre::TFO_NONE );
material_->setCullingMode(Ogre::CULL_NONE);
Ogre::AxisAlignedBox aabInf;
aabInf.setInfinite();
screen_rect_->setBoundingBox(aabInf);
screen_rect_->setMaterial(material_->getName());
img_scene_node_->attachObject(screen_rect_);
}
render_panel_ = new RenderPanel();
render_panel_->getRenderWindow()->setAutoUpdated(false);
render_panel_->getRenderWindow()->setActive( false );
render_panel_->resize( 640, 480 );
render_panel_->initialize(img_scene_manager_, context_);
setAssociatedWidget( render_panel_ );
render_panel_->setAutoRender(false);
render_panel_->setOverlaysEnabled(false);
render_panel_->getCamera()->setNearClipDistance( 0.01f );
updateNormalizeOptions();
}
示例9: setTextureAndTexAniFPS
//--------------------------------------------------------------------------------
static void setTextureAndTexAniFPS(const MaterialPtr& _material, const String& _texture, Real _texAniFPS)
{
Technique* technique = _material->getTechnique(0);
Pass* pass = technique->getPass(0);
if(_texture.empty())
{
pass->removeAllTextureUnitStates();
}
else
{
TextureManager& tmgr = TextureManager::getSingleton();
Ogre::TextureUnitState* tus = pass->getNumTextureUnitStates() ? pass->getTextureUnitState(0) : pass->createTextureUnitState();
if(_texAniFPS == 0)
{
TexturePtr ogreTexture = tmgr.createOrRetrieve(_texture).first;
const String& ogreTexName = ogreTexture->getName();
tus->setTextureName(ogreTexName);
}
else
{
vector<String>::type ogreTexNames;
TexturePtr ogreTexture = tmgr.createOrRetrieve(_texture).first;
ogreTexNames.push_back(ogreTexture->getName());
size_t dotpos = _texture.rfind('.');
if(dotpos != String::npos && dotpos >= 1
&& '0' <= _texture[dotpos-1] && _texture[dotpos-1] < '9')
{
String tmpname = _texture;
char& dig0 = tmpname[dotpos - 1];
++dig0;
while(!tmgr.getByName(tmpname).isNull() || tmgr.canLoadResource(tmpname, TextureManager::GROUP_NAME))
{
TexturePtr ogreTexture = tmgr.createOrRetrieve(tmpname).first;
ogreTexNames.push_back(ogreTexture->getName());
++dig0;
if(dig0 > '9')
{
if(dotpos >= 2 && '0' <= _texture[dotpos-2] && _texture[dotpos-2] < '9')
{
char& dig1 = tmpname[dotpos-2];
++dig1;
dig0 = '0';
}
else
break;
}
}
}
Real duration = ogreTexNames.size() / _texAniFPS;
tus->setAnimatedTextureName(&ogreTexNames[0], ogreTexNames.size(), duration);
}
}
}
示例10: setAtmosphereDepthImage
void SkyDome::setAtmosphereDepthImage (const Ogre::String& atmosphereDepth)
{
if (!mShadersEnabled) {
return;
}
Ogre::TextureUnitState* atmosphereTus =
mMaterial->getTechnique (0)->getPass (0)->getTextureUnitState(1);
atmosphereTus->setTextureName (atmosphereDepth, Ogre::TEX_TYPE_1D);
atmosphereTus->setTextureAddressingMode (Ogre::TextureUnitState::TAM_CLAMP, Ogre::TextureUnitState::TAM_WRAP, Ogre::TextureUnitState::TAM_WRAP);
}
示例11: addEffect
void EffectManager::addEffect(const std::string &model, std::string textureOverride, const Ogre::Vector3 &worldPosition, float scale)
{
Ogre::SceneNode* sceneNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(worldPosition);
sceneNode->setScale(scale,scale,scale);
// fix texture extension to .dds
if (textureOverride.size() > 4)
{
textureOverride[textureOverride.size()-3] = 'd';
textureOverride[textureOverride.size()-2] = 'd';
textureOverride[textureOverride.size()-1] = 's';
}
NifOgre::ObjectScenePtr scene = NifOgre::Loader::createObjects(sceneNode, model);
// TODO: turn off shadow casting
MWRender::Animation::setRenderProperties(scene, RV_Misc,
RQG_Main, RQG_Alpha, 0.f, false, NULL);
for(size_t i = 0;i < scene->mControllers.size();i++)
{
if(scene->mControllers[i].getSource().isNull())
scene->mControllers[i].setSource(Ogre::SharedPtr<EffectAnimationTime> (new EffectAnimationTime()));
}
if (!textureOverride.empty())
{
for(size_t i = 0;i < scene->mParticles.size(); ++i)
{
Ogre::ParticleSystem* partSys = scene->mParticles[i];
Ogre::MaterialPtr mat = scene->mMaterialControllerMgr.getWritableMaterial(partSys);
for (int t=0; t<mat->getNumTechniques(); ++t)
{
Ogre::Technique* tech = mat->getTechnique(t);
for (int p=0; p<tech->getNumPasses(); ++p)
{
Ogre::Pass* pass = tech->getPass(p);
for (int tex=0; tex<pass->getNumTextureUnitStates(); ++tex)
{
Ogre::TextureUnitState* tus = pass->getTextureUnitState(tex);
tus->setTextureName("textures\\" + textureOverride);
}
}
}
}
}
mEffects.push_back(std::make_pair(sceneNode, scene));
}
示例12: _imageFromRenderTarget
//----------------------------------------------------------------------------------------
QImage ImageConverter::_imageFromRenderTarget(const Ogre::Image& img)
{
Ogre::TextureManager::getSingletonPtr()->loadImage("QTTextureName", "QTImageConverter", img);
// create our material
Ogre::MaterialPtr material = Ogre::MaterialManager::getSingletonPtr()->create("terrainMaterial", "QTImageConverter");
Ogre::Technique * technique = material->getTechnique(0);
Ogre::Pass* pass = technique->getPass(0);
Ogre::TextureUnitState* textureUnit = pass->createTextureUnitState();
textureUnit->setTextureName("QTTextureName");
return _getRenderTarget(material->getName());
}
示例13: createCubeMesh
//-------------------------------------------------------------------------------------
void BasicTutorial2::createScene(void)
{
mSceneMgr->setAmbientLight(Ogre::ColourValue(0, 0, 0));
//mSceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);
//Create cube
//Create a basic green color texture
Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().create("BoxColor", "General", true );
Ogre::Technique* tech = mat->getTechnique(0);
Ogre::Pass* pass = tech->getPass(0);
Ogre::TextureUnitState* tex = pass->createTextureUnitState();
tex->setTextureName("grassTexture.png");
//tex->setNumMipmaps(4);
tex->setTextureAnisotropy(1);
tex->setTextureFiltering(Ogre::FO_POINT, Ogre::FO_POINT, Ogre::FO_POINT);
//Create the one box and the supporting class objects
Ogre::ManualObject* testBox = createCubeMesh("TestBox1", "BoxColor");
Ogre::SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
Ogre::MeshPtr Mesh = testBox->convertToMesh("TestBox2");
Ogre::StaticGeometry* pGeom = new Ogre::StaticGeometry (mSceneMgr, "Boxes");
Ogre::Entity* pEnt = mSceneMgr->createEntity("TestBox2");
//testBox->triangle
pGeom->setRegionDimensions(Ogre::Vector3(300, 300, 300));
World::Instance();
pGeom->build ();
mSceneMgr->setAmbientLight(Ogre::ColourValue(0.5, 0.5, 0.5));
Ogre::Light* l = mSceneMgr->createLight("MainLight");
l->setPosition(20,80,50);
//Create Cube
/* Ogre::Entity* entNinja = mSceneMgr->createEntity("Ninja", "ninja.mesh");
entNinja->setCastShadows(true);
mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(entNinja);*/
Ogre::Light* directionalLight = mSceneMgr->createLight("directionalLight");
directionalLight->setType(Ogre::Light::LT_DIRECTIONAL);
directionalLight->setDiffuseColour(Ogre::ColourValue(.25, .25, 0));
directionalLight->setSpecularColour(Ogre::ColourValue(.25, .25, 0));
directionalLight->setDirection(Ogre::Vector3( 0, -1, 1 ));
}
示例14: createScene
void IntroState::createScene()
{
MaterialPtr material = MaterialManager::getSingleton().create("Background", "General");
material->getTechnique(0)->getPass(0)->createTextureUnitState("rockwall.tga");
material->getTechnique(0)->getPass(0)->setDepthCheckEnabled(false);
material->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false);
material->getTechnique(0)->getPass(0)->setLightingEnabled(false);
//Ustvarimo 2D kvadrat, ki prekrije celonti ekrat
Rectangle2D* rect = new Rectangle2D(true);
rect->setCorners(-1.0, 1.0, 1.0, -1.0);
rect->setMaterial("Background");
//najprej renderiramo ozadje potem pa vse ostalo
rect->setRenderQueueGroup(RENDER_QUEUE_BACKGROUND);
rect->setBoundingBox(AxisAlignedBox(-100000.0*Ogre::Vector3::UNIT_SCALE, 100000.0*Ogre::Vector3::UNIT_SCALE));
// pripnemo teksturo na ozadje
SceneNode* node = m_pSceneMgr->getRootSceneNode()->createChildSceneNode("Background");
node->attachObject(rect);
Ogre::MaterialPtr mat;
Ogre::TextureUnitState* tex;
Ogre::String materialName="Background";
if (!Ogre::MaterialManager::getSingleton().resourceExists(materialName))
{
throw("Error, material doesn't exist!");
}
//tukaj prilepimo film na prej ustvarjeno teksturo
mat=Ogre::MaterialManager::getSingleton().getByName(materialName);
tex=mat->getTechnique(0)->getPass(0)->getTextureUnitState(0);
tex->setTextureName(dshowMovieTextureSystem->getMovieTexture()->getName());
mTitleLabel->setCaption("Intro");
mTitleLabel->show();
mTitleLabel2->setCaption("Press ESC to Exit Game!");
mTitleLabel2->show();
mTitleLabel3->setCaption("Press Space to skip!");
mTitleLabel3->show();
}
示例15: 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);
}