當前位置: 首頁>>代碼示例>>C++>>正文


C++ Technique::getPass方法代碼示例

本文整理匯總了C++中Technique::getPass方法的典型用法代碼示例。如果您正苦於以下問題:C++ Technique::getPass方法的具體用法?C++ Technique::getPass怎麽用?C++ Technique::getPass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Technique的用法示例。


在下文中一共展示了Technique::getPass方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: getSafeTextureUnitState

int GameScript::getSafeTextureUnitState(TextureUnitState **tu, const String materialName, int techniqueNum, int passNum, int textureUnitNum)
{
	try
	{
		MaterialPtr m = MaterialManager::getSingleton().getByName(materialName);
		if (m.isNull()) return 1;

		// verify technique
		if (techniqueNum < 0 || techniqueNum > m->getNumTechniques()) return 2;
		Technique *t = m->getTechnique(techniqueNum);
		if (!t) return 2;

		//verify pass
		if (passNum < 0 || passNum > t->getNumPasses()) return 3;
		Pass *p = t->getPass(passNum);
		if (!p) return 3;

		//verify texture unit
		if (textureUnitNum < 0 || textureUnitNum > p->getNumTextureUnitStates()) return 4;
		TextureUnitState *tut = p->getTextureUnitState(textureUnitNum);
		if (!tut) return 4;

		*tu = tut;
		return 0;
	} catch(Exception e)
	{
		SLOG("Exception in getSafeTextureUnitState(): " + e.getFullDescription());
	}
	return 1;
}
開發者ID:Bob-Z,項目名稱:rigs-of-rods,代碼行數:30,代碼來源:GameScript.cpp

示例2: build

//-----------------------------------------------------------------------------
///
void BatchPage::build()
{
	m_pBatchGeom->build();
	BatchedGeometry::TSubBatchIterator it = m_pBatchGeom->getSubBatchIterator();

	while (it.hasMoreElements())
   {
		BatchedGeometry::SubBatch *subBatch = it.getNext();
		const MaterialPtr &ptrMat = subBatch->getMaterial();

		//Disable specular unless a custom shader is being used.
		//This is done because the default shader applied by BatchPage
		//doesn't support specular, and fixed-function needs to look
		//the same as the shader (for computers with no shader support)
		for (unsigned short t = 0, tCnt = ptrMat->getNumTechniques(); t < tCnt; ++t)
      {
			Technique *tech = ptrMat->getTechnique(t);
			for (unsigned short p = 0, pCnt = tech->getNumPasses(); p < pCnt; ++p)
         {
				Pass *pass = tech->getPass(p);
				//if (pass->getVertexProgramName() == "")
				//	pass->setSpecular(0, 0, 0, 1);
            if (!pass->hasVertexProgram())
               pass->setSpecular(0.f, 0.f, 0.f, 1.f);
			}
		}

		//Store the original materials
		m_vecUnfadedMaterials.push_back(subBatch->getMaterial());
	}

	_updateShaders();
}
開發者ID:drwbns,項目名稱:ogre-paged-latest,代碼行數:35,代碼來源:BatchPage.cpp

示例3: build

void BatchPage::build()
{
	batch->build();

	BatchedGeometry::SubBatchIterator it = batch->getSubBatchIterator();
	while (it.hasMoreElements()){
		BatchedGeometry::SubBatch *subBatch = it.getNext();
		MaterialPtr mat = subBatch->getMaterial();

		//Disable specular unless a custom shader is being used.
		//This is done because the default shader applied by BatchPage
		//doesn't support specular, and fixed-function needs to look
		//the same as the shader (for computers with no shader support)
		for (int t = 0; t < mat->getNumTechniques(); ++t){
			Technique *tech = mat->getTechnique(t);
			for (int p = 0; p < tech->getNumPasses(); ++p){
				Pass *pass = tech->getPass(p);
				if (pass->getVertexProgramName() == "")
					pass->setSpecular(0, 0, 0, 1);
			}
		}

		//Store the original materials
		unfadedMaterials.push_back(subBatch->getMaterial());
	}

	_updateShaders();
}
開發者ID:Antaresgames,項目名稱:kbengine_ogre_demo,代碼行數:28,代碼來源:BatchPage.cpp

示例4: setColor

	//--------------------------------------------------------------------------------
	void MaterialUtil::setColor(const MaterialPtr& _material, const ColourValue& _color)
	{
		Technique* technique = _material->getTechnique(0);
		Pass* pass = technique->getPass(0);
		pass->setDiffuse( _color );
		pass->setAmbient( _color );
	}
開發者ID:raduetsya,項目名稱:GothOgre,代碼行數:8,代碼來源:GothOgre_MaterialUtil.cpp

示例5: execute

//-----------------------------------------------------------------------
void DeferredLightRenderOperation::execute(SceneManager *sm, RenderSystem *rs)
{
    Ogre::Camera* cam = mViewport->getCamera();

	mAmbientLight->updateFromCamera(cam);
    Technique* tech = mAmbientLight->getMaterial()->getBestTechnique();
	injectTechnique(sm, tech, mAmbientLight, 0);

	const LightList& lightList = sm->_getLightsAffectingFrustum();
    for (LightList::const_iterator it = lightList.begin(); it != lightList.end(); it++) 
	{
        Light* light = *it;
		Ogre::LightList ll;
		ll.push_back(light);

		//if (++i != 2) continue;
        //if (light->getType() != Light::LT_DIRECTIONAL) continue;
		//if (light->getDiffuseColour() != ColourValue::Red) continue;

		LightsMap::iterator dLightIt = mLights.find(light);
		DLight* dLight = 0;
		if (dLightIt == mLights.end()) 
		{
			dLight = createDLight(light);
		}
		else 
		{
			dLight = dLightIt->second;
			dLight->updateFromParent();
		}
		dLight->updateFromCamera(cam);
		tech = dLight->getMaterial()->getBestTechnique();

		//Update shadow texture
		if (dLight->getCastChadows())
		{
			SceneManager::RenderContext* context = sm->_pauseRendering();

			sm->prepareShadowTextures(cam, mViewport, &ll);
			sm->_resumeRendering(context);
			
			Pass* pass = tech->getPass(0);
			TextureUnitState* tus = pass->getTextureUnitState("ShadowMap");
			assert(tus);
			const TexturePtr& shadowTex = sm->getShadowTexture(0);
			if (tus->_getTexturePtr() != shadowTex)
			{
				tus->_setTexturePtr(shadowTex);
			}
			
		}
		
        injectTechnique(sm, tech, dLight, &ll);
	}
}
開發者ID:Strongc,項目名稱:game-ui-solution,代碼行數:56,代碼來源:DeferredLightCP.cpp

示例6: 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);
			}
		}
	}
開發者ID:raduetsya,項目名稱:GothOgre,代碼行數:55,代碼來源:GothOgre_MaterialUtil.cpp

示例7: injectRender

	void LightInstanceBatchHW::injectRender()
	{
		if( (mRenderOperation.numberOfInstances = updateVertexBuffer( mCurrentCamera )) )
		{
			Technique* tech = mMaterial->getBestTechnique();

			for (size_t i=0; i<tech->getNumPasses(); ++i)
			{
				mManager->_injectRenderWithPass(tech->getPass(i), this, false);
			}
		}
	}
開發者ID:mavaL,項目名稱:MiniCraft,代碼行數:12,代碼來源:LightInstanceBatchHW.cpp

示例8: handleSchemeNotFound

//! [schemenotfound]
Technique* GBufferSchemeHandler::handleSchemeNotFound(unsigned short schemeIndex, 
        const String& schemeName, Material* originalMaterial, unsigned short lodIndex, 
        const Renderable* rend)
{
    Ogre::MaterialManager& matMgr = Ogre::MaterialManager::getSingleton();
    String curSchemeName = matMgr.getActiveScheme();
    matMgr.setActiveScheme(MaterialManager::DEFAULT_SCHEME_NAME);
    Technique* originalTechnique = originalMaterial->getBestTechnique(lodIndex, rend);
    matMgr.setActiveScheme(curSchemeName);

    Technique* gBufferTech = originalMaterial->createTechnique();
    gBufferTech->removeAllPasses();
    gBufferTech->setSchemeName(schemeName);

#ifdef OGRE_BUILD_COMPONENT_RTSHADERSYSTEM
    RTShader::ShaderGenerator& rtShaderGen = RTShader::ShaderGenerator::getSingleton();
    rtShaderGen.createShaderBasedTechnique(originalTechnique, "NoGBuffer");
#else
    Technique* noGBufferTech = originalMaterial->createTechnique();
    noGBufferTech->removeAllPasses();
    noGBufferTech->setSchemeName("NoGBuffer");
#endif

    for (unsigned short i=0; i<originalTechnique->getNumPasses(); i++)
    {
        Pass* originalPass = originalTechnique->getPass(i);
        PassProperties props = inspectPass(originalPass, lodIndex, rend);
        
        if (!props.isDeferred)
        {
#ifdef OGRE_BUILD_COMPONENT_RTSHADERSYSTEM
            rtShaderGen.validateMaterial("NoGBuffer", originalMaterial->getName(), originalMaterial->getGroup());
#else
            //Just copy the technique so it gets rendered regularly
            Pass* clonePass = noGBufferTech->createPass();
            *clonePass = *originalPass;
#endif
            continue;
        }

        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;
}
開發者ID:yiliu1203,項目名稱:OGRE,代碼行數:53,代碼來源:GBufferSchemeHandler.cpp

示例9: removeTerrainBlockerPass

	// 把地形的障礙區域顯示Pass移除
	void TerrainEditorPlugin::removeTerrainBlockerPass(ETTerrain *terrain)
	{
		MaterialPtr mat = terrain->getTerrainImpl()->getMaterial();
		Technique *tech = mat->getTechnique(0);
		// 看有沒有這個Blocker的Pass,如果有就刪除之
		for(size_t i = 0 ; i < tech->getNumPasses() ; i ++)
		{
			if(tech->getPass(i)->getName() == "Blocker")
			{
				tech->removePass(i);
				return;
			}
		}
	}
開發者ID:duzhi5368,項目名稱:FKOgreWorldEdit,代碼行數:15,代碼來源:TerrainEditorPlugin.cpp

示例10: setPaintTexutreName

	// 替換指定紋理層的紋理
	bool TerrainImpl::setPaintTexutreName(size_t nPaintChannel , const String &strTextureName)
	{
		Technique *pTech = mMaterial->getTechnique(0);
		Pass *pass = pTech->getPass(nPaintChannel / SPLATTING_TEXTURE_NUM);
		if(pass)
		{
			TextureUnitState *texture = pass->getTextureUnitState(COVERAGE_TEXTURE_NUM + (nPaintChannel % SPLATTING_TEXTURE_NUM));
			if(texture)
			{
				texture->setTextureName(strTextureName);
				return texture->getTextureName() == strTextureName && !texture->_getTexturePtr().isNull() && texture->_getTexturePtr()->isLoaded();
			}
		}
		return false;
	}
開發者ID:duzhi5368,項目名稱:FKOgreWorldEdit,代碼行數:16,代碼來源:ETTerrainImpl.cpp

示例11: lua_Technique_getPass

static int lua_Technique_getPass(lua_State* state)
{
    // Get the number of parameters.
    int paramCount = lua_gettop(state);

    // Attempt to match the parameters to a valid binding.
    switch (paramCount)
    {
        case 2:
        {
            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
            {
                // Get parameter 1 off the stack.
                const char* param1 = gameplay::ScriptUtil::getString(2, false);

                Technique* instance = getInstance(state);
                void* returnPtr = ((void*)instance->getPass(param1));
                if (returnPtr)
                {
                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
                    object->instance = returnPtr;
                    object->owns = false;
                    luaL_getmetatable(state, "Pass");
                    lua_setmetatable(state, -2);
                }
                else
                {
                    lua_pushnil(state);
                }

                return 1;
            }

            lua_pushstring(state, "lua_Technique_getPass - Failed to match the given parameters to a valid function signature.");
            lua_error(state);
            break;
        }
        default:
        {
            lua_pushstring(state, "Invalid number of parameters (expected 2).");
            lua_error(state);
            break;
        }
    }
    return 0;
}
開發者ID:03050903,項目名稱:GamePlay,代碼行數:47,代碼來源:lua_Technique.cpp

示例12: 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 ) ) ;
      }
    }
  }
}
開發者ID:Akanoa,項目名稱:PRI,代碼行數:23,代碼來源:ovkMaterialAction.cpp

示例13: createSGPassList

//-----------------------------------------------------------------------------
void SGMaterialSerializerListener::createSGPassList(Material* mat, SGPassList& passList)
{
	for (unsigned short techniqueIndex = 0; techniqueIndex < mat->getNumTechniques(); ++techniqueIndex)
	{
		Technique* curTechnique = mat->getTechnique(techniqueIndex);

		for (unsigned short passIndex = 0; passIndex < curTechnique->getNumPasses(); ++passIndex)
		{
			Pass* curPass = curTechnique->getPass(passIndex);		
			const Any& passUserData = curPass->getUserObjectBindings().getUserAny(ShaderGenerator::SGPass::UserKey);

			// Case this pass created by the shader generator.
			if (passUserData.isEmpty() == false)	
			{
				ShaderGenerator::SGPass* passEntry = any_cast<ShaderGenerator::SGPass*>(passUserData);

				passList.push_back(passEntry);
			}								
		}
	}
}
開發者ID:albmarvil,項目名稱:The-Eternal-Sorrow,代碼行數:22,代碼來源:OgreShaderMaterialSerializerListener.cpp

示例14: getTemplateMaterial

const MaterialPtr &MaterialGenerator::getMaterial(Perm permutation)
{
	/// Check input validity
	size_t totalBits = bitNames.size();
	size_t totalPerms = 1<<totalBits;
	assert(permutation < totalPerms);

	/// Check if material/shader permutation already was generated
	MaterialMap::iterator i = mMaterials.find(permutation);
	if(i != mMaterials.end())
	{
		return i->second;
	}
	else
	{
		/// Create it
		MaterialPtr templ = getTemplateMaterial(permutation & matMask);
		GpuProgramPtr vs = getVertexShader(permutation & vsMask);
		GpuProgramPtr fs = getFragmentShader(permutation & fsMask);
		
		/// Create material name
		String name=materialBaseName;
		for(size_t bit=0; bit<totalBits; ++bit)
			if(permutation & (1<<bit))
				name += bitNames[bit];

		std::cerr << name << " " << vs->getName() << " " << fs->getName() << std::endl;
		/// Create material from template, and set shaders
		MaterialPtr mat = templ->clone(name);
		Technique *tech = mat->getTechnique(0);
		Pass *pass = tech->getPass(0);
		pass->setFragmentProgram(fs->getName());
		pass->setVertexProgram(vs->getName());
	
		/// And store it
		mMaterials[permutation] = mat;
		return mMaterials[permutation];
	}
}
開發者ID:venkatarajasekhar,項目名稱:viper,代碼行數:39,代碼來源:MaterialGenerator.cpp

示例15: setMaterialNodeBinding

void Model::setMaterialNodeBinding(Material *material)
{
    if (_node)
    {
        material->setNodeBinding(_node);

        unsigned int techniqueCount = material->getTechniqueCount();
        for (unsigned int i = 0; i < techniqueCount; ++i)
        {
            Technique* technique = material->getTechnique(i);
            
            technique->setNodeBinding(_node);

            unsigned int passCount = technique->getPassCount();
            for (unsigned int j = 0; j < passCount; ++j)
            {
                Pass* pass = technique->getPass(j);

                pass->setNodeBinding(_node);
            }
        }
    }
}
開發者ID:Jaegermeiste,項目名稱:GamePlay,代碼行數:23,代碼來源:Model.cpp


注:本文中的Technique::getPass方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。