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


C++ IEntity::GetMaterial方法代码示例

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


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

示例1: ChangeEntityDiffuseTextureForMaterial

    void CCoherentUISystem::ChangeEntityDiffuseTextureForMaterial( CCoherentViewListener* pViewListener, const char* entityName, const char* materialName )
    {
        IMaterial* pMaterial = gEnv->p3DEngine->GetMaterialManager()->FindMaterial( materialName );
        IEntity* pEntity = gEnv->pEntitySystem->FindEntityByName( entityName );

        if ( pEntity && !pMaterial )
        {
            pMaterial = pEntity->GetMaterial();
        }

        if ( pMaterial )
        {
            STexSamplerRT& sampler = pMaterial->GetShaderItem().m_pShaderResources->GetTexture( EFTT_DIFFUSE )->m_Sampler;

            // Create a new texture and scrap the old one
            void* pD3DTextureDst = NULL;
            ITexture* pCryTex = gD3DSystem->CreateTexture(
                                    &pD3DTextureDst,
                                    sampler.m_pITex->GetWidth(),
                                    sampler.m_pITex->GetHeight(),
                                    1,
                                    eTF_A8R8G8B8,
                                    FT_USAGE_DYNAMIC
                                );

            int oldTextureID = sampler.m_pITex->GetTextureID();
            gEnv->pRenderer->RemoveTexture( oldTextureID );
            sampler.m_pITex = pCryTex;
            pCryTex->AddRef();

            pViewListener->SetTexture( pD3DTextureDst, pCryTex->GetTextureID() );
        }
    }
开发者ID:iherwig,项目名称:Plugin_CoherentUI,代码行数:33,代码来源:CoherentUISystem.cpp

示例2: TriggerSpark

void CLightningArc::TriggerSpark()
{
	const char* targetName = "Target";
	IEntity* pEntity = GetEntity();

	if (pEntity->GetMaterial() == 0)
	{
		GameWarning("Lightning arc '%s' has no Material, no sparks will trigger", pEntity->GetName());
		return;
	}

	IEntityLink* pLinks = pEntity->GetEntityLinks();
	int numLinks = 0;
	for (IEntityLink* link = pLinks; link; link = link->next)
	{
		if (strcmp(link->name, targetName) == 0)
			++numLinks;
	}

	if (numLinks == 0)
	{
		GameWarning("Lightning arc '%s' has no Targets, no sparks will trigger", pEntity->GetName());
		return;
	}

	int nextSpark = Random(numLinks);
	IEntityLink* pNextSparkLink = pLinks;
	for (; nextSpark && pNextSparkLink; pNextSparkLink = pNextSparkLink->next)
	{
		if (strcmp(pNextSparkLink->name, targetName) == 0)
			--nextSpark;
	}

	CLightningGameEffect::TIndex id = g_pGame->GetLightningGameEffect()->TriggerSpark(
		m_lightningPreset,
		pEntity->GetMaterial(),
		CLightningGameEffect::STarget(GetEntityId()),
		CLightningGameEffect::STarget(pNextSparkLink->entityId));
	float strikeTime = g_pGame->GetLightningGameEffect()->GetSparkRemainingTime(id);
	IScriptTable* pTargetScriptTable = 0;
	IEntity* pTarget = gEnv->pEntitySystem->GetEntity(pNextSparkLink->entityId);
	if (pTarget)
		pTargetScriptTable = pTarget->GetScriptTable();

	EntityScripts::CallScriptFunction(pEntity, pEntity->GetScriptTable(), "OnStrike", strikeTime, pTargetScriptTable);
}
开发者ID:Xydrel,项目名称:Infected,代码行数:46,代码来源:LightningArc.cpp

示例3: SetupVolume

void CGameVolume_Water::SetupVolume()
{
	IGameVolumes::VolumeInfo volumeInfo;
	if (GetVolumeInfoForEntity(GetEntityId(), volumeInfo) == false)
		return;

	if (volumeInfo.verticesCount < 3)
		return;

	WaterProperties waterProperties(GetEntity()); 

	if(waterProperties.isRiver)
	{
		if(volumeInfo.verticesCount < 4 || volumeInfo.verticesCount % 2 != 0)
			return;

		int numSegments = (volumeInfo.verticesCount / 2) - 1;

		m_segments.resize(numSegments);

		for(int i = 0; i < numSegments; ++i)
		{
			SetupVolumeSegment(waterProperties, i, &volumeInfo.pVertices[0], volumeInfo.verticesCount);
		}
	}
	else
	{
		SetupVolumeSegment(waterProperties, 0, &volumeInfo.pVertices[0], volumeInfo.verticesCount);
	}

#if CRY_PLATFORM_WINDOWS && !defined(_RELEASE)
	{
		if (gEnv->IsEditor())
		{
			IEntity* pEnt = GetEntity();
			IMaterial* pMat = pEnt ? pEnt->GetMaterial() : 0;
			if (pMat)
			{
				const SShaderItem& si = pMat->GetShaderItem();
				if (si.m_pShader && si.m_pShader->GetShaderType() != eST_Water)
				{
					CryWarning(VALIDATOR_MODULE_3DENGINE, VALIDATOR_ERROR, "Incorrect shader set for water / water fog volume \"%s\"!", pEnt->GetName());
				}
			}
		}
	}
#endif

	m_baseMatrix = GetEntity()->GetWorldTM();
	m_initialMatrix = m_baseMatrix;
	m_volumeDepth = waterProperties.depth;
	m_streamSpeed = waterProperties.streamSpeed;
	m_awakeAreaWhenMoving = waterProperties.awakeAreaWhenMoving;
	m_isRiver = waterProperties.isRiver;
}
开发者ID:NightOwlsEntertainment,项目名称:PetBox_A_Journey_to_Conquer_Elementary_Algebra,代码行数:55,代码来源:GameVolume_Water.cpp


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