本文整理汇总了C++中ogre::Technique::getNumPasses方法的典型用法代码示例。如果您正苦于以下问题:C++ Technique::getNumPasses方法的具体用法?C++ Technique::getNumPasses怎么用?C++ Technique::getNumPasses使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::Technique
的用法示例。
在下文中一共展示了Technique::getNumPasses方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rotateTexture
//-----------------------------------------------------------------------
void PrimitiveShapeSet::rotateTexture(Ogre::Real speed)
{
// Get the material and rotate it, assume the material is loaded already, otherwise skip.
Ogre::MaterialPtr material = getMaterial();
if (material.isNull())
return;
Ogre::TextureUnitState::EffectMap::const_iterator it;
unsigned short numberOfTechniques = material->getNumTechniques();
for (unsigned short u = 0; u < numberOfTechniques; ++u)
{
Ogre::Technique* technique = material->getTechnique(u);
unsigned short numberOfPasses = technique->getNumPasses();
for (unsigned short v = 0; v < numberOfPasses; ++v)
{
Ogre::Pass* pass = technique->getPass(v);
unsigned short numberOfTextureUnitStates = pass->getNumTextureUnitStates();
for (unsigned short w = 0; w < numberOfTextureUnitStates; ++w)
{
// Set the rotation if not already available.
// This can only be done once! Changing the rotationspeed or removing the rotation
// and resetting it doesn´t seem to work.
Ogre::TextureUnitState* textureUnitState = pass->getTextureUnitState(w);
it = textureUnitState->getEffects().find(Ogre::TextureUnitState::ET_ROTATE);
if (it == textureUnitState->getEffects().end())
{
textureUnitState->setRotateAnimation(speed);
}
}
}
}
}
示例2: _rotateTexture
//-----------------------------------------------------------------------
void EntityRenderer::_rotateTexture(VisualParticle* particle, Ogre::Entity* entity)
{
Ogre::TextureUnitState::EffectMap::const_iterator it;
// Get the material and rotate it
unsigned int numberOfSubEntities = entity->getNumSubEntities();
for (unsigned short u = 0; u < numberOfSubEntities; ++u)
{
Ogre::MaterialPtr material = entity->getSubEntity(u)->getMaterial();
unsigned short numberOfTechniques = material->getNumTechniques();
for (unsigned short v = 0; v < numberOfTechniques; ++v)
{
Ogre::Technique* technique = material->getTechnique(v);
unsigned short numberOfPasses = technique->getNumPasses();
for (unsigned short w = 0; w < numberOfPasses; ++w)
{
Ogre::Pass* pass = technique->getPass(w);
unsigned short numberOfTextureUnitStates = pass->getNumTextureUnitStates();
for (unsigned short x = 0; x < numberOfTextureUnitStates; ++x)
{
// Set the rotation if not already available.
// This can only be done once! Changing the rotationspeed or removing the rotation
// and resetting it doesn´t seem to work.
Ogre::TextureUnitState* textureUnitState = pass->getTextureUnitState(x);
it = textureUnitState->getEffects().find(Ogre::TextureUnitState::ET_ROTATE);
if (it == textureUnitState->getEffects().end())
{
textureUnitState->setRotateAnimation((particle->zRotationSpeed.valueRadians()));
}
}
}
}
}
}
示例3: updateFromCamera
void DeferredLight::updateFromCamera(Ogre::Camera* camera)
{
const Ogre::MaterialPtr& mat = getMaterial();
if (!mat->isLoaded())
{
mat->load();
}
Ogre::Technique* tech = mat->getBestTechnique();
Ogre::Vector3 farCorner = camera->getViewMatrix(true) * camera->getWorldSpaceCorners()[4];
for (unsigned short i=0; i<tech->getNumPasses(); i++)
{
Ogre::Pass* pass = tech->getPass(i);
Ogre::GpuProgramParametersSharedPtr params = pass->getVertexProgramParameters();
if (params->_findNamedConstantDefinition("farCorner"))
params->setNamedConstant("farCorner", farCorner);
params = pass->getFragmentProgramParameters();
if (params->_findNamedConstantDefinition("farCorner"))
params->setNamedConstant("farCorner", farCorner);
// If inside light geometry, render back faces with CMPF_GREATER, otherwise normally
if (mParentLight->getType() == Ogre::Light::LT_DIRECTIONAL)
{
pass->setCullingMode(Ogre::CULL_CLOCKWISE);
pass->setDepthCheckEnabled(false);
}
else
{
pass->setDepthCheckEnabled(true);
if (isCameraInsideLight(camera))
{
pass->setCullingMode(Ogre::CULL_ANTICLOCKWISE);
pass->setDepthFunction(Ogre::CMPF_GREATER_EQUAL);
}
else
{
pass->setCullingMode(Ogre::CULL_CLOCKWISE);
pass->setDepthFunction(Ogre::CMPF_LESS_EQUAL);
}
}
Ogre::Camera shadowCam("ShadowCameraSetupCam", 0);
shadowCam._notifyViewport(camera->getViewport());
Ogre::SceneManager* sm = mParentLight->_getManager();
sm->getShadowCameraSetup()->getShadowCamera(sm,
camera, camera->getViewport(), mParentLight, &shadowCam, 0);
//Get the shadow camera position
if (params->_findNamedConstantDefinition("shadowCamPos"))
{
params->setNamedConstant("shadowCamPos", shadowCam.getPosition());
}
if (params->_findNamedConstantDefinition("shadowFarClip"))
{
params->setNamedConstant("shadowFarClip", shadowCam.getFarClipDistance());
}
}
}
示例4: setChangeWorldFactor
void RenderComponentBillboardSet::setChangeWorldFactor(double factor)
{
Ogre::Technique * technique;
Ogre::GpuProgramParametersSharedPtr params;
Ogre::Pass * pass;
Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().getByName(mChangeWorldMaterial);
if(material.get())
{
technique= material->getTechnique(0);
if(technique)
{
if(technique->getNumPasses()>0)
{
pass=technique->getPass(0);
if(pass->hasFragmentProgram())
{
params=pass->getFragmentProgramParameters();
if(params.get())
{
params->setNamedConstant("mix_factor",Ogre::Real(factor));
}
}
}
}
}
}
示例5: setColour
void BillboardObject::setColour(const ColourValue& pColour)
{
mColour = pColour;
Ogre::MaterialPtr m = static_cast<sh::OgreMaterial*>(mMaterial->getMaterial ())->getOgreMaterial ();
for (int i=0; i<m->getNumTechniques(); ++i)
{
Ogre::Technique* t = m->getTechnique(i);
if (t->getNumPasses ())
t->getPass(0)->setSelfIllumination (pColour);
}
}
示例6: setVisibility
void BillboardObject::setVisibility(const float visibility)
{
mVisibility = visibility;
Ogre::MaterialPtr m = static_cast<sh::OgreMaterial*>(mMaterial->getMaterial ())->getOgreMaterial ();
for (int i=0; i<m->getNumTechniques(); ++i)
{
Ogre::Technique* t = m->getTechnique(i);
if (t->getNumPasses ())
t->getPass(0)->setDiffuse (0,0,0, visibility);
}
}
示例7: populateWorkSpaceTree
void MainWindow::populateWorkSpaceTree(const QStringList &itemNames)
{
for(int count = 0; count < itemNames.size(); ++count)
{
QTreeWidgetItem *matItem = new QTreeWidgetItem(ui->workspaceTree);
QString parentName = itemNames.at(count);
matItem->setText(0, parentName);
matItem->setText(1, "material");
Ogre::MaterialPtr parMat = Ogre::MaterialManager::getSingleton().getByName(parentName.toStdString());
unsigned short numTech = parMat.getPointer()->getNumTechniques();
for (int countTech = 0; countTech < numTech; ++countTech)
{
Ogre::Technique *parTech = parMat.getPointer()->getTechnique(countTech);
int numPass = parTech->getNumPasses();
QTreeWidgetItem *techItem = new QTreeWidgetItem(matItem);
techItem->setText(0, QString("technique(")+QString(Ogre::String(parTech->getName()).c_str())+QString(")"));
for (int countPass = 0; countPass < numPass; ++countPass)
{
QTreeWidgetItem *passItem = new QTreeWidgetItem(techItem);
Ogre::Pass* pass = parTech->getPass(countPass);
passItem->setText(0, QString("pass(")+QString(Ogre::String(pass->getName()).c_str())+QString(")"));
passItem->setText(1, QString("pass"));
if(pass->hasVertexProgram())
{
QTreeWidgetItem *vpItem = new QTreeWidgetItem(passItem);
vpItem->setText(0,Ogre::String(pass->getVertexProgramName()).c_str());
vpItem->setText(1,QString("VertexProgram"));
vpItem->setText(2,QString(parentName));
vpItem->setText(3,QString(countTech));
vpItem->setText(4,QString(countPass));
}
if(pass->hasFragmentProgram())
{
QTreeWidgetItem *fpItem = new QTreeWidgetItem(passItem);
fpItem->setText(0,Ogre::String(pass->getFragmentProgramName()).c_str());
fpItem->setText(1,QString("FragmentProgram"));
fpItem->setText(2,QString(parentName));
fpItem->setText(3,QString(countTech));
fpItem->setText(4,QString(countPass));
}
if(pass->hasGeometryProgram())
{
QTreeWidgetItem *gpItem = new QTreeWidgetItem(passItem);
gpItem->setText(0,Ogre::String(pass->getGeometryProgramName()).c_str());
}
}
}
}
}
示例8: 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));
}
示例9: selectMaterial
//-----------------------------------------------------------------------
void MaterialTab::selectMaterial(wxString& materialName)
{
Ogre::TextureUnitState* textureUnitState = 0;
mTxtMaterialName->SetValue(materialName);
if (isSelectedMaterialInUse())
{
mTxtMaterialName->Disable();
}
else
{
mTxtMaterialName->Enable();
}
mLastSelectedMaterial = materialName;
Ogre::String name = wx2ogre(materialName);
Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().getByName(name);
if (!material.isNull() && material->getNumTechniques() > 0)
{
material->load();
mTxtTextureLoad->SetValue(wxT(""));
Ogre::Technique* technique = material->getBestTechnique(); // Get the best technique
if (technique && technique->getNumPasses() > 0)
{
Ogre::Pass* pass = technique->getPass(0); // Get the first
if (pass)
{
// Set pass properties
mCheckLighting->SetValue(pass->getLightingEnabled());
mCheckDepthCheck->SetValue(pass->getDepthCheckEnabled());
mCheckDepthWrite->SetValue(pass->getDepthWriteEnabled());
mSceneBlendList->SetValue(getSceneBlending(pass));
if (pass->getNumTextureUnitStates() > 0)
{
textureUnitState = pass->getTextureUnitState(0); // Get the first
if (textureUnitState)
{
// Set texture properties
if (textureUnitState->getNumFrames() > 0)
{
wxString name = ogre2wx(textureUnitState->getFrameTextureName(0));
mTxtTextureLoad->SetValue(name);
}
mAddressingModeList->SetValue(getTextureAddressingMode(textureUnitState));
}
}
}
}
}
// Display image
viewTexture(textureUnitState); // Clear the old texture if no TextureUnitState
}
示例10: getFirstPass
//-----------------------------------------------------------------------
Ogre::Pass* MaterialTab::getFirstPass(void)
{
wxString materialName = mMaterialListBox->GetStringSelection();
Ogre::String name = wx2ogre(materialName);
Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().getByName(name);
if (!material.isNull() && material->getNumTechniques() > 0)
{
Ogre::Technique* technique = 0;
material->load();
technique = material->getBestTechnique(); // Get the best technique
if (technique && technique->getNumPasses() > 0)
{
return technique->getPass(0); // Get the first
}
}
return 0;
}
示例11: updateFromCamera
void AmbientLight::updateFromCamera(Ogre::Camera* camera)
{
Ogre::Technique* tech = getMaterial()->getBestTechnique();
Ogre::Vector3 farCorner = camera->getViewMatrix(true) * camera->getWorldSpaceCorners()[4];
for (unsigned short i=0; i<tech->getNumPasses(); i++)
{
Ogre::Pass* pass = tech->getPass(i);
// get the vertex shader parameters
Ogre::GpuProgramParametersSharedPtr params = pass->getVertexProgramParameters();
// set the camera's far-top-right corner
if (params->_findNamedConstantDefinition("farCorner"))
params->setNamedConstant("farCorner", farCorner);
params = pass->getFragmentProgramParameters();
if (params->_findNamedConstantDefinition("farCorner"))
params->setNamedConstant("farCorner", farCorner);
}
}
示例12: 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;
}
示例13:
void RoR::SkinManager::ReplaceMaterialTextures(SkinDef* skin_def, std::string materialName) // Static
{
const auto not_found = skin_def->replace_textures.end();
Ogre::MaterialPtr mat = RoR::OgreSubsystem::GetMaterialByName(materialName);
if (!mat.isNull())
{
for (int t = 0; t < mat->getNumTechniques(); t++)
{
Ogre::Technique* tech = mat->getTechnique(0);
if (!tech)
continue;
for (int p = 0; p < tech->getNumPasses(); p++)
{
Ogre::Pass* pass = tech->getPass(p);
if (!pass)
continue;
for (int tu = 0; tu < pass->getNumTextureUnitStates(); tu++)
{
Ogre::TextureUnitState* tus = pass->getTextureUnitState(tu);
if (!tus)
continue;
//if (tus->getTextureType() != TEX_TYPE_2D) continue; // only replace 2d images
// walk the frames, usually there is only one
for (unsigned int fr = 0; fr < tus->getNumFrames(); fr++)
{
Ogre::String textureName = tus->getFrameTextureName(fr);
std::map<Ogre::String, Ogre::String>::iterator it = skin_def->replace_textures.find(textureName);
if (it != not_found)
{
textureName = it->second; //getReplacementForTexture(textureName);
tus->setFrameTextureName(textureName, fr);
}
}
}
}
}
}
}
示例14: SetMaterialParameters
void CompositionHandler::SetMaterialParameters(const Ogre::MaterialPtr &material, const QList< std::pair<std::string, Ogre::Vector4> > &source) const
{
assert (material.get());
material->load();
for(ushort t=0 ; t<material->getNumTechniques() ; ++t)
{
Ogre::Technique *technique = material->getTechnique(t);
if (technique)
{
for(ushort p=0 ; p<technique->getNumPasses() ; ++p)
{
Ogre::Pass *pass = technique->getPass(p);
if (pass)
{
if (pass->hasVertexProgram())
{
Ogre::GpuProgramParametersSharedPtr destination = pass->getVertexProgramParameters();
for(int i=0 ; i<source.size() ; ++i)
{
if (destination->_findNamedConstantDefinition(source[i].first, false))
destination->setNamedConstant(source[i].first, source[i].second);
}
}
if (pass->hasFragmentProgram())
{
Ogre::GpuProgramParametersSharedPtr destination = pass->getFragmentProgramParameters();
for(int i=0 ; i<source.size() ; ++i)
{
if (destination->_findNamedConstantDefinition(source[i].first, false))
destination->setNamedConstant(source[i].first, source[i].second);
}
}
}
}
}
}
}
示例15: backgroundTexName
//.........这里部分代码省略.........
// sscanf(szUserCameraValue.c_str(), "%f;%f", &(newNode.fCameraHeight), &(newNode.fCameraDistance));
// }
int Row_Index;
Row_Index = atoi(szUserCameraValue.c_str());
const tDataBase* pDBC = g_pDataBase->GetDataBase(DBC_MODEL_PARAMETER);
KLAssert(pDBC);
const _DBC_MODEL_PARAMETER* pParameter = NULL;
pParameter = (const _DBC_MODEL_PARAMETER*)((tDataBase*)pDBC)->Search_Index_EQU(Row_Index);
if(pParameter)
{
newNode.fCameraHeight = pParameter->nHeight;
newNode.fCameraDistance = pParameter->nDistance;
}
//设置摄像机
_UpdateCamera(newNode);
newNode.pCamera->setNearClipDistance(10.f);
newNode.pCamera->setAspectRatio((float)nTexWidth/nTexHeight);
newNode.pCamera->setFOVy(Ogre::Degree(45.0f)); // 经验值
newNode.pCamera->setProjectionType(Ogre::PT_PERSPECTIVE); //透视投影 (平行投影 Ogre::PT_ORTHOGRAPHIC)
//--------------------------------------------------
//创建ViewPort
newNode.pViewPort = pTexture->addViewport(newNode.pCamera, 1);
newNode.pViewPort->setClearEveryFrame(true);
newNode.pViewPort->setBackgroundColour(Ogre::ColourValue(0,0,0,0));
newNode.pViewPort->setOverlaysEnabled(false);
newNode.pViewPort->setSkiesEnabled(false);
newNode.pViewPort->setShadowsEnabled(false);
//--------------------------------------------------
//创建rectangle(如果纹理名称不为空并且所需的material template存在)
Ogre::String backgroundTexName(szBackgroundName);
Ogre::MaterialPtr originMat = Ogre::MaterialManager::getSingleton().getByName("UIModelBackground");
if (false == backgroundTexName.empty() && false == originMat.isNull())
{
newNode.pRectange = new Ogre::Rectangle2D(true);
newNode.pRectange->setCorners(-1.0f, 1.0f, 1.0f, -1.0f);
Ogre::String cloneMatName = Ogre::String(szNodeName) + "_Rectangle";
Ogre::MaterialPtr cloneMat = Ogre::MaterialManager::getSingleton().getByName(cloneMatName);
if (cloneMat.isNull())
{
cloneMat = originMat->clone(cloneMatName);
if (cloneMat->getNumTechniques())
{
Ogre::Technique* tech = cloneMat->getTechnique(0);
if (tech->getNumPasses())
{
Ogre::Pass* pass = tech->getPass(0);
if (pass->getNumTextureUnitStates())
{
Ogre::TextureUnitState* tex = pass->getTextureUnitState(0);
tex->setTextureName(szBackgroundName);
}
}
}
}
newNode.pRectange->setMaterial(cloneMat->getName());
newNode.pRectange->setRenderQueueGroup(Ogre::RENDER_QUEUE_BACKGROUND);
newNode.pRectange->setVisibilityFlags(Fairy::OVF_GUI_ELEMENTS);
// 设置boundingbox为无限大,以防被camera剔除掉(默认的包围盒大小为-1,1)
newNode.pRectange->setBoundingBox(
Ogre::AxisAlignedBox(
Ogre::Vector3(Ogre::Math::NEG_INFINITY, Ogre::Math::NEG_INFINITY, Ogre::Math::NEG_INFINITY),
Ogre::Vector3(Ogre::Math::POS_INFINITY, Ogre::Math::POS_INFINITY, Ogre::Math::POS_INFINITY)
) );
Ogre::SceneNode* parentNode =
CEngineInterface::GetMe()->GetFairySystem()->getBaseSceneNode()->createChildSceneNode();
parentNode->attachObject(newNode.pRectange);
}
//--------------------------------------------------
//加入Map
m_mapObject.insert(std::make_pair(newNode.strName, newNode));
it = m_mapObject.find(newNode.strName);
KLAssert(it != m_mapObject.end());
//加入索引Map
m_mapIndexOfViewPort.insert(std::make_pair(newNode.pViewPort, &(it->second)));
return it;
}