本文整理汇总了C++中ogre::material::TechniqueIterator类的典型用法代码示例。如果您正苦于以下问题:C++ TechniqueIterator类的具体用法?C++ TechniqueIterator怎么用?C++ TechniqueIterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TechniqueIterator类的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: destroyMaterial
/**
* Destroy / unload the memory of a material
* @param mat MaterialName
*/
void GUIHelper::destroyMaterial(const Ogre::String &matName)
{
Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().getByName(matName);
if(mat.isNull()) return;
Ogre::Material::TechniqueIterator tit = mat->getTechniqueIterator();
while(tit.hasMoreElements()){
Ogre::Technique *t = tit.peekNext();
ASSERT(t);
Ogre::Technique::PassIterator pit = t->getPassIterator();
while(pit.hasMoreElements()){
Ogre::Pass *pass = pit.peekNext();
ASSERT(pass);
Ogre::Pass::TextureUnitStateIterator tuit =
pass->getTextureUnitStateIterator();
while(tuit.hasMoreElements()){
Ogre::TextureUnitState *tus = tuit.peekNext();
ASSERT(tus);
const Ogre::String &textName = tus->getTextureName();
Ogre::TextureManager::getSingleton().unload(textName);
Ogre::TextureManager::getSingleton().remove(textName);
tuit.moveNext();
}
pit.moveNext();
}
tit.moveNext();
}
Ogre::MaterialManager::getSingleton().unload(matName);
Ogre::MaterialManager::getSingleton().remove(matName);
}
示例3: SetSelfIllumination
void EC_WidgetCanvas::SetSelfIllumination(bool illuminating)
{
if (material_name_.empty())
return;
Ogre::ColourValue emissiveColor;
if (illuminating)
emissiveColor = Ogre::ColourValue(1.0f, 1.0f, 1.0f, 1.0f);
else
emissiveColor = Ogre::ColourValue(0.0f, 0.0f, 0.0f, 0.0f);
Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().getByName(material_name_);
if (!material.isNull())
{
Ogre::Material::TechniqueIterator iter = material->getTechniqueIterator();
while(iter.hasMoreElements())
{
Ogre::Technique *tech = iter.getNext();
if (!tech)
continue;
Ogre::Technique::PassIterator passIter = tech->getPassIterator();
while(passIter.hasMoreElements())
{
Ogre::Pass *pass = passIter.getNext();
if (pass)
pass->setSelfIllumination(emissiveColor);
}
}
}
}
示例4: validateCompositionTargetPass
bool MainCamera::validateCompositionTargetPass(Ogre::CompositionTargetPass& compositionPass)
{
Ogre::CompositionTargetPass::PassIterator compPassIter = compositionPass.getPassIterator();
while (compPassIter.hasMoreElements()) {
Ogre::CompositionPass* compositorPass = compPassIter.getNext();
compositorPass->getMaterial()->load();
Ogre::Material::TechniqueIterator techIter = compositorPass->getMaterial()->getSupportedTechniqueIterator();
while (techIter.hasMoreElements()) {
Ogre::Technique::PassIterator _passIter = techIter.getNext()->getPassIterator();
while (_passIter.hasMoreElements()) {
Ogre::Pass* pass = _passIter.getNext();
//Also disallow camera polygon mode overide. This is because if it's turned on,
//and the camera is switched to polygon mode, the end result will be one single
//large polygon being shown. This is not what we want.
pass->setPolygonModeOverrideable(false);
if (pass->hasFragmentProgram()) {
if (pass->getFragmentProgram()->hasCompileError()) {
return false;
}
}
}
}
}
return true;
}
示例5: Animation
CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, OEngine::Render::OgreRenderer& _rend): Animation(_rend)
{
mInsert = ptr.getRefData().getBaseNode();
MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>();
assert (ref->base != NULL);
if(!ref->base->model.empty())
{
const std::string &mesh = "meshes\\" + ref->base->model;
std::string meshNumbered = mesh + getUniqueID(mesh) + ">|";
NifOgre::NIFLoader::load(meshNumbered);
mBase = mRend.getScene()->createEntity(meshNumbered);
mBase->setVisibilityFlags(RV_Actors);
bool transparent = false;
for (unsigned int i=0; i < mBase->getNumSubEntities(); ++i)
{
Ogre::MaterialPtr mat = mBase->getSubEntity(i)->getMaterial();
Ogre::Material::TechniqueIterator techIt = mat->getTechniqueIterator();
while (techIt.hasMoreElements())
{
Ogre::Technique* tech = techIt.getNext();
Ogre::Technique::PassIterator passIt = tech->getPassIterator();
while (passIt.hasMoreElements())
{
Ogre::Pass* pass = passIt.getNext();
if (pass->getDepthWriteEnabled() == false)
transparent = true;
}
}
}
mBase->setRenderQueueGroup(transparent ? RQG_Alpha : RQG_Main);
std::string meshZero = mesh + "0000>|";
if((mTransformations = (NIFLoader::getSingletonPtr())->getAnim(meshZero)))
{
for(std::size_t init = 0; init < mTransformations->size(); init++)
{
mRindexI.push_back(0);
mTindexI.push_back(0);
}
mStopTime = mTransformations->begin()->getStopTime();
mStartTime = mTransformations->begin()->getStartTime();
mShapes = (NIFLoader::getSingletonPtr())->getShapes(meshZero);
}
mTextmappings = NIFLoader::getSingletonPtr()->getTextIndices(meshZero);
mInsert->attachObject(mBase);
}
}
示例6: Animation
CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr): Animation()
{
mInsert = ptr.getRefData().getBaseNode();
MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>();
assert (ref->mBase != NULL);
if(!ref->mBase->mModel.empty())
{
std::string mesh = "meshes\\" + ref->mBase->mModel;
mEntityList = NifOgre::NIFLoader::createEntities(mInsert, &mTextKeys, mesh);
for(size_t i = 0; i < mEntityList.mEntities.size(); i++)
{
Ogre::Entity *ent = mEntityList.mEntities[i];
ent->setVisibilityFlags(RV_Actors);
bool transparent = false;
for (unsigned int j=0; j < ent->getNumSubEntities() && !transparent; ++j)
{
Ogre::MaterialPtr mat = ent->getSubEntity(j)->getMaterial();
Ogre::Material::TechniqueIterator techIt = mat->getTechniqueIterator();
while (techIt.hasMoreElements() && !transparent)
{
Ogre::Technique* tech = techIt.getNext();
Ogre::Technique::PassIterator passIt = tech->getPassIterator();
while (passIt.hasMoreElements() && !transparent)
{
Ogre::Pass* pass = passIt.getNext();
if (pass->getDepthWriteEnabled() == false)
transparent = true;
}
}
}
ent->setRenderQueueGroup(transparent ? RQG_Alpha : RQG_Main);
}
if(mEntityList.mSkelBase)
{
Ogre::AnimationStateSet *aset = mEntityList.mSkelBase->getAllAnimationStates();
Ogre::AnimationStateIterator as = aset->getAnimationStateIterator();
while(as.hasMoreElements())
{
Ogre::AnimationState *state = as.getNext();
state->setEnabled(true);
state->setLoop(false);
}
}
}
}
示例7: handleSchemeNotFound
//copied from ogre sample browser
Ogre::Technique* gkMaterialLoader::handleSchemeNotFound(unsigned short schemeIndex, const Ogre::String& schemeName,
Ogre::Material* originalMaterial, unsigned short lodIndex, const Ogre::Renderable* rend)
{
#ifdef OGREKIT_USE_RTSHADER_SYSTEM
Ogre::RTShader::ShaderGenerator* shaderGenerator = Ogre::RTShader::ShaderGenerator::getSingletonPtr();
GK_ASSERT(shaderGenerator);
Ogre::Technique* generatedTech = 0;
if (schemeName == Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME)
{
bool techniqueCreated;
techniqueCreated = shaderGenerator->createShaderBasedTechnique(
originalMaterial->getName(), Ogre::MaterialManager::DEFAULT_SCHEME_NAME, schemeName);
if (techniqueCreated)
{
shaderGenerator->validateMaterial(schemeName, originalMaterial->getName());
Ogre::Material::TechniqueIterator itTech = originalMaterial->getTechniqueIterator();
while (itTech.hasMoreElements())
{
Ogre::Technique* curTech = itTech.getNext();
if (curTech->getSchemeName() == schemeName)
{
generatedTech = curTech;
break;
}
}
}
}
if (!generatedTech)
{
gkLogMessage("Material: " << schemeName << " isn't found.");
}
else
{
gkLogMessage("Material: " << schemeName << " is found.");
}
return generatedTech;
#else
return 0;
#endif
}
示例8: while
void
Terrain::_applyFogMode(const Ogre::MaterialPtr& material, Ogre::FogMode oldFogMode, Ogre::FogMode newFogMode) const
{
if (oldFogMode == newFogMode)
return;
if (mData->mSupportedFogReplacements.empty())
return;
Ogre::String newProgramName;
Ogre::Material::TechniqueIterator ti = material->getTechniqueIterator();
while (ti.hasMoreElements())
{
Ogre::Technique* technique = ti.getNext();
Ogre::Technique::PassIterator pi = technique->getPassIterator();
while (pi.hasMoreElements())
{
Ogre::Pass* pass = pi.getNext();
if (pass->hasVertexProgram() &&
_checkFogProgramName(pass->getVertexProgram(), oldFogMode, newFogMode, newProgramName))
{
pass->setVertexProgram(newProgramName);
}
if (pass->hasFragmentProgram() &&
_checkFogProgramName(pass->getFragmentProgram(), oldFogMode, newFogMode, newProgramName))
{
pass->setFragmentProgram(newProgramName);
}
if (pass->hasShadowCasterVertexProgram() &&
_checkFogProgramName(pass->getShadowCasterVertexProgram(), oldFogMode, newFogMode, newProgramName))
{
pass->setShadowCasterVertexProgram(newProgramName);
}
if (pass->hasShadowReceiverVertexProgram() &&
_checkFogProgramName(pass->getShadowReceiverVertexProgram(), oldFogMode, newFogMode, newProgramName))
{
pass->setShadowReceiverVertexProgram(newProgramName);
}
if (pass->hasShadowReceiverFragmentProgram() &&
_checkFogProgramName(pass->getShadowReceiverFragmentProgram(), oldFogMode, newFogMode, newProgramName))
{
pass->setShadowReceiverFragmentProgram(newProgramName);
}
}
}
}
示例9: findFogPassesByName
void GroundFog::findFogPassesByName (const Ogre::String& passName) {
Ogre::MaterialManager *matManager = Ogre::MaterialManager::getSingletonPtr();
Ogre::MaterialManager::ResourceMapIterator matIt = matManager->getResourceIterator();
while (matIt.hasMoreElements()) {
Ogre::MaterialPtr mat = matIt.getNext();
Ogre::Material::TechniqueIterator techIt = mat->getTechniqueIterator();
while (techIt.hasMoreElements()) {
Ogre::Technique *tech = techIt.getNext();
Ogre::Technique::PassIterator passIt = tech->getPassIterator();
while (passIt.hasMoreElements()) {
Ogre::Pass *pass = passIt.getNext();
if (pass->getName() == passName) {
mPasses.insert(pass);
}
}
}
}
forceUpdate();
}
示例10: handleSchemeNotFound
/** This class demonstrates basic usage of the RTShader system.
It sub class the material manager listener class and when a target scheme callback
is invoked with the shader generator scheme it tries to create an equivalent shader
based technique based on the default technique of the given material.
*/
Ogre::Technique* MaterialMgrListener::handleSchemeNotFound(unsigned short schemeIndex,
const Ogre::String& schemeName, Ogre::Material* originalMaterial, unsigned short lodIndex,
const Ogre::Renderable* rend)
{
Ogre::Technique* generatedTech = NULL;
// Case this is the default shader generator scheme.
if (schemeName == Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME)
{
bool techniqueCreated;
// Create shader generated technique for this material.
techniqueCreated = mShaderGenerator->createShaderBasedTechnique(
originalMaterial->getName(),
Ogre::MaterialManager::DEFAULT_SCHEME_NAME,
schemeName);
// Case technique registration succeeded.
if (techniqueCreated)
{
// Force creating the shaders for the generated technique.
mShaderGenerator->validateMaterial(schemeName, originalMaterial->getName());
// Grab the generated technique.
Ogre::Material::TechniqueIterator itTech = originalMaterial->getTechniqueIterator();
while (itTech.hasMoreElements())
{
Ogre::Technique* curTech = itTech.getNext();
if (curTech->getSchemeName() == schemeName)
{
generatedTech = curTech;
break;
}
}
}
}
return generatedTech;
}
示例11: GetTextureNamesFromMaterial
void GetTextureNamesFromMaterial(Ogre::MaterialPtr material, StringVector& textures)
{
textures.clear();
if (material.isNull())
return;
// Use a set internally to avoid duplicates
std::set<std::string> textures_set;
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();
const std::string& texname = texUnit->getTextureName();
if (!texname.empty())
textures_set.insert(texname);
}
}
}
std::set<std::string>::iterator i = textures_set.begin();
while (i != textures_set.end())
{
textures.push_back(*i);
++i;
}
}
示例12: Animation
ActivatorAnimation::ActivatorAnimation(const MWWorld::Ptr &ptr)
: Animation(ptr)
{
MWWorld::LiveCellRef<ESM::Activator> *ref = mPtr.get<ESM::Activator>();
assert (ref->mBase != NULL);
if(!ref->mBase->mModel.empty())
{
std::string mesh = "meshes\\" + ref->mBase->mModel;
createEntityList(mPtr.getRefData().getBaseNode(), mesh);
for(size_t i = 0;i < mEntityList.mEntities.size();i++)
{
Ogre::Entity *ent = mEntityList.mEntities[i];
bool transparent = false;
for (unsigned int j=0;j < ent->getNumSubEntities() && !transparent; ++j)
{
Ogre::MaterialPtr mat = ent->getSubEntity(j)->getMaterial();
Ogre::Material::TechniqueIterator techIt = mat->getTechniqueIterator();
while (techIt.hasMoreElements() && !transparent)
{
Ogre::Technique* tech = techIt.getNext();
Ogre::Technique::PassIterator passIt = tech->getPassIterator();
while (passIt.hasMoreElements() && !transparent)
{
Ogre::Pass* pass = passIt.getNext();
if (pass->getDepthWriteEnabled() == false)
transparent = true;
}
}
}
ent->setVisibilityFlags(RV_Misc);
ent->setRenderQueueGroup(transparent ? RQG_Alpha : RQG_Main);
}
setAnimationSource(mesh);
}
}
示例13: unloadTheMesh
// unload all about this mesh. The mesh itself and the textures.
// BETWEEN FRAME OPERATION
void VisCalcFrustDist::unloadTheMesh(Ogre::MeshPtr meshP) {
if (m_shouldCullTextures) {
Ogre::Mesh::SubMeshIterator smi = meshP->getSubMeshIterator();
while (smi.hasMoreElements()) {
Ogre::SubMesh* oneSubMesh = smi.getNext();
Ogre::String subMeshMaterialName = oneSubMesh->getMaterialName();
Ogre::MaterialPtr subMeshMaterial = (Ogre::MaterialPtr)Ogre::MaterialManager::getSingleton().getByName(subMeshMaterialName);
if (!subMeshMaterial.isNull()) {
Ogre::Material::TechniqueIterator techIter = subMeshMaterial->getTechniqueIterator();
while (techIter.hasMoreElements()) {
Ogre::Technique* oneTech = techIter.getNext();
Ogre::Technique::PassIterator passIter = oneTech->getPassIterator();
while (passIter.hasMoreElements()) {
Ogre::Pass* onePass = passIter.getNext();
Ogre::Pass::TextureUnitStateIterator tusIter = onePass->getTextureUnitStateIterator();
while (tusIter.hasMoreElements()) {
Ogre::TextureUnitState* oneTus = tusIter.getNext();
Ogre::String texName = oneTus->getTextureName();
Ogre::TexturePtr texP = (Ogre::TexturePtr)Ogre::TextureManager::getSingleton().getByName(texName);
if (!texP.isNull()) {
// if (texP.useCount() <= 1) {
texP->unload();
LG::IncStat(LG::StatCullTexturesUnloaded);
// LG::Log("unloadTheMesh: unloading texture %s", texName.c_str());
// }
}
}
}
}
}
}
}
if (m_shouldCullMeshes) {
LG::OLMeshTracker::Instance()->MakeUnLoaded(meshP->getName(), Ogre::String(), NULL);
LG::IncStat(LG::StatCullMeshesUnloaded);
// LG::Log("unloadTheMesh: unloading mesh %s", mshName.c_str());
}
}
示例14: findFogPassesByName
void GroundFog::findFogPassesByName (const Ogre::String& passName) {
Ogre::MaterialManager *matManager = Ogre::MaterialManager::getSingletonPtr();
Ogre::MaterialManager::ResourceMapIterator matIt = matManager->getResourceIterator();
while (matIt.hasMoreElements()) {
#if (OGRE_VERSION < ((1 << 16) | (9 << 8) | 0))
Ogre::MaterialPtr mat = matIt.getNext();
#else
Ogre::MaterialPtr mat = matIt.getNext().staticCast<Ogre::Material>();
#endif
Ogre::Material::TechniqueIterator techIt = mat->getTechniqueIterator();
while (techIt.hasMoreElements()) {
Ogre::Technique *tech = techIt.getNext();
Ogre::Technique::PassIterator passIt = tech->getPassIterator();
while (passIt.hasMoreElements()) {
Ogre::Pass *pass = passIt.getNext();
if (pass->getName() == passName) {
mPasses.insert(pass);
}
}
}
}
forceUpdate();
}
示例15: SetData
//.........这里部分代码省略.........
}
std::string output_str = output.str();
Ogre::DataStreamPtr modified_data = Ogre::DataStreamPtr(new Ogre::MemoryDataStream((u8 *)(&output_str[0]), output_str.size()));
matmgr.parseScript(modified_data, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
Ogre::MaterialPtr tempmat;
tempmat = matmgr.getByName(tempname);
if (tempmat.isNull())
{
OgreRenderingModule::LogWarning(std::string("Failed to create an Ogre material from material asset ") +
source->GetId());
return false;
}
if(!tempmat->getNumTechniques())
{
OgreRenderingModule::LogWarning("Failed to create an Ogre material from material asset " +
source->GetId());
return false;
}
ogre_material_ = tempmat->clone(id_);
tempmat.setNull();
matmgr.remove(tempname);
if (ogre_material_.isNull())
{
OgreRenderingModule::LogWarning("Failed to create an Ogre material from material asset " +
source->GetId());
return false;
}
// Now go through all the texturenames and restore \ back to / and @ to :
Ogre::Material::TechniqueIterator iter = ogre_material_->getTechniqueIterator();
while (iter.hasMoreElements())
{
Ogre::Technique *tech = iter.getNext();
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();
std::string texname = texUnit->getTextureName();
if (texname.find('\\') != std::string::npos)
{
ReplaceCharInplace(texname, '\\', '/');
ReplaceCharInplace(texname, '@', ':');
texUnit->setTextureName(texname);
}
}
}
}
//workaround: if receives shadows, check the amount of shadowmaps. If only 1 specified, add 2 more to support 3 shadowmaps
if(ogre_material_->getReceiveShadows() && shadowquality_ == Shadows_High && ogre_material_->getNumTechniques() > 0)
{
Ogre::Technique *tech = ogre_material_->getTechnique(0);
if(tech)
{
Ogre::Technique::PassIterator passiterator = tech->getPassIterator();
while(passiterator.hasMoreElements())
{
Ogre::Pass* pass = passiterator.getNext();