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


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

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


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

示例1: 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();
         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();
         fparams->setNamedConstant("sampleOffsets", mBloomTexOffsetsVert[0], 15);
         fparams->setNamedConstant("sampleWeights", mBloomTexWeights[0], 15);
         break;
     }
     }
 }
开发者ID:Manaluusua,项目名称:naali,代码行数:29,代码来源:CompositionHandler.cpp

示例2: CreateGroundMaterialTextured

//-------------------------------------------------------
Ogre::Material* Ground::CreateGroundMaterialTextured(const std::string & name, const Ogre::Image* texture)
{
    Ogre::TexturePtr heightMapTexture = Ogre::TextureManager::getSingleton().loadImage("Texture/Terrain",
        Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, *texture);

    Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create(name, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
    {
        Ogre::Technique* techniqueGL = material->getTechnique(0);
        Ogre::Pass* pass = techniqueGL->getPass(0);
        {
            auto vprogram = Ogre::HighLevelGpuProgramManager::getSingleton().createProgram("Shader/" + CLASS_NAME + "/GL/Textured/V",
                Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, "glsl", Ogre::GPT_VERTEX_PROGRAM);
            vprogram->setSource(Shader_GL_Simple_V);
            //auto vparams = vprogram->createParameters();
            //vparams->setNamedAutoConstant("modelviewproj", Ogre::GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX);

            pass->setVertexProgram(vprogram->getName());
        }
        {
            auto fprogram = Ogre::HighLevelGpuProgramManager::getSingleton().createProgram("Shader/" + CLASS_NAME + "/GL/Textured/F",
                Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, "glsl", Ogre::GPT_FRAGMENT_PROGRAM);
            fprogram->setSource(Shader_GL_Simple_F);

            auto unit0 = pass->createTextureUnitState(heightMapTexture->getName());
            unit0->setTextureAddressingMode(Ogre::TextureUnitState::TAM_CLAMP);
            unit0->setTextureFiltering(Ogre::TFO_NONE);

            pass->setFragmentProgram(fprogram->getName());
        }
    }
#if !NDEBUG
    material->load();
#endif
    return material.get();
}
开发者ID:agruzdev,项目名称:OgreNature,代码行数:36,代码来源:Ground.cpp

示例3: compileMaterial

bool Simple::compileMaterial(Ogre::MaterialPtr material)
{
	material->removeAllTechniques();
	Ogre::Technique* technique = material->createTechnique();
	for (SurfaceLayerStore::const_iterator I = mTerrainPageSurfaces.begin(); I != mTerrainPageSurfaces.end(); ++I) {
		const TerrainPageSurfaceLayer* surfaceLayer = I->second;
		if (I == mTerrainPageSurfaces.begin()) {
			Ogre::Pass* pass = technique->createPass();
			pass->setLightingEnabled(false);
			//add the first layer of the terrain, no alpha or anything
			Ogre::TextureUnitState * textureUnitState = pass->createTextureUnitState();
			textureUnitState->setTextureScale(1.0f / surfaceLayer->getScale(), 1.0f / surfaceLayer->getScale());
			textureUnitState->setTextureName(surfaceLayer->getDiffuseTextureName());
			textureUnitState->setTextureCoordSet(0);
		} else {
			if (surfaceLayer->intersects(*mGeometry)) {
				addPassToTechnique(*mGeometry, technique, surfaceLayer);
			}
		}
	}
	if (mTerrainPageShadow) {
		addShadow(technique, mTerrainPageShadow, material);
	}
	material->load();
	if (material->getNumSupportedTechniques() == 0) {
		S_LOG_WARNING("The material '" << material->getName() << "' has no supported techniques. The reason for this is: \n" << material->getUnsupportedTechniquesExplanation());
		return false;
	}
	return true;
}
开发者ID:Arsakes,项目名称:ember,代码行数:30,代码来源:Simple.cpp

示例4: compileMaterial

bool Simple::compileMaterial(Ogre::MaterialPtr material, std::set<std::string>& managedTextures) const
{
	material->removeAllTechniques();
	Ogre::Technique* technique = material->createTechnique();
	if (!mTerrainPageSurfaces.empty()) {
		//First add a base pass
		auto surfaceLayer = mTerrainPageSurfaces.begin()->second;
		Ogre::Pass* pass = technique->createPass();
		pass->setLightingEnabled(false);
		Ogre::TextureUnitState * textureUnitState = pass->createTextureUnitState();
		textureUnitState->setTextureScale(1.0f / surfaceLayer->getScale(), 1.0f / surfaceLayer->getScale());
		textureUnitState->setTextureName(surfaceLayer->getDiffuseTextureName());
		textureUnitState->setTextureCoordSet(0);

		for (auto& layer : mLayers) {
			addPassToTechnique(*mGeometry, technique, layer, managedTextures);
		}
	}
	if (mTerrainPageShadow) {
		addShadow(technique, mTerrainPageShadow, material, managedTextures);
	}

//	addLightingPass(technique, managedTextures);

	material->load();
	if (material->getNumSupportedTechniques() == 0) {
		S_LOG_WARNING("The material '" << material->getName() << "' has no supported techniques. The reason for this is: \n" << material->getUnsupportedTechniquesExplanation());
		return false;
	}
	return true;
}
开发者ID:Chimangoo,项目名称:ember,代码行数:31,代码来源:Simple.cpp

示例5: 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

示例6: notifyMaterialSetup

//---------------------------------------------------------------------------
void BlurListener::notifyMaterialSetup(Ogre::uint32 pass_id, Ogre::MaterialPtr &mat)
{
	mat->load();
	/*Ogre::GpuProgramParametersSharedPtr fparams = mat->getBestTechnique()->getPass(0)->getFragmentProgramParameters();
	fparams->setNamedConstant("radius", 10);
	fparams->setNamedConstant("intensity", 1);*/

}
开发者ID:Alex-G,项目名称:MuOnline,代码行数:9,代码来源:BlurListener.cpp

示例7: notifyMaterialSetup

void HDRListener::notifyMaterialSetup(Ogre::uint32 pass_id, Ogre::MaterialPtr &mat)
{
//  Prepare the fragment params offsets
	switch (pass_id)
	{
	//case 994: // rt_lum4
	case 993: // rt_lum3
	case 992: // rt_lum2
	case 991: // rt_lum1
	case 990: // rt_lum0
		break;
	case 800: // rt_brightpass
		break;
	case 701: // rt_bloom1
		{
			// horizontal bloom
		try
		{	mat->load();
			Ogre::GpuProgramParametersSharedPtr fparams =
				mat->getBestTechnique()->getPass(0)->getFragmentProgramParameters();
			fparams->setNamedConstant("sampleOffsets", mBloomTexOffsetsHorz[0], 15);
			fparams->setNamedConstant("sampleWeights", mBloomTexWeights[0], 15);
		}catch(...)
		{	}

			break;
		}
	case 700: // rt_bloom0
		{
			// vertical bloom
		try
		{	mat->load();
			Ogre::GpuProgramParametersSharedPtr fparams =
				mat->getTechnique(0)->getPass(0)->getFragmentProgramParameters();
			fparams->setNamedConstant("sampleOffsets", mBloomTexOffsetsVert[0], 15);
			fparams->setNamedConstant("sampleWeights", mBloomTexWeights[0], 15);
		}catch(...)
		{	}

			break;
		}
	}
}
开发者ID:sureandrew,项目名称:stuntrally,代码行数:43,代码来源:Compositor.cpp

示例8: 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

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

示例10:

//---------------------------------------------------------------------
std::list<Ogre::MaterialPtr> MapBlock::cloneMaterials(void) {
	std::list<Ogre::MaterialPtr> clones;
	for(unsigned int i=0; i < mEntity->getNumSubEntities(); i++) {
		Ogre::MaterialPtr realMaterial = mEntity->getSubEntity(i)->getMaterial();
		std::stringstream nameStream;
		nameStream << realMaterial->getName() << " " << mStaticPosition[0] << ":" << mStaticPosition[1];
		Ogre::MaterialPtr newMaterial = realMaterial->clone(nameStream.str());
		newMaterial->load();
		mEntity->getSubEntity(i)->setMaterial(newMaterial);
		clones.push_back(newMaterial);
	}
	return clones;
}
开发者ID:DanApperloo,项目名称:Eradicate,代码行数:14,代码来源:MapBlock.cpp

示例11: notifyMaterialRender

void MotionBlurListener::notifyMaterialRender(Ogre::uint32 pass_id, Ogre::MaterialPtr &mat)
{
	if (pass_id != 120) return;
	//Ogre::LogManager::getSingleton().logMessage("notifyMaterialRender");
	try
	{	mat->load();
		Ogre::GpuProgramParametersSharedPtr fparams =
			mat->getBestTechnique()->getPass(0)->getFragmentProgramParameters();
		fparams->setNamedConstant("blur", pApp->motionBlurIntensity);
	}catch(Ogre::Exception& e)
	{
		Ogre::LogManager::getSingleton().logMessage("Error setting motion blur");
	}
}
开发者ID:sureandrew,项目名称:stuntrally,代码行数:14,代码来源:Compositor.cpp

示例12: 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

示例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: launch

void GPGPUDemo::launch()
{
	// create rendertarget
	Ogre::TexturePtr tex = Ogre::TextureManager::getSingleton().createManual("Ogre/GPGPU/RT", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, 512, 512, 0, Ogre::PF_R8G8B8A8, Ogre::TU_RENDERTARGET);

	// load material
	Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().getByName("GPGPUDemo");
	mat->load();

	Ogre::GPGPU::Root* gpgpu = new Ogre::GPGPU::Root;
	Ogre::GPGPU::Result* result = gpgpu->createResult(tex->getBuffer(0, 0));
	Ogre::GPGPU::Operation* op  = gpgpu->createOperation(mat->getTechnique(0)->getPass(0));

	Chrono chrono(true);
	for (unsigned int i=0; i<5000; ++i)
		gpgpu->compute(result, op);
	result->save("gpgpu_computing.png");
	std::cout << chrono.getTimeElapsed() << "ms [rendering+saving]" << std::endl;
}
开发者ID:aufheben1,项目名称:visual-experiments,代码行数:19,代码来源:OgreGPGPUDemo.cpp

示例15: OnChangeName

//-----------------------------------------------------------------------
void MaterialTab::OnChangeName(wxCommandEvent& event)
{
	wxString newName = mTxtMaterialName->GetValue();
	wxString oldName = mMaterialListBox->GetStringSelection();
	Ogre::String newMaterialName = wx2ogre(newName);
	Ogre::String oldMaterialName = wx2ogre(oldName);
	Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().getByName(oldMaterialName);
	if (!material.isNull())
	{
		Ogre::MaterialPtr clonedMaterial = material->clone(newMaterialName);
		if (!clonedMaterial.isNull())
		{
			// Load the new resource, unload the old one, remove it from the list and set the new material as the selected
			clonedMaterial->load();
			Ogre::MaterialManager* materialManager = Ogre::MaterialManager::getSingletonPtr();
			materialManager->remove(oldMaterialName);
			mMaterialListBox->Delete(mMaterialListBox->GetSelection());
			mMaterialListBox->addMaterialName(newName);
			selectMaterial(newName);
		}
	}
}
开发者ID:xubingyue,项目名称:particle_universe,代码行数:23,代码来源:ParticleUniverseMaterialTab.cpp


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