本文整理汇总了C++中material::TechniqueIterator::hasMoreElements方法的典型用法代码示例。如果您正苦于以下问题:C++ TechniqueIterator::hasMoreElements方法的具体用法?C++ TechniqueIterator::hasMoreElements怎么用?C++ TechniqueIterator::hasMoreElements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类material::TechniqueIterator
的用法示例。
在下文中一共展示了TechniqueIterator::hasMoreElements方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: correctAlpha
//--------------------------------------------------------------------------------
void MaterialUtil::correctAlpha(const MaterialPtr& _material)
{
if(isPortal(_material) || isGhostOccluder(_material))
{
// create fully transparent material
Material::TechniqueIterator it = _material->getTechniqueIterator();
while(it.hasMoreElements())
{
Technique* technique = it.getNext();
Technique::PassIterator it2 = technique->getPassIterator();
while(it2.hasMoreElements())
{
Pass* pass = it2.getNext();
pass->setAlphaRejectFunction(Ogre::CMPF_ALWAYS_FAIL);
}
}
}
else
{
Material::TechniqueIterator it = _material->getTechniqueIterator();
while(it.hasMoreElements())
{
Technique* technique = it.getNext();
Technique::PassIterator it2 = technique->getPassIterator();
while(it2.hasMoreElements())
{
Pass* pass = it2.getNext();
pass->setAlphaRejectFunction(Ogre::CMPF_GREATER);
pass->setAlphaRejectValue(220);
}
}
_material->setReceiveShadows(true);
}
}
示例2: setShadowsEnabled
void MaterialFactory::setShadowsEnabled(bool bEnable)
{
for (std::vector<MaterialDefinition*>::iterator it=mDefinitions.begin();
it!=mDefinitions.end(); ++it)
{
MaterialPtr mat = MaterialManager::getSingleton().getByName( (*it)->getName() );
if (mat.isNull()) continue;
Material::TechniqueIterator techIt = mat->getTechniqueIterator();
while (techIt.hasMoreElements())
{
Technique* tech = techIt.getNext();
Technique::PassIterator passIt = tech->getPassIterator();
while (passIt.hasMoreElements())
{
Pass* pass = passIt.getNext();
if (pass->hasFragmentProgram())
{
if ( pass->getFragmentProgramParameters()->_findNamedConstantDefinition("enableShadows", false))
pass->getFragmentProgramParameters()->setNamedConstant("enableShadows", Real(bEnable));
}
}
}
}
}
示例3: ChangeClr
void CarModel::ChangeClr()
{
int i = iColor;
float c_h = pSet->gui.car_hue[i], c_s = pSet->gui.car_sat[i],
c_v = pSet->gui.car_val[i], gloss = pSet->gui.car_gloss[i], refl = pSet->gui.car_refl[i];
color.setHSB(1-c_h, c_s, c_v); //set, mini pos clr
MaterialPtr mtr = MaterialManager::getSingleton().getByName(sMtr[Mtr_CarBody]);
if (!mtr.isNull())
{ Material::TechniqueIterator techIt = mtr->getTechniqueIterator();
while (techIt.hasMoreElements())
{ Technique* tech = techIt.getNext();
Technique::PassIterator passIt = tech->getPassIterator();
while (passIt.hasMoreElements())
{ Pass* pass = passIt.getNext();
if (pass->hasFragmentProgram())
{
GpuProgramParametersSharedPtr params = pass->getFragmentProgramParameters();
params->setNamedConstant("carColour", color);
params->setNamedConstant("glossiness", 1 - gloss);
params->setNamedConstant("reflectiveness", refl);
} } } }
if (pNickTxt)
pNickTxt->setTextColour(MyGUI::Colour(color.r,color.g,color.b));
// opp list text and mini pos colors - auto in hud update
}
示例4: setColor
void MaterialInstance::setColor(float red, float green, float blue, float alpha)
{
if (mCopyMat.isNull ()) {
createCopyMaterial ();
}
unsigned short i = 0, j;
ColourValue sc, dc; // Source colur, destination colour
Material::TechniqueIterator techniqueIt = mCopyMat->getTechniqueIterator ();
while (techniqueIt.hasMoreElements ())
{
Technique *t = techniqueIt.getNext ();
Technique::PassIterator passIt = t->getPassIterator ();
j = 0;
while (passIt.hasMoreElements ())
{
sc = mOriginalMat->getTechnique (i)->getPass (j)->getDiffuse ();
dc = sc;
dc.a = alpha;
dc.r = red;
dc.g = green;
dc.b = blue;
passIt.peekNext ()->setAmbient (mOriginalMat->getTechnique (i)->getPass (j)->getAmbient ());
passIt.peekNext ()->setDiffuse (dc);
passIt.moveNext ();
++j;
}
++i;
}
}
示例5: ChangeOriginalMaterial
void MaterialInstance::ChangeOriginalMaterial()
{
if (mCopyMat.isNull ()) {
createCopyMaterial ();
}
unsigned short i = 0, j;
ColourValue sc, dc; // Source colur, destination colour
Material::TechniqueIterator techniqueIt = mCopyMat->getTechniqueIterator ();
while (techniqueIt.hasMoreElements ())
{
Technique *t = techniqueIt.getNext ();
Technique::PassIterator passIt = t->getPassIterator ();
j = 0;
while (passIt.hasMoreElements ())
{
sc = mOriginalMat->getTechnique (i)->getPass (j)->getDiffuse ();
passIt.peekNext ()->setAmbient (mOriginalMat->getTechnique (i)->getPass (j)->getAmbient ());
passIt.peekNext ()->setDiffuse (sc);
passIt.moveNext ();
++j;
}
++i;
}
}
示例6: setSceneBlending
void MaterialInstance::setSceneBlending (SceneBlendType sbt) {
mSBT = sbt;
if (!mCopyMat.isNull ()) {
Material::TechniqueIterator techniqueIt = mCopyMat->getTechniqueIterator ();
while (techniqueIt.hasMoreElements ()) {
Technique *t = techniqueIt.getNext ();
Technique::PassIterator passIt = t->getPassIterator ();
while (passIt.hasMoreElements ()) {
passIt.getNext ()->setSceneBlending (mSBT);
}
}
}
}
示例7: setTransparency
void MaterialInstance::setTransparency (Real transparency) {
mCurrentTransparency = transparency;
if (mCurrentTransparency > 0.0f) {
if (mCurrentTransparency > 1.0f)
mCurrentTransparency = 1.0f;
if (mCopyMat.isNull ()) {
createCopyMaterial ();
}
unsigned short i = 0, j;
ColourValue sc, dc; // Source colur, destination colour
Material::TechniqueIterator techniqueIt = mCopyMat->getTechniqueIterator ();
while (techniqueIt.hasMoreElements ()) {
Technique *t = techniqueIt.getNext ();
Technique::PassIterator passIt = t->getPassIterator ();
j = 0;
while (passIt.hasMoreElements ()) {
sc = mOriginalMat->getTechnique (i)->getPass (j)->getDiffuse ();
switch (mSBT) {
case SBT_ADD:
dc = sc;
dc.r -= sc.r * mCurrentTransparency;
dc.g -= sc.g * mCurrentTransparency;
dc.b -= sc.b * mCurrentTransparency;
passIt.peekNext ()->setAmbient (ColourValue::Black);
break;
case SBT_TRANSPARENT_ALPHA:
default:
dc = sc;
dc.a = sc.a * (1.0f - mCurrentTransparency);
passIt.peekNext ()->setAmbient (mOriginalMat->getTechnique (i)->getPass (j)->getAmbient ());
break;
}
passIt.peekNext ()->setDiffuse (dc);
passIt.moveNext ();
++j;
}
++i;
}
}
else {
mCurrentTransparency = 0.0f;
}
}
示例8: createCopyMaterial
void MaterialInstance::createCopyMaterial () {
String name;
// Avoid name collision
do {
name = mOriginalMat->getName () + StringConverter::toString (Math::UnitRandom ());
} while (MaterialManager::getSingleton ().resourceExists (name));
mCopyMat = mOriginalMat->clone (name);
Material::TechniqueIterator techniqueIt = mCopyMat->getTechniqueIterator ();
while (techniqueIt.hasMoreElements ()) {
Technique *t = techniqueIt.getNext ();
Technique::PassIterator passIt = t->getPassIterator ();
while (passIt.hasMoreElements ()) {
passIt.peekNext ()->setDepthWriteEnabled (false);
passIt.peekNext ()->setSceneBlending (mSBT);
passIt.moveNext ();
}
}
}
示例9: UpdateLightMap
//-------------------------------------------------------------------------------------------------------
// utility
//-------------------------------------------------------------------------------------------------------
void CarModel::UpdateLightMap()
{
MaterialPtr mtr;
for (int i=0; i < NumMaterials; ++i)
{
mtr = MaterialManager::getSingleton().getByName(sMtr[i]);
if (!mtr.isNull())
{ Material::TechniqueIterator techIt = mtr->getTechniqueIterator();
while (techIt.hasMoreElements())
{ Technique* tech = techIt.getNext();
Technique::PassIterator passIt = tech->getPassIterator();
while (passIt.hasMoreElements())
{ Pass* pass = passIt.getNext();
if (pass->hasFragmentProgram())
{
GpuProgramParametersSharedPtr params = pass->getFragmentProgramParameters();
params->setIgnoreMissingParams(true); // don't throw exception if material doesnt use lightmap
params->setNamedConstant("enableTerrainLightMap", bLightMapEnabled ? 1.f : 0.f);
} } } } }
}
示例10: subEntityAction
//===========================================================================
// MaterialPassAction
//===========================================================================
void IMaterialPassAction::subEntityAction( SubEntityMaterial* subEntity ) const
{
if( !subEntity->getMaterial().isNull() )
{
unsigned short i = 0 ;
for( Material::TechniqueIterator techniqueIt = subEntity->getMaterial()->getTechniqueIterator() ;
techniqueIt.hasMoreElements() ;
techniqueIt.moveNext(), ++i )
{
Technique* techniqueScr = subEntity->getMaterial()->getTechnique( i ) ;
unsigned short j = 0;
for( Technique::PassIterator passIt = techniqueIt.peekNext()->getPassIterator ();
passIt.hasMoreElements() ;
passIt.moveNext(), ++j )
{
passAction( subEntity, passIt.peekNext(), techniqueScr->getPass( j ) ) ;
}
}
}
}
示例11: UpdateBraking
void CarModel::UpdateBraking()
{
if (brakes)
brakes->setVisible(bBraking && mbVisible);
std::string texName = sDirname + (bBraking ? "_body00_brake.png" : "_body00_add.png");
MaterialPtr mtr = MaterialManager::getSingleton().getByName(sMtr[Mtr_CarBody]);
if (!mtr.isNull())
{ Material::TechniqueIterator techIt = mtr->getTechniqueIterator();
while (techIt.hasMoreElements())
{ Technique* tech = techIt.getNext();
Technique::PassIterator passIt = tech->getPassIterator();
while (passIt.hasMoreElements())
{ Pass* pass = passIt.getNext();
Pass::TextureUnitStateIterator tusIt = pass->getTextureUnitStateIterator();
while (tusIt.hasMoreElements())
{
TextureUnitState* tus = tusIt.getNext();
if (tus->getName() == "diffuseMap")
{ tus->setTextureName( texName ); return; }
} } } }
}
示例12: update
void MaterialFactory::update()
{
for (std::vector<std::string>::const_iterator it = timeMtrs.begin();
it != timeMtrs.end(); ++it)
{
MaterialPtr mtr = MaterialManager::getSingleton().getByName( (*it) );
if (!mtr.isNull())
{ Material::TechniqueIterator techIt = mtr->getTechniqueIterator();
while (techIt.hasMoreElements())
{ Technique* tech = techIt.getNext();
Technique::PassIterator passIt = tech->getPassIterator();
while (passIt.hasMoreElements())
{ Pass* pass = passIt.getNext();
// time
if (pass->hasFragmentProgram() && pass->getFragmentProgramParameters()->_findNamedConstantDefinition("time", false))
pass->getFragmentProgramParameters()->setNamedConstantFromTime( "time", 1 );
}
}
}
}
}
示例13: isPotentialOccluder
bool OcclusionQuery::isPotentialOccluder(Ogre::SceneNode* node)
{
bool result = false;
for (unsigned int i=0; i < node->numAttachedObjects(); ++i)
{
MovableObject* ob = node->getAttachedObject(i);
std::string type = ob->getMovableType();
if (type == "Entity")
{
Entity* ent = static_cast<Entity*>(ob);
for (unsigned int j=0; j < ent->getNumSubEntities(); ++j)
{
// if any sub entity has a material with depth write off,
// consider the object as not an occluder
MaterialPtr mat = ent->getSubEntity(j)->getMaterial();
Material::TechniqueIterator techIt = mat->getTechniqueIterator();
while (techIt.hasMoreElements())
{
Technique* tech = techIt.getNext();
Technique::PassIterator passIt = tech->getPassIterator();
while (passIt.hasMoreElements())
{
Pass* pass = passIt.getNext();
if (pass->getDepthWriteEnabled() == false)
return false;
else
result = true;
}
}
}
}
}
return result;
}
示例14: setShaderParams
void MaterialFactory::setShaderParams(MaterialPtr mat)
{
if (mat.isNull()) return;
Material::TechniqueIterator techIt = mat->getTechniqueIterator();
while (techIt.hasMoreElements())
{
Technique* tech = techIt.getNext();
Technique::PassIterator passIt = tech->getPassIterator();
while (passIt.hasMoreElements())
{
Pass* pass = passIt.getNext();
if (pass->hasFragmentProgram())
{
// shadow fading parameters
if ( getShadowsFade()
&& pass->getFragmentProgramParameters()->_findNamedConstantDefinition("fadeStart_farDist", false)
&& mSceneMgr
)
{
float fadeDist;
if (mSceneMgr->getShadowFarDistance() != 0)
fadeDist = getShadowsFadeDistance()/mSceneMgr->getShadowFarDistance();
else
fadeDist = 0.f;
pass->getFragmentProgramParameters()->setNamedConstant("fadeStart_farDist", Vector3(
fadeDist,
mSceneMgr->getShadowFarDistance(),
float(getShadowsFade())
));
}
// terrain lightmap name & size
if ( mTerrain && !mTerrain->getLightmap().isNull() )
{
if (pass->getFragmentProgramParameters()->_findNamedConstantDefinition("terrainWorldSize", false))
pass->getFragmentProgramParameters()->setNamedConstant( "terrainWorldSize", Real( mTerrain->getWorldSize() ) );
Pass::TextureUnitStateIterator tusIt = pass->getTextureUnitStateIterator();
while (tusIt.hasMoreElements())
{
TextureUnitState* tus = tusIt.getNext();
if (tus->getName() == "terrainLightMap")
{
tus->setTextureName( mTerrain->getLightmap()->getName() );
}
}
}
if (pass->getFragmentProgramParameters()->_findNamedConstantDefinition("invTerSize", false))
pass->getFragmentProgramParameters()->setNamedConstant("invTerSize", 1.f / Real(pApp->sc.td.fTerWorldSize));
// pssm split points
if ( pass->getFragmentProgramParameters()->_findNamedConstantDefinition("pssmSplitPoints", false) && mPSSM)
{
const PSSMShadowCameraSetup::SplitPointList& splitPointList = mPSSM->getSplitPoints();
Vector4 splitPoints;
for (size_t i = 0; i < splitPointList.size(); ++i)
splitPoints[i] = splitPointList[i];
pass->getFragmentProgramParameters()->setNamedConstant("pssmSplitPoints", splitPoints);
}
}
}
}
}
示例15: changeShadows
//.........这里部分代码省略.........
OverlayContainer* debugPanel;
// destroy container if exists
try
{
if (debugPanel =
static_cast<OverlayContainer*>(
mgr.getOverlayElement("Ogre/DebugTexPanel" + toStr(i)
)))
mgr.destroyOverlayElement(debugPanel);
}
catch (Ogre::Exception&) {}
debugPanel = (OverlayContainer*)
(OverlayManager::getSingleton().createOverlayElement("Panel", "Ogre/DebugTexPanel" + StringConverter::toString(i)));
debugPanel->_setPosition(0.8, i*0.25);
debugPanel->_setDimensions(0.2, 0.24);
debugPanel->setMaterialName(debugMat->getName());
debugPanel->show();
overlay->add2D(debugPanel);
overlay->show();
}
#endif
}
materialFactory->setNumShadowTex(num);
materialFactory->setShadows(pSet->shadow_type != 0);
materialFactory->setShadowsDepth(bDepth);
materialFactory->generate();
// set terrain lightmap texture and terrainWorldSize for all materials that need it
if (terrain) // naive check if a game has been started already
{
for (std::vector<std::string>::const_iterator it = materialFactory->terrainLightMapMtrs.begin();
it != materialFactory->terrainLightMapMtrs.end(); ++it)
{
MaterialPtr mtr = MaterialManager::getSingleton().getByName( (*it) );
if (!mtr.isNull())
{ Material::TechniqueIterator techIt = mtr->getTechniqueIterator();
while (techIt.hasMoreElements())
{ Technique* tech = techIt.getNext();
Technique::PassIterator passIt = tech->getPassIterator();
while (passIt.hasMoreElements())
{ Pass* pass = passIt.getNext();
Pass::TextureUnitStateIterator tusIt = pass->getTextureUnitStateIterator();
while (tusIt.hasMoreElements())
{
TextureUnitState* tus = tusIt.getNext();
if (tus->getName() == "terrainLightMap")
{
tus->setTextureName( terrain->getLightmap()->getName() );
pass->getFragmentProgramParameters()->setNamedConstant( "terrainWorldSize", Real( sc.td.fTerWorldSize ) );
}
}
} } }
}
}
// ------------------- update the paged-geom materials
// grass is not cloned, just need to set new shader parameters
if (grass)
{
GrassLoader *grassLoader = static_cast<GrassLoader*>(grass->getPageLoader());
for (std::list<GrassLayer*>::iterator it= grassLoader->getLayerList().begin();
it != grassLoader->getLayerList().end(); ++it)
{
GrassLayer* layer = (*it);
layer->applyShader();
}
}
// trees are more complicated since they are cloned
if(trees)
{
trees->reloadGeometry();
std::vector<ResourcePtr> reosurceToDelete;
ResourceManager::ResourceMapIterator it = MaterialManager::getSingleton().getResourceIterator();
while (it.hasMoreElements())
{
ResourcePtr material = it.getNext();
String materialName = material->getName();
std::string::size_type pos =materialName.find("BatchMat|");
if( pos != std::string::npos ) {
reosurceToDelete.push_back(material);
}
}
for(int i=0;i<reosurceToDelete.size();i++)
{
MaterialManager::getSingleton().remove(reosurceToDelete[i]);
}
}
UpdPSSMMaterials();
ti.update(); /// time
float dt = ti.dt * 1000.f;
LogO(String("::: Time Shadows: ") + toStr(dt) + " ms");
}