本文整理汇总了C++中ogre::Technique::removeAllPasses方法的典型用法代码示例。如果您正苦于以下问题:C++ Technique::removeAllPasses方法的具体用法?C++ Technique::removeAllPasses怎么用?C++ Technique::removeAllPasses使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::Technique
的用法示例。
在下文中一共展示了Technique::removeAllPasses方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleSchemeNotFound
Ogre::Technique* GBufferSchemeHandler::handleSchemeNotFound(unsigned short schemeIndex,
const Ogre::String& schemeName, Ogre::Material* originalMaterial, unsigned short lodIndex,
const Ogre::Renderable* rend)
{
Ogre::MaterialManager& matMgr = Ogre::MaterialManager::getSingleton();
Ogre::String curSchemeName = matMgr.getActiveScheme();
matMgr.setActiveScheme(Ogre::MaterialManager::DEFAULT_SCHEME_NAME);
Ogre::Technique* originalTechnique = originalMaterial->getBestTechnique(lodIndex, rend);
matMgr.setActiveScheme(curSchemeName);
Ogre::Technique* gBufferTech = originalMaterial->createTechnique();
gBufferTech->removeAllPasses();
gBufferTech->setSchemeName(schemeName);
Ogre::Technique* noGBufferTech = originalMaterial->createTechnique();
noGBufferTech->removeAllPasses();
noGBufferTech->setSchemeName("NoGBuffer");
for (unsigned short i=0; i<originalTechnique->getNumPasses(); i++)
{
Ogre::Pass* originalPass = originalTechnique->getPass(i);
PassProperties props = inspectPass(originalPass, lodIndex, rend);
if (!props.isDeferred)
{
//Just copy the technique so it gets rendered regularly
Ogre::Pass* clonePass = noGBufferTech->createPass();
*clonePass = *originalPass;
continue;
}
Ogre::Pass* newPass = gBufferTech->createPass();
MaterialGenerator::Perm perm = getPermutation(props);
const Ogre::MaterialPtr& templateMat = mMaterialGenerator.getMaterial(perm);
//We assume that the GBuffer technique contains only one pass. But its true.
*newPass = *(templateMat->getTechnique(0)->getPass(0));
fillPass(newPass, originalPass, props);
}
return gBufferTech;
}
示例2: create
Ogre::MaterialPtr MaterialGenerator::create(bool renderCompositeMap, bool displayCompositeMap)
{
assert(!renderCompositeMap || !displayCompositeMap);
static int count = 0;
std::stringstream name;
name << "terrain/mat" << count++;
if (!mShaders)
{
Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().create(name.str(),
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
Ogre::Technique* technique = mat->getTechnique(0);
technique->removeAllPasses();
if (displayCompositeMap)
{
Ogre::Pass* pass = technique->createPass();
pass->setVertexColourTracking(Ogre::TVC_AMBIENT|Ogre::TVC_DIFFUSE);
pass->createTextureUnitState(mCompositeMap)->setTextureAddressingMode(Ogre::TextureUnitState::TAM_CLAMP);
}
else
{
assert(mLayerList.size() == mBlendmapList.size()+1);
std::vector<Ogre::TexturePtr>::iterator blend = mBlendmapList.begin();
for (std::vector<LayerInfo>::iterator layer = mLayerList.begin(); layer != mLayerList.end(); ++layer)
{
Ogre::Pass* pass = technique->createPass();
pass->setLightingEnabled(false);
pass->setVertexColourTracking(Ogre::TVC_NONE);
// TODO: How to handle fog?
pass->setFog(true, Ogre::FOG_NONE);
bool first = (layer == mLayerList.begin());
Ogre::TextureUnitState* tus;
if (!first)
{
pass->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
pass->setDepthFunction(Ogre::CMPF_EQUAL);
tus = pass->createTextureUnitState((*blend)->getName());
tus->setAlphaOperation(Ogre::LBX_BLEND_TEXTURE_ALPHA,
Ogre::LBS_TEXTURE,
Ogre::LBS_TEXTURE);
tus->setColourOperationEx(Ogre::LBX_BLEND_DIFFUSE_ALPHA,
Ogre::LBS_TEXTURE,
Ogre::LBS_TEXTURE);
tus->setIsAlpha(true);
tus->setTextureAddressingMode(Ogre::TextureUnitState::TAM_CLAMP);
float scale = (16/(16.f+1.f));
tus->setTextureScale(1.f/scale,1.f/scale);
}
// Add the actual layer texture on top of the alpha map.
tus = pass->createTextureUnitState(layer->mDiffuseMap);
if (!first)
tus->setColourOperationEx(Ogre::LBX_BLEND_DIFFUSE_ALPHA,
Ogre::LBS_TEXTURE,
Ogre::LBS_CURRENT);
tus->setTextureScale(1/16.f,1/16.f);
if (!first)
++blend;
}
if (!renderCompositeMap)
{
Ogre::Pass* lightingPass = technique->createPass();
lightingPass->setSceneBlending(Ogre::SBT_MODULATE);
lightingPass->setVertexColourTracking(Ogre::TVC_AMBIENT|Ogre::TVC_DIFFUSE);
lightingPass->setFog(true, Ogre::FOG_NONE);
}
}
return mat;
}
#if TERRAIN_USE_SHADER
else
{
sh::MaterialInstance* material = sh::Factory::getInstance().createMaterialInstance (name.str());
material->setProperty ("allow_fixed_function", sh::makeProperty<sh::BooleanValue>(new sh::BooleanValue(false)));
if (displayCompositeMap)
{
sh::MaterialInstancePass* p = material->createPass ();
p->setProperty ("vertex_program", sh::makeProperty<sh::StringValue>(new sh::StringValue("terrain_vertex")));
p->setProperty ("fragment_program", sh::makeProperty<sh::StringValue>(new sh::StringValue("terrain_fragment")));
p->mShaderProperties.setProperty ("is_first_pass", sh::makeProperty(new sh::BooleanValue(true)));
p->mShaderProperties.setProperty ("render_composite_map", sh::makeProperty(new sh::BooleanValue(false)));
p->mShaderProperties.setProperty ("display_composite_map", sh::makeProperty(new sh::BooleanValue(true)));
p->mShaderProperties.setProperty ("num_layers", sh::makeProperty (new sh::StringValue("0")));
p->mShaderProperties.setProperty ("num_blendmaps", sh::makeProperty (new sh::StringValue("0")));
p->mShaderProperties.setProperty ("normal_map_enabled", sh::makeProperty (new sh::BooleanValue(false)));
p->mShaderProperties.setProperty ("parallax_enabled", sh::makeProperty (new sh::BooleanValue(false)));
p->mShaderProperties.setProperty ("normal_maps",
//.........这里部分代码省略.........
示例3: createActions
//.........这里部分代码省略.........
mNodeEditor->addNode(mMaterialNode);
}
}
//****************************************************************************/
void EditorDockWidget::doTechniqueHToolbarAction(void)
{
// Add a technique node
Magus::QtNodeTechnique* techniqueNode = new Magus::QtNodeTechnique(NODE_TITLE_TECHNIQUE);
mNodeEditor->addNode(techniqueNode);
}
//****************************************************************************/
void EditorDockWidget::doPassHToolbarAction(void)
{
// Add a pass node
Magus::QtNodePass* passNode = new Magus::QtNodePass(NODE_TITLE_PASS);
mNodeEditor->addNode(passNode);
}
//****************************************************************************/
void EditorDockWidget::doTextureHToolbarAction(void)
{
// Add a texture unit node
Magus::QtNodeTextureUnit* textureUnitNode = new Magus::QtNodeTextureUnit(NODE_TITLE_TEXTURE_UNIT);
mNodeEditor->addNode(textureUnitNode);
}
//****************************************************************************/
void EditorDockWidget::doCogHToolbarAction(void)
{
if (!mMaterialNode)
return;
if (mMaterialNode->getMaterialName().isEmpty())
return;
// ---------------------------------------- Create a material ----------------------------------------
Ogre::LogManager* logManager = Ogre::LogManager::getSingletonPtr();
Ogre::MaterialManager* materialManager = Ogre::MaterialManager::getSingletonPtr();
Ogre::String materialName = mMaterialNode->getMaterialName().toStdString(); // Convert to std format
logManager->logMessage("SME: create Ogre material: " + materialName);
Ogre::MaterialPtr material = materialManager->create(materialName, "General");
// Remark: Sceneblending is done for each pass individually, although it is defined on material level
// ---------------------------------------- Add the technique ----------------------------------------
Magus::QtNode* node = mMaterialNode->getNodeConnectedToPort(PORT_TECHNIQUE_OUT);
if (!node)
{
logManager->logMessage("SME: No technique node available");
return;
}
Magus::QtNodeTechnique* techniqueNode = static_cast<Magus::QtNodeTechnique*>(node);
material->removeAllTechniques();
Ogre::Technique* technique = material->createTechnique();
technique->removeAllPasses();
logManager->logMessage("SME: Technique created" + Ogre::StringConverter::toString(material->getNumTechniques()));
// ---------------------------------------- Add the passes ----------------------------------------
Magus::QtNodePass* passNode;
Magus::QtNodeTextureUnit* textureUnitNode;
Ogre::Pass* pass;
Ogre::TextureUnitState* textureUnit;
for (unsigned int i = 1; i < 5; ++i)
{
node = techniqueNode->getNodeConnectedToPort(PORT_PASS_OUT, i); // node with the same name
if (node)
{
passNode = static_cast<Magus::QtNodePass*>(node);
pass = technique->createPass();
pass->removeAllTextureUnitStates();
logManager->logMessage("SME: Pass on port nr. " + Ogre::StringConverter::toString(i) + " created");
propagatePassNodeData(passNode, pass);
// ---------------------------------------- Add the texture units ----------------------------------------
for (unsigned int j = 1; j < 9; ++j)
{
node = passNode->getNodeConnectedToPort(PORT_TEXTURE_OUT, j);
if (node)
{
logManager->logMessage("SME: Texture unit on port nr. " +
Ogre::StringConverter::toString(j) +
" of Pass port nr. " +
Ogre::StringConverter::toString(i) +
" created");
textureUnitNode = static_cast<Magus::QtNodeTextureUnit*>(node);
textureUnit = pass->createTextureUnitState();
propagateTextureUnitNodeData(textureUnitNode, textureUnit);
}
}
}
}
// Assign the material to the ogrehead
material->compile();
material->load();
mParent->getOgreManager()->getOgreWidget(1)->mEntity->setMaterial(material);
}