Ejemplo n.º 1
0
//---------------------------------------------------------------
void CFists::CollisionFeeback(Vec3 &pos, int eFAS)
{

	CPlayer *pPlayer = static_cast<CPlayer*>(GetOwnerActor());
	if(pPlayer)
	{
		switch(eFAS)
		{
			case eFAS_RUNNING:
				pPlayer->PlaySound(CPlayer::ESound_Hit_Wall,true,true,"speed",0.4f);
				break;

			case eFAS_JUMPING:
				pPlayer->PlaySound(CPlayer::ESound_Hit_Wall,true,true,"speed",0.8f);
				break;

			default:
				break;
		}
	}

	//FX feedback
	IParticleEffect *pEffect = gEnv->pParticleManager->FindEffect("collisions.footsteps.dirt");
	if (pEffect)
	{
		Matrix34 tm = IParticleEffect::ParticleLoc(pos);
		pEffect->Spawn(true,tm);
	}	
}
void CMFXParticleEffect::Execute(const SMFXRunTimeEffectParams& params)
{
  FUNCTION_PROFILER(gEnv->pSystem, PROFILE_ACTION);

  Vec3 pos = params.pos;
	Vec3 dir = ZERO;
	Vec3 inDir = params.dir[0];
	Vec3 reverso = inDir * -1.0f;
	switch (m_particleParams.directionType)
	{
	case SMFXParticleParams::eDT_Normal:
		dir = params.normal;
		break;
	case SMFXParticleParams::eDT_Ricochet:
		dir = reverso.GetRotated(params.normal, gf_PI).normalize();
		break;
	default:
		dir = params.normal;
		break;
	}
 
  bool tryToAttachEffect = (CMaterialEffectsCVars::Get().mfx_EnableAttachedEffects != 0);
  float distToPlayer = 0.f;
  IActor *pClientActor = gEnv->pGame->GetIGameFramework()->GetClientActor();
  if (pClientActor)
  {
    distToPlayer = (pClientActor->GetEntity()->GetWorldPos() - params.pos).GetLength();
	tryToAttachEffect = tryToAttachEffect && (pClientActor->GetEntityId() != params.trg);
  }
  
  SMFXParticleEntries::const_iterator end = m_particleParams.m_entries.end();
  for (SMFXParticleEntries::const_iterator it = m_particleParams.m_entries.begin(); it!=end; ++it)
  {
    // choose effect based on distance
    if ((it->maxdist == 0.f) || (distToPlayer <= it->maxdist) && !it->name.empty() )
    { 
      IParticleEffect *pParticle = gEnv->pParticleManager->FindEffect(it->name.c_str());

      if (pParticle)
      {
        const float pfx_minscale = (it->minscale != 0.f) ? it->minscale : CMaterialEffectsCVars::Get().mfx_pfx_minScale;
        const float pfx_maxscale = (it->maxscale != 0.f) ? it->maxscale : CMaterialEffectsCVars::Get().mfx_pfx_maxScale; 
        const float pfx_maxdist = (it->maxscaledist != 0.f) ? it->maxscaledist : CMaterialEffectsCVars::Get().mfx_pfx_maxDist; 
                
        const float truscale = pfx_minscale + ((pfx_maxscale - pfx_minscale) * (distToPlayer!=0.f ? min(1.0f, distToPlayer/pfx_maxdist) : 1.f));  

		bool particleSpawnedAndAttached = tryToAttachEffect ? AttachToTarget(*it, params, pParticle, dir, truscale) : false;

        // If not attached, just spawn the particle
		if (particleSpawnedAndAttached == false)
		{
			pParticle->Spawn( true, IParticleEffect::ParticleLoc(pos, dir, truscale) );
		}
      }
      
      break;
    }
  }
}
Ejemplo n.º 3
0
void CBurnEffectManager::SpawnImpactEffect(const EventPhysCollision& pCollision, const char* effectName)
{
	Vec3 surfaceNormal = pCollision.n;
	Vec3 surfacePosition = pCollision.pt;

	CItemParticleEffectCache& particleCache = g_pGame->GetGameSharedParametersStorage()->GetItemResourceCache().GetParticleEffectCache();
	IParticleEffect* pParticleEffect = particleCache.GetCachedParticle(effectName);

	if (pParticleEffect)
	{
		Matrix34 loc;
		loc.SetIdentity();
		loc.SetTranslation(surfacePosition);
		loc.SetRotation33(OrthoNormalVector(surfaceNormal));
		pParticleEffect->Spawn(false, loc);
	}
}
Ejemplo n.º 4
0
void CBurnEffectManager::CreateBurnEffect(const EventPhysCollision& pCollision, CBurnEffectManager::SBurnPoint* pBurnPoint)
{
	Vec3 surfaceNormal = pCollision.n;
	Vec3 hitDir(ZERO);
	if (pCollision.vloc[0].GetLengthSquared() > 1e-6f)
	{
		hitDir = pCollision.vloc[0].GetNormalized();
	}
	Vec3 surfacePosition = pCollision.pt;
	Vec3 halfVector = (surfaceNormal + (-hitDir)).GetNormalized();

	CItemParticleEffectCache& particleCache = g_pGame->GetGameSharedParametersStorage()->GetItemResourceCache().GetParticleEffectCache();
	IParticleEffect* pParticleEffect = particleCache.GetCachedParticle(pBurnPoint->m_pBurnParams->m_effectName);

	if (pParticleEffect)
	{
		Matrix34 loc;
		loc.SetIdentity();
		loc.SetTranslation(surfacePosition);
		loc.SetRotation33(OrthoNormalVector(surfaceNormal));
		IParticleEmitter* pEffect = pParticleEffect->Spawn(false, loc);
		if(pEffect)
		{
			pEffect->AddRef();
			pBurnPoint->m_effect = pEffect;

			const ParticleParams& particleParams = pParticleEffect->GetParticleParams();

			pBurnPoint->m_attachType = particleParams.eAttachType;
			pBurnPoint->m_attachForm = particleParams.eAttachForm;
		}
		UpdateBurnEffect(pBurnPoint);
	}
	
	UpdateBurnEffect(pBurnPoint);
}
Ejemplo n.º 5
0
//------------------------------------------------------------------------
void CItem::SpawnEffect(int slot, const char *effectName, const char *helper, const Vec3 &offset, const Vec3 &dir, float scale)
{
	if (m_stats.mounted)
		slot=eIGS_FirstPerson;

	Vec3 position(0,0,0);
	Vec3 finalOffset = offset;

  SEntitySlotInfo slotInfo;
  if (GetEntity()->GetSlotInfo(slot, slotInfo))
  {
    if (slotInfo.pStatObj)	// entity slot
    {
      // get helper position
      IStatObj *pStatsObj = slotInfo.pStatObj;
      position = pStatsObj->GetHelperPos(helper);

			position = GetEntity()->GetSlotWorldTM(slot).TransformPoint(position);
    }
    else if (slotInfo.pCharacter)	// bone attachment
    {
      ICharacterInstance *pCharacter = slotInfo.pCharacter;
      IAttachmentManager *pAttachmentManager = pCharacter->GetIAttachmentManager();
      IAttachment *pAttachment = pAttachmentManager->GetInterfaceByName(helper);

      if (pAttachment)
      {
        const Matrix34 m = Matrix34(pAttachment->GetAttWorldAbsolute());
        position = m.GetTranslation();
      }
      else
      {
        int16 id = pCharacter->GetISkeletonPose()->GetJointIDByName(helper);
        if (id>=0)
          position = pCharacter->GetISkeletonPose()->GetAbsJointByID(id).t;

				position = GetEntity()->GetSlotWorldTM(slot).TransformPoint(position);
      }
    }
  }
	else if(m_stats.mounted && !m_stats.fp)
	{
		if(GetIWeapon())
		{
				// if no helper specified, try getting pos from firing locator
				IWeaponFiringLocator *pLocator = GetIWeapon()->GetFiringLocator();            

				if (pLocator)
				{
					if(!pLocator->GetFiringPos(GetEntityId(), NULL, position))
						position.Set(0.0f,0.0f,0.0f);
					else
						finalOffset = GetEntity()->GetWorldTM().TransformVector(finalOffset);
				}

		}
	}

	position += finalOffset;

	IParticleEffect *pParticleEffect = gEnv->pParticleManager->FindEffect(effectName);
	if (pParticleEffect)
		pParticleEffect->Spawn(true, IParticleEffect::ParticleLoc(position, dir, scale));
}