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


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

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


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

示例1:

void ResourceGroupReloader::UpdateMaterialRenderableVisitor::visit(
	Ogre::Renderable *rend, Ogre::ushort lodIndex, bool isDebug, Ogre::Any *pAny)
{
	const Ogre::MaterialPtr mat = rend->getMaterial();
	if(!mat.isNull())
	{
		std::string newMatName = mat->getName();
		Ogre::MaterialPtr newMat = Ogre::MaterialManager::getSingleton().getByName(newMatName);
		if(newMat.isNull())
		{
			// this can happen if there was error during the reloading of the material.
			// in that case, we keep the ancient one.
			// Ice::Log::Instance().LogMessage(newMatName+" : new material is null!");
			return;
		}

		// unfortunately, the renderable gives access only to a const MaterialPtr.
		// and there is no 'setMaterial' or 'setMaterialName' method on renderables.
		// so I have to try to down cast with known classes...
		{   
			Ogre::SubEntity* lRend = dynamic_cast<Ogre::SubEntity*>(rend);
			if(lRend){lRend->setMaterialName(newMatName);return;} 
		}
		{
			Ogre::SimpleRenderable* lRend = dynamic_cast<Ogre::SimpleRenderable*>(rend);
			if(lRend){lRend->setMaterial(newMatName);return;} 
		}
		{
			Ogre::ShadowRenderable* lRend = dynamic_cast<Ogre::ShadowRenderable*>(rend);
			if(lRend){lRend->setMaterial(newMat);return;} 
		}
		{   
			Ogre::BillboardChain* lRend = dynamic_cast<Ogre::BillboardChain*>(rend);
			if(lRend){lRend->setMaterialName(newMatName);return;} 
		}
		{   
			Ogre::BillboardSet* lRend = dynamic_cast<Ogre::BillboardSet*>(rend);
			if(lRend){lRend->setMaterialName(newMatName);return;} 
		}
		{   
			Ogre::OverlayElement* lRend = dynamic_cast<Ogre::OverlayElement*>(rend);
			if(lRend){lRend->setMaterialName(newMatName);return;} 
		}
	}else{
		// was there for debug...
		// Ice::Log::Instance().LogMessage("material of renderable is null!");
	}
}
开发者ID:JohannKollmann,项目名称:blackstar-engine,代码行数:48,代码来源:ResourceGroupReloader.cpp

示例2: ReplaceTextureOnMaterial

 void ReplaceTextureOnMaterial(Ogre::MaterialPtr material, const std::string& original_name, const std::string& texture_name)
 {
     if (material.isNull())
         return;
     
     Ogre::TextureManager &tm = Ogre::TextureManager::getSingleton();
     Ogre::TexturePtr tex = tm.getByName(texture_name);
     
     Ogre::Material::TechniqueIterator iter = material->getTechniqueIterator();
     while(iter.hasMoreElements())
     {
         Ogre::Technique *tech = iter.getNext();
         assert(tech);
         Ogre::Technique::PassIterator passIter = tech->getPassIterator();
         while(passIter.hasMoreElements())
         {
             Ogre::Pass *pass = passIter.getNext();
             
             Ogre::Pass::TextureUnitStateIterator texIter = pass->getTextureUnitStateIterator();
             
             while(texIter.hasMoreElements())
             {
                 Ogre::TextureUnitState *texUnit = texIter.getNext();
                 if (texUnit->getTextureName() == original_name)
                 {
                     if (tex.get())
                         texUnit->setTextureName(texture_name);
                     else
                         texUnit->setTextureName("TextureMissing.png");
                 }
             }
         }
     }
 }
开发者ID:Belsepubi,项目名称:naali,代码行数:34,代码来源:OgreMaterialUtils.cpp

示例3: destroyMaterial

/**
 * Destroy / unload the memory of a material
 * @param	mat		MaterialName
 */
void GUIHelper::destroyMaterial(const Ogre::String &matName)
{
	Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().getByName(matName);
	if(mat.isNull()) return;

	Ogre::Material::TechniqueIterator tit = mat->getTechniqueIterator();
	while(tit.hasMoreElements()){
		Ogre::Technique *t = tit.peekNext();
		ASSERT(t);
		Ogre::Technique::PassIterator pit = t->getPassIterator();
		while(pit.hasMoreElements()){
			Ogre::Pass *pass = pit.peekNext();
			ASSERT(pass);
			Ogre::Pass::TextureUnitStateIterator tuit =
					pass->getTextureUnitStateIterator();

			while(tuit.hasMoreElements()){
				Ogre::TextureUnitState *tus = tuit.peekNext();
				ASSERT(tus);
				const Ogre::String &textName = tus->getTextureName();
				Ogre::TextureManager::getSingleton().unload(textName);
				Ogre::TextureManager::getSingleton().remove(textName);

				tuit.moveNext();
			}
			pit.moveNext();
		}

		tit.moveNext();
	}

	Ogre::MaterialManager::getSingleton().unload(matName);
	Ogre::MaterialManager::getSingleton().remove(matName);
}
开发者ID:agudpp,项目名称:CordobaZombie,代码行数:38,代码来源:GUIHelper.cpp

示例4: load

/* Loads the app */
void ImgShowerApp::load(void)
{
	Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton();

	if(!mContainer){
		// Create a panel
		mContainer = static_cast<Ogre::OverlayContainer*>(
			overlayManager.createOverlayElement("Panel", "ImgShowerAppPanel"));
		mContainer->setMetricsMode(Ogre::GMM_RELATIVE);
		mContainer->setPosition(0, 0);
		mContainer->setDimensions(1, 1);
		mContainer->setMaterialName(mOverlayName); // Optional background material
		// Ensures that the material exists
#ifdef DEBUG
		Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().getByName(
				mOverlayName,Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME);
		ASSERT(!mat.isNull());
#endif

	}

	if(!mOverlay){
		// Create an overlay, and add the panel
		mOverlay = overlayManager.create("ImgShowerAppOverlay");
		mOverlay->add2D(mContainer);
		mOverlay->show();
	}

	// extracted from http://www.ogre3d.org/tikiwiki/Creating+Overlays+via+Code

}
开发者ID:agudpp,项目名称:CordobaZombie,代码行数:32,代码来源:ImgShowerApp.cpp

示例5: GetMaterialCopy

Ogre::MaterialPtr Renderer::GetMaterialCopy(const String& originalName, const String& newName)
{
    Ogre::MaterialPtr material = GetMaterial(originalName);
    if (material.isNull())
        return material;
    return material->clone(newName);
}
开发者ID:JamesLinus,项目名称:dawnengine,代码行数:7,代码来源:Renderer.cpp

示例6: CreateSky

void EC_Sky::CreateSky()
{
    if (!ViewEnabled())
        return;

    if (world_.expired())
        return;

    QString currentMaterial = materialRef.Get().ref;

    Ogre::MaterialPtr materialPtr = Ogre::MaterialManager::getSingleton().getByName(currentMaterial.toStdString().c_str());
    //Ogre::MaterialPtr materialPtr = Ogre::MaterialManager::getSingleton().getByName(framework->Asset()->LookupAssetRefToStorage(materialRef.Get().ref).toStdString().c_str());
    if (materialPtr.isNull())
    {
        LogError("Could not get SkyBox material : " + currentMaterial.toStdString());
        return;
    }

    materialPtr->setReceiveShadows(false);

    try
    {
        world_.lock()->GetSceneManager()->setSkyBox(true, currentMaterial.toStdString().c_str(), distance.Get(),
            drawFirst.Get(), orientation.Get());
    }
    catch(Ogre::Exception& e)
    {
        LogError("Could not set SkyBox: " + std::string(e.what()));
    }
}
开发者ID:Ilikia,项目名称:naali,代码行数:30,代码来源:EC_Sky.cpp

示例7: createOrRetrieveHaloMaterial

	gkString createOrRetrieveHaloMaterial(const gkString& baseMatName)
	{
		gkString matName = DEFAULT_HALO_MAT;

		try
		{
			gkString haloMatName = baseMatName + ".halo";
			Ogre::MaterialManager& mmgr = Ogre::MaterialManager::getSingleton();
		
			if (mmgr.resourceExists(haloMatName))
				matName = haloMatName;
			else
			{
				Ogre::MaterialPtr baseMat = mmgr.getByName(baseMatName);
				if (!baseMat.isNull())
				{
					Ogre::MaterialPtr mat = mmgr.create(haloMatName, baseMat->getGroup());
					baseMat->copyDetailsTo(mat);
					Ogre::Pass *pass = mat->getTechnique(0)->getPass(0);

					pass->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
					pass->setAlphaRejectSettings(Ogre::CMPF_GREATER_EQUAL, 150);
					pass->setDepthWriteEnabled(false);
					Ogre::TextureUnitState* tu = pass->createTextureUnitState(HALO_IMAGE_NAME);	

					matName = haloMatName;
				}
			}		
		}
		catch(Ogre::Exception& e)
		{
			gkLogMessage("gkParticleManager: " << e.getDescription());
		}
		return matName;
	}
开发者ID:Ali-il,项目名称:gamekit,代码行数:35,代码来源:gkParticleManager.cpp

示例8: resizeTexture

	void UiManager::resizeTexture(const QSize &aSize, const Ogre::MaterialPtr &aMaterial, const Ogre::TexturePtr &aTexture)
	{
		assert(!aMaterial.isNull());
		assert(!aTexture.isNull());
		
		// get the smallest power of two dimension that is at least as large as the new UI size
		Ogre::uint newTexWidth = nextHigherPowerOfTwo(aSize.width());
		Ogre::uint newTexHeight = nextHigherPowerOfTwo(aSize.height());
	
		if (!aTexture.isNull())
		{
			std::string txtrName = aTexture->getName();
			
			// remove the old texture
			aTexture->unload();
			aMaterial->getTechnique(0)->getPass(0)->removeAllTextureUnitStates();
			Ogre::TextureManager::getSingleton().remove(aTexture->getHandle());
	
			Ogre::TexturePtr newTxtr = Ogre::TextureManager::getSingleton().createManual(
					txtrName, "General", Ogre::TEX_TYPE_2D, newTexWidth, newTexHeight, 0, Ogre::PF_A8R8G8B8,
					Ogre::TU_DYNAMIC_WRITE_ONLY);
	
			// add the new texture
			Ogre::TextureUnitState* txtrUstate = aMaterial->getTechnique(0)->getPass(0)->createTextureUnitState(txtrName);
	
			// adjust it to stay aligned and scaled to the window
			Ogre::Real txtrUScale = (Ogre::Real)newTexWidth / aSize.width();
			Ogre::Real txtrVScale = (Ogre::Real)newTexHeight / aSize.height();
			txtrUstate->setTextureScale(txtrUScale, txtrVScale);
			txtrUstate->setTextureScroll((1 / txtrUScale) / 2 - 0.5, (1 / txtrVScale) / 2 - 0.5);
		}
	}
开发者ID:advancingu,项目名称:Cutexture,代码行数:32,代码来源:UiManager.cpp

示例9: enter

void SponsorsState::enter(const MainMachineInfo &info)
{
	// load the fader state
	ASSERT(!mFader);
	Ogre::OverlayManager &om = Ogre::OverlayManager::getSingleton();
	mFader = om.getByName("FaderOverlay");
	ASSERT(mFader);
	Ogre::PanelOverlayElement *panel = static_cast<Ogre::PanelOverlayElement *>(
					mFader->getChild("FaderOverlay/Background"));
	ASSERT(panel);
	Ogre::MaterialPtr mat = panel->getMaterial();
	ASSERT(!mat.isNull());
	mTexture = mat->getTechnique(0)->getPass(0)->getTextureUnitState(0);
	mTexture->setAlphaOperation(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL,
						Ogre::LBS_TEXTURE, 0);
	ASSERT(mTexture);

	// load the  sponsors Overlay
	ASSERT(!mOverlay);
	mOverlay = om.getByName("SponsorsOverlay");
	ASSERT(mOverlay);
	mOverlay->setZOrder(mFader->getZOrder() - 1);	// put behind it

	mState = STATE_FADE_IN;
}
开发者ID:agudpp,项目名称:CordobaZombie,代码行数:25,代码来源:SponsorsState.cpp

示例10: reset

void MeshResourceMarker::reset()
{
  //destroy entity
  if (entity_)
  {
    context_->getSceneManager()->destroyEntity( entity_ );
    entity_ = 0;
  }

  // destroy all the materials we've created
  S_MaterialPtr::iterator it;
  for ( it = materials_.begin(); it!=materials_.end(); it++ )
  {
    Ogre::MaterialPtr material = *it;
    if (!material.isNull())
    {
      for (size_t i = 0; i < material->getNumTechniques(); ++i)
      {
        Ogre::Technique* t = material->getTechnique(i);
        // hack hack hack, really need to do a shader-based way of picking, rather than
        // creating a texture for each object
        if (t->getSchemeName() == "Pick")
        {
          Ogre::TextureManager::getSingleton().remove(t->getPass(0)->getTextureUnitState(0)->getTextureName());
        }
      }

      material->unload();
      Ogre::MaterialManager::getSingleton().remove(material->getName());
    }
  }
  materials_.clear();
}
开发者ID:F34140r,项目名称:visualization-userfriendly,代码行数:33,代码来源:mesh_resource_marker.cpp

示例11: GetMaterialTextureNames

StringVector EC_OgreSky::GetMaterialTextureNames()
{
    StringVector texture_names;
    Ogre::MaterialPtr skyMaterial;
    switch(type_)
    {
    case OgreRenderer::SKYTYPE_BOX:
        skyMaterial = Ogre::MaterialManager::getSingleton().getByName(skyBoxParameters.material);
        break;
    case OgreRenderer::SKYTYPE_DOME:
        skyMaterial = Ogre::MaterialManager::getSingleton().getByName(skyDomeParameters.material);
        break;
    case OgreRenderer::SKYTYPE_PLANE:
        skyMaterial = Ogre::MaterialManager::getSingleton().getByName(skyPlaneParameters.material);
        break;
    }

    if (!skyMaterial.isNull())
    {
        Ogre::TextureUnitState *texture_state = skyMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0);
        if (texture_state)
            for(uint i = 0; i < texture_state->getNumFrames(); i++)
                texture_names.push_back(texture_state->getFrameTextureName(i));
        //Ogre::String textures = texture_state->getTextureName();
        //texture_names = Ogre::StringConverter::parseStringVector(textures);
    }
    return texture_names;
}
开发者ID:Belsepubi,项目名称:naali,代码行数:28,代码来源:EC_OgreSky.cpp

示例12: GetAxesMaterial

Ogre::MaterialPtr SkeletonDebug::GetAxesMaterial()
{
    Ogre::String matName = "SkeletonDebug/AxesMat";

    Ogre::MaterialPtr mAxisMatPtr =
        Ogre::MaterialManager::getSingleton().getByName(matName);

    if (mAxisMatPtr.isNull())
    {
        mAxisMatPtr = Ogre::MaterialManager::getSingleton().create(
            matName, Ogre::ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME);

        // First pass for axes that are partially within the model (shows transparency)
        Ogre::Pass* p = mAxisMatPtr->getTechnique(0)->getPass(0);
        p->setLightingEnabled(false);
        p->setPolygonModeOverrideable(false);
        p->setVertexColourTracking(Ogre::TVC_AMBIENT);
        p->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
        p->setCullingMode(Ogre::CULL_NONE);
        p->setDepthWriteEnabled(false);
        p->setDepthCheckEnabled(false);

        // Second pass for the portion of the axis that is outside the model (solid colour)
        Ogre::Pass* p2 = mAxisMatPtr->getTechnique(0)->createPass();
        p2->setLightingEnabled(false);
        p2->setPolygonModeOverrideable(false);
        p2->setVertexColourTracking(Ogre::TVC_AMBIENT);
        p2->setCullingMode(Ogre::CULL_NONE);
        p2->setDepthWriteEnabled(false);
    }

    return mAxisMatPtr;
}
开发者ID:Bewolf2,项目名称:LearningGameAI,代码行数:33,代码来源:SkeletonDebug.cpp

示例13: reset

void MeshResourceMarker::reset()
{
  //destroy entity
  if (entity_)
  {
    context_->getSceneManager()->destroyEntity(entity_);
    entity_ = 0;
  }


  // destroy all the materials we've created
  S_MaterialPtr::iterator it;
  for (it = materials_.begin(); it != materials_.end(); it++)
  {
    Ogre::MaterialPtr material = *it;
    if (!material.isNull())
    {
      material->unload();
      Ogre::MaterialManager::getSingleton().remove(material->getName());
    }
  }
  materials_.clear();
  // the actual passes are deleted by the material
  color_tint_passes_.clear();
}
开发者ID:CURG,项目名称:rviz,代码行数:25,代码来源:mesh_resource_marker.cpp

示例14:

Fade::Fade() :
mTime(1.0f),
mType(FADE_IN),
mTexture(0),
mAccumTime(0)
{
	if(!mOverlay){
		// create the shared overlay
		mOverlay = Ogre::OverlayManager::getSingleton().create("sFadeOv");
		mOverlay->show();
	}

	// create the element
	mElement = Ogre::OverlayManager::getSingleton().createOverlayElement(
			"Panel", "FdE" + Ogre::StringConverter::toString(mICounter));

	// Set the material
	mElement->setMaterialName("FaderMaterial");
	Ogre::MaterialPtr mat = mElement->getMaterial();
	ASSERT(!mat.isNull());
	mTexture = mat->getTechnique(0)->getPass(0)->getTextureUnitState(0);
	mTexture->setAlphaOperation(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL,
						Ogre::LBS_TEXTURE, 0);
	ASSERT(mTexture);

	mElement->show();

	++mICounter;
}
开发者ID:agudpp,项目名称:CordobaZombie,代码行数:29,代码来源:Fade.cpp

示例15: SetSelfIllumination

void EC_WidgetCanvas::SetSelfIllumination(bool illuminating)
{
    if (material_name_.empty())
        return;

    Ogre::ColourValue emissiveColor;
    if (illuminating)
        emissiveColor = Ogre::ColourValue(1.0f, 1.0f, 1.0f, 1.0f);
    else
        emissiveColor = Ogre::ColourValue(0.0f, 0.0f, 0.0f, 0.0f);

    Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().getByName(material_name_);
    if (!material.isNull())
    {
        Ogre::Material::TechniqueIterator iter = material->getTechniqueIterator();
        while(iter.hasMoreElements())
        {
            Ogre::Technique *tech = iter.getNext();
            if (!tech)
                continue;
            Ogre::Technique::PassIterator passIter = tech->getPassIterator();
            while(passIter.hasMoreElements())
            {
                Ogre::Pass *pass = passIter.getNext();
                if (pass)
                    pass->setSelfIllumination(emissiveColor);
            }
        }
    }
}
开发者ID:360degrees-fi,项目名称:tundra,代码行数:30,代码来源:EC_WidgetCanvas.cpp


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