当前位置: 首页>>代码示例>>C++>>正文


C++ MaterialPtr::getBestTechnique方法代码示例

本文整理汇总了C++中ogre::MaterialPtr::getBestTechnique方法的典型用法代码示例。如果您正苦于以下问题:C++ MaterialPtr::getBestTechnique方法的具体用法?C++ MaterialPtr::getBestTechnique怎么用?C++ MaterialPtr::getBestTechnique使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ogre::MaterialPtr的用法示例。


在下文中一共展示了MaterialPtr::getBestTechnique方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Draw

void Rect::Draw(Ogre::Vector3 pos)
{
    Ogre::Vector3 quad[4];
    quad[0] = Ogre::Vector3(pos.x - (length / 2.0), pos.y, pos.z - (height / 2.0)); // ll
    quad[1] = Ogre::Vector3(pos.x - (length / 2.0), pos.y, pos.z + (height / 2.0)); // ul
    quad[2] = Ogre::Vector3(pos.x + (length / 2.0), pos.y, pos.z + (height / 2.0)); // ur
    quad[3] = Ogre::Vector3(pos.x + (length / 2.0), pos.y, pos.z - (height / 2.0)); // lr

    Ogre::MaterialPtr matptr = Ogre::MaterialManager::getSingleton().create("BaseColoured", "General");
    matptr->load();
    matptr->getBestTechnique()->getPass(0)->setVertexColourTracking(Ogre::TVC_DIFFUSE);
    matptr->getBestTechnique()->getPass(0)->setLightingEnabled(false);

    mObj->begin("BaseColoured", Ogre::RenderOperation::OT_TRIANGLE_LIST);
    mObj->position(quad[0]);
    mObj->colour(colour);
    
    //mObj->textureCoord(1,1);
    mObj->position(quad[1]);
    mObj->colour(colour);
    //mObj->textureCoord(1,0);
    mObj->position(quad[2]);
    mObj->colour(colour);
    //mObj->textureCoord(0,0);
    mObj->position(quad[3]);
    mObj->colour(colour);
    //mObj->textureCoord(0,1);

    mObj->quad(0,1,2,3);
    mObj->end();
}
开发者ID:pixelgriffin,项目名称:DroneCraft,代码行数:31,代码来源:Rect.cpp

示例2: notifyMaterialRender

void HDRListener::notifyMaterialRender(Ogre::uint32 pass_id, Ogre::MaterialPtr &mat)
{
	
	if(pass_id == 600 || pass_id == 800)
	{
		Ogre::Pass *pass = mat->getBestTechnique()->getPass(0);
		Ogre::GpuProgramParametersSharedPtr params = pass->getFragmentProgramParameters();
    
		if (params->_findNamedConstantDefinition("toneMapSettings"))
		{
			Ogre::Vector4 toneMapSettings(1-mApp->pSet->hdrParam1, mApp->pSet->hdrParam2, mApp->pSet->hdrParam3, 1.0);
			params->setNamedConstant("toneMapSettings", toneMapSettings);
		}
		if (params->_findNamedConstantDefinition("bloomSettings"))
		{
			Ogre::Vector4 bloomSettings(mApp->pSet->hdrbloomorig*2, mApp->pSet->hdrbloomint, 1.0, 1.0);
			params->setNamedConstant("bloomSettings", bloomSettings);
		}
		if (params->_findNamedConstantDefinition("vignettingSettings"))
		{
			Ogre::Vector4 vignettingSettings(mApp->pSet->vignettingRadius, mApp->pSet->vignettingDarkness, 1.0, 1.0);
			params->setNamedConstant("vignettingSettings", vignettingSettings);
		}
	
	}
	else if(pass_id == 989)
	{
		Ogre::Pass *pass = mat->getBestTechnique()->getPass(0);
		Ogre::GpuProgramParametersSharedPtr params = pass->getFragmentProgramParameters();
		if (params->_findNamedConstantDefinition("AdaptationScale"))
		{
			params->setNamedConstant("AdaptationScale", mApp->pSet->hdrAdaptationScale);
		}
	}
}
开发者ID:sureandrew,项目名称:stuntrally,代码行数:35,代码来源:Compositor.cpp

示例3: notifyMaterialSetup

 void GaussianListener::notifyMaterialSetup(Ogre::uint32 pass_id, Ogre::MaterialPtr &mat)
 {
     // Prepare the fragment params offsets
     switch(pass_id)
     {
     case 701: // blur horz
     {
         // horizontal bloom
         mat->load();
         Ogre::GpuProgramParametersSharedPtr fparams =
             mat->getBestTechnique()->getPass(0)->getFragmentProgramParameters();
         const Ogre::String& progName = mat->getBestTechnique()->getPass(0)->getFragmentProgramName();
         UNREFERENCED_PARAM(progName);
         fparams->setNamedConstant("sampleOffsets", mBloomTexOffsetsHorz[0], 15);
         fparams->setNamedConstant("sampleWeights", mBloomTexWeights[0], 15);
         break;
     }
     case 700: // blur vert
     {
         // vertical bloom
         mat->load();
         Ogre::GpuProgramParametersSharedPtr fparams =
             mat->getTechnique(0)->getPass(0)->getFragmentProgramParameters();
         const Ogre::String& progName = mat->getBestTechnique()->getPass(0)->getFragmentProgramName();
         UNREFERENCED_PARAM(progName);
         fparams->setNamedConstant("sampleOffsets", mBloomTexOffsetsVert[0], 15);
         fparams->setNamedConstant("sampleWeights", mBloomTexWeights[0], 15);
         break;
     }
     }
 }
开发者ID:Ilikia,项目名称:naali,代码行数:31,代码来源:CompositionHandler.cpp

示例4: notifyMaterialRender

//---------------------------------------------------------------------------
void BlurListener::notifyMaterialRender(Ogre::uint32 pass_id, Ogre::MaterialPtr &mat)
{
	Ogre::GpuProgramParametersSharedPtr fparams = mat->getBestTechnique()->getPass(0)->getFragmentProgramParameters();
	if( pass_id == 700 || pass_id == 701 )
	{
		bool horizontal = pass_id == 700;

		Ogre::Vector2 sampleOffsets[15];
		Ogre::Vector4 sampleWeights[15];

		// calculate gaussian texture offsets & weights
		Ogre::Vector2 textureSize = Vector2(1280,720);
		float texelSize = 1.0f / (float)( horizontal ? textureSize.x : textureSize.y );

		texelSize *= fuzziness;

		// central sample, no offset
		sampleOffsets[ 0 ] = Vector2::ZERO;
		{
			float distribution = GaussianDistribution( 0, 0, 3 );
			sampleWeights[ 0 ] = Ogre::Vector4( distribution, distribution, distribution, 0 );
		}

		// 'pre' samples
		for( int n = 1; n < 8; n++ )
		{
			float distribution = GaussianDistribution( n, 0, 3 );
			sampleWeights[ n ] = Vector4( distribution, distribution, distribution, 1 );

			if( horizontal )
				sampleOffsets[ n ] = Vector2( (float)n * texelSize, 0 );
			else
				sampleOffsets[ n ] = Vector2( 0, (float)n * texelSize );
		}
		// 'post' samples
		for( int n = 8; n < 15; n++ )
		{
			sampleWeights[ n ] = sampleWeights[ n - 7 ];
			sampleOffsets[ n ] = -sampleOffsets[ n - 7 ];
		}

		//convert to Vec4 array
		Vector4 vec4Offsets [15];
		for( int n = 0; n < 15; n++ )
		{
			Vector2 offset = sampleOffsets[ n ];
			vec4Offsets[ n ] = Vector4( offset.x, offset.y, 0, 0 );
		}

		Ogre::GpuProgramParametersSharedPtr fparams = mat->getBestTechnique()->getPass(0)->getFragmentProgramParameters();

		//fparams->setNamedConstant( "sampleOffsets", vec4Offsets );
		//fparams->setNamedConstant( "sampleWeights", sampleWeights );
	}
}
开发者ID:Alex-G,项目名称:MuOnline,代码行数:56,代码来源:BlurListener.cpp

示例5: notifyMaterialRender

	// this callback we will use to modify SSAO parameters
    void notifyMaterialRender(Ogre::uint32 pass_id, Ogre::MaterialPtr &mat)
    {
        if (pass_id != 42) // not SSAO, return
            return;

        // this is the camera you're using
		Ogre::Camera *cam = mInstance->getChain()->getViewport()->getCamera();

        // calculate the far-top-right corner in view-space
        Ogre::Vector3 farCorner = cam->getViewMatrix(true) * cam->getWorldSpaceCorners()[4];

        // get the pass
        Ogre::Pass *pass = mat->getBestTechnique()->getPass(0);

        // 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);

        // get the fragment shader parameters
        params = pass->getFragmentProgramParameters();
        // set the projection matrix we need
        static const Ogre::Matrix4 CLIP_SPACE_TO_IMAGE_SPACE(
            0.5,    0,    0,  0.5,
            0,   -0.5,    0,  0.5,
            0,      0,    1,    0,
            0,      0,    0,    1);
        if (params->_findNamedConstantDefinition("ptMat"))
            params->setNamedConstant("ptMat", CLIP_SPACE_TO_IMAGE_SPACE * cam->getProjectionMatrixWithRSDepth());
        if (params->_findNamedConstantDefinition("far"))
            params->setNamedConstant("far", cam->getFarClipDistance());
    }
开发者ID:MrLobo,项目名称:El-Rayo-de-Zeus,代码行数:34,代码来源:SSAOLogic.cpp

示例6: loadMaterialControlsFile

void loadMaterialControlsFile(MaterialControlsContainer& controlsContainer, const Ogre::String& filename)
{
    // Load material controls from config file
    Ogre::ConfigFile cf;

    try
    {

        cf.load(filename, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, "\t;=", true);

        // Go through all sections & controls in the file
        Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();

        Ogre::String secName, typeName, materialName, dataString;

        while (seci.hasMoreElements())
        {
            secName = seci.peekNextKey();
            Ogre::ConfigFile::SettingsMultiMap* settings = seci.getNext();
            if (!secName.empty() && settings)
            {
                materialName = cf.getSetting("material", secName);
				
				Ogre::MaterialPtr curMat = Ogre::MaterialManager::getSingleton().getByName(materialName);
				curMat->load();
				Ogre::Technique * curTec = curMat->getBestTechnique();
				if (!curTec || !curTec->isSupported())
				{
					continue;
				}

                MaterialControls newMaaterialControls(secName, materialName);
                controlsContainer.push_back(newMaaterialControls);

                size_t idx = controlsContainer.size() - 1;

                Ogre::ConfigFile::SettingsMultiMap::iterator i;

                for (i = settings->begin(); i != settings->end(); ++i)
                {
                    typeName = i->first;
                    dataString = i->second;
                    if (typeName == "control")
                        controlsContainer[idx].addControl(dataString);
                }
            }
        }

	    Ogre::LogManager::getSingleton().logMessage( "Material Controls setup" );
    }
    catch (Ogre::Exception e)
    {
        // Guess the file didn't exist
    }
}
开发者ID:Anti-Mage,项目名称:ogre,代码行数:55,代码来源:MaterialControls.cpp

示例7: setSoftParticlesDelta

	//-----------------------------------------------------------------------
	void ParticleRenderer::setSoftParticlesDelta(Ogre::Real softParticlesDelta)
	{
		mSoftParticlesDelta = softParticlesDelta;
		if (mUseSoftParticles)
		{
			// Set GPU param
			Ogre::MaterialPtr mat = mParentTechnique->getMaterial();
			if (!mat.isNull())
			{
				if (mat->getBestTechnique() && mat->getBestTechnique()->getPass(0))
				{
					Ogre::Pass* gpuPass = mat->getBestTechnique()->getPass(0);
					if (gpuPass->hasFragmentProgram())
					{
						Ogre::GpuProgramParametersSharedPtr fragmentParams = gpuPass->getFragmentProgramParameters();
						fragmentParams->setNamedConstant("delta", mSoftParticlesDelta);
					}
				}
			}
		}
	}
开发者ID:dbabox,项目名称:aomi,代码行数:22,代码来源:ParticleUniverseRenderer.cpp

示例8: 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
}
开发者ID:xubingyue,项目名称:particle_universe,代码行数:53,代码来源:ParticleUniverseMaterialTab.cpp

示例9: update

void Bomber::update(float timer_,ObjectManager* manager)
{
	std::vector<GameObject*> tempList = manager->getObjectList();
	Ogre::MaterialPtr mat;
	for(int i = 1; i<=26; i++){
		mat = static_cast<Ogre::MaterialPtr>(Ogre::MaterialManager::getSingleton().getByName(m_pNode->getName()+"_SField_SplineParticleMaterial_"+ Ogre::StringConverter::toString(i)));
		mat->getBestTechnique()->getPass(0)->getVertexProgramParameters()->setNamedConstant("timer", timer_ - i);
	}

	if(hasExploded){
		personalTimer += 1;
		mat = static_cast<Ogre::MaterialPtr>(Ogre::MaterialManager::getSingleton().getByName(m_pNode->getName()+"_Explosion_ParticleMaterial_"+ Ogre::StringConverter::toString(27)));
		mat->getBestTechnique()->getPass(0)->getVertexProgramParameters()->setNamedConstant("timer", personalTimer);

		if(personalTimer >= 50){
			m_pNode->setVisible(false);
			dead = true;
		}
	}
	Ogre::Vector3 temp = m_pNode->getPosition() - tempList.at(0)->getNode().getPosition();
	move(temp);
}
开发者ID:WilliamCreber,项目名称:COMP3501_EOY_Project,代码行数:22,代码来源:Bomber.cpp

示例10: Update

void ParticleEffect::Update(const Ogre::FrameEvent& fe)
{
	PhysicsEntity::Update(fe);
	if(alive){
		timer += fe.timeSinceLastFrame;
		//std::cout << "Passing in Timer: " <<timer <<std::endl;
		Ogre::MaterialPtr mat = static_cast<Ogre::MaterialPtr>(Ogre::MaterialManager::getSingleton().getByName(materialName));
		mat->getBestTechnique()->getPass(0)->getVertexProgramParameters()->setNamedConstant("timer", timer);

		if(duration > 0.0f && timer > duration){
			alive = false;
		}
	}
}
开发者ID:Elephly,项目名称:d00m3d,代码行数:14,代码来源:particle_effect.cpp

示例11: update

void Rocket::update(float timer_)
{
	Ogre::MaterialPtr mat;
	mat = static_cast<Ogre::MaterialPtr>(Ogre::MaterialManager::getSingleton().getByName(m_pNode->getName()+"_Thruster_FireMaterial_"+ Ogre::StringConverter::toString(1)));
	mat->getBestTechnique()->getPass(0)->getVertexProgramParameters()->setNamedConstant("timer", timer_);

	if(hasExploded){
		personalTimer += 1;
		mat = static_cast<Ogre::MaterialPtr>(Ogre::MaterialManager::getSingleton().getByName(m_pNode->getName()+"_Explosion_ParticleMaterial_"+ Ogre::StringConverter::toString(2)));
		mat->getBestTechnique()->getPass(0)->getVertexProgramParameters()->setNamedConstant("timer", personalTimer);

		if(personalTimer >= 15){
			m_pNode->setVisible(false);
			dead = true;
		}
		return;
	}
	move();

	flyTime -= 0.75f;
	if(flyTime < 0.0f){
		dead = true;
	}
}
开发者ID:Benjanator,项目名称:COMP3501_EOY_Project,代码行数:24,代码来源:Rocket.cpp

示例12: notifyMaterialSetup

	void DepthComposerInstance::notifyMaterialSetup(uint pass_id, Ogre::MaterialPtr &mat)
	{
        //LogManager::getSingleton ().logMessage (
        //            "Caelum::DepthComposer: Material setup");

        Pass* pass = mat->getBestTechnique ()->getPass (0);

        TextureUnitState *depthTus = pass->getTextureUnitState(1);
        if (depthTus->getTextureName () != mDepthRenderer->getDepthRenderTexture ()->getName()) {
            depthTus->setTextureName (mDepthRenderer->getDepthRenderTexture ()->getName ());
            LogManager::getSingleton ().logMessage (
                        "Caelum::DepthComposer: Assigned depth texture in compositor material");
        }

        mParams.setup(pass->getFragmentProgramParameters ());
	}
开发者ID:Chimangoo,项目名称:ember,代码行数:16,代码来源:DepthComposer.cpp

示例13: forceCreateFirstTexture

//-----------------------------------------------------------------------
Ogre::TextureUnitState* MaterialTab::forceCreateFirstTexture(const Ogre::String textureName)
{
	// Ignore some materials because they result in a crash while unloading
	wxString materialName = mMaterialListBox->GetStringSelection();
	if (materialName == wxT("DefaultSettings"))
		return 0;

	Ogre::Technique* technique = 0;
	Ogre::TextureUnitState* texture = 0;
	Ogre::Pass* pass = getFirstPass();
	if (pass)
	{
		// There is a pass, check for textures or create one
		if (pass->getNumTextureUnitStates() > 0)
		{
			pass->removeAllTextureUnitStates();
		}
		texture = pass->createTextureUnitState(textureName);
	}
	else
	{
		// There is no pass
		wxString materialName = mMaterialListBox->GetStringSelection();
		Ogre::String name = wx2ogre(materialName);
		Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().getByName(name);
		if (!material.isNull())
		{
			material->load();
			if (material->getNumTechniques() > 0)
			{
				technique = material->getBestTechnique(); // Get the best technique
				pass = technique->createPass();
				texture = pass->createTextureUnitState(textureName);
			}
			else
			{
				// There is no technique, no pass and no textureunitstate
				technique = material->createTechnique();
				pass = technique->createPass();
				texture = pass->createTextureUnitState(textureName);
			}
		}
	}

	return texture;
}
开发者ID:xubingyue,项目名称:particle_universe,代码行数:47,代码来源:ParticleUniverseMaterialTab.cpp

示例14: 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;
}
开发者ID:xubingyue,项目名称:particle_universe,代码行数:18,代码来源:ParticleUniverseMaterialTab.cpp

示例15: checkMaterial

bool ShaderManager::checkMaterial(const std::string& materialName, const std::string& schemeName)
{
  // OGRE scheme is switched in caller
  Ogre::MaterialPtr material = static_cast<Ogre::MaterialPtr>(Ogre::MaterialManager::getSingleton().load(materialName, "General"));
  if (material->getNumSupportedTechniques() == 0) {
    S_LOG_INFO("The material '" << material->getName() << "' has no supported techniques with scheme " << schemeName << ". The reason for this is: \n" << material->getUnsupportedTechniquesExplanation());
    return false;
  }

  S_LOG_INFO("The material '" << material->getName() << "' has " << material->getNumSupportedTechniques() << " supported techniques out of " << material->getNumTechniques());

  // Check that we use desired scheme, but not fallbacked to default
  if (material->getBestTechnique()->getSchemeName() != schemeName) {
    S_LOG_INFO("The material '" << material->getName() << "' has best supported scheme " << material->getBestTechnique()->getSchemeName() << ". Was looking for " << schemeName);
    return false;
  }
  S_LOG_INFO("The material '" << material->getName() << "' supported with scheme " << schemeName);
  return true;
}
开发者ID:junrw,项目名称:ember-gsoc2012,代码行数:19,代码来源:ShaderManager.cpp


注:本文中的ogre::MaterialPtr::getBestTechnique方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。