コード例 #1
0
ファイル: FireModePlugin.cpp プロジェクト: aronarts/FireNET
//------------------------------------------------------------------------
void CFireModePlugin_Reject::Activate(bool activate)
{
	if (m_shellFXSpeed != 0.0f && !activate)
	{
		const SEffectParams& rejectEffect = m_pParams->rejectEffect;

		IParticleEffect* pParticleEffect = gEnv->pParticleManager->FindEffect(rejectEffect.effect[0].c_str());
		if (pParticleEffect)
		{
			ParticleParams particleParams = pParticleEffect->GetParticleParams();
			particleParams.fSpeed = m_shellFXSpeed;
			pParticleEffect->SetParticleParams(particleParams);
		}
		
		pParticleEffect = gEnv->pParticleManager->FindEffect(rejectEffect.effect[1].c_str());
		if (pParticleEffect)
		{
			ParticleParams particleParams = pParticleEffect->GetParticleParams();
			particleParams.fSpeed = m_shellFXSpeed;
			pParticleEffect->SetParticleParams(particleParams);
		}
		
		m_shellFXSpeed = 0.0f;
	}
}
コード例 #2
0
ファイル: FireModePlugin.cpp プロジェクト: aronarts/FireNET
//------------------------------------------------------------------------
void CFireModePlugin_Reject::OnShoot()
{
	const SEffectParams& rejectEffect = m_pParams->rejectEffect;
	CWeapon* pWeapon = m_pOwnerFiremode->GetWeapon();

	const int slot = pWeapon->GetStats().fp ? 0 : 1;
	const bool doRejectEffect = (g_pGameCVars->i_rejecteffects != 0) && (!rejectEffect.effect[slot].empty());

	if (doRejectEffect)
	{
		//First check if we can skip/cull the effect (not for the local player)
		if (!pWeapon->IsOwnerClient())
		{
			const CCamera& camera = gEnv->p3DEngine->GetRenderingCamera();
			const Vec3 cameraPos = camera.GetPosition();
			const Vec3 effectPosition = pWeapon->GetWorldPos();

			const float fDist2 = (cameraPos-effectPosition).len2();

			// Too far, skip
			if (fDist2 > g_pGameCVars->g_rejectEffectCullDistance)			
			{
				return; 
			}

			// Not in the view ?
			if(g_pGameCVars->g_rejectEffectVisibilityCull)
			{
				Sphere emitterSphere(effectPosition, 2.0f);
				if(camera.IsSphereVisible_F(emitterSphere) == false)
				{
					return;
				}
			}
		}

		IParticleEffect* pParticleEffect = gEnv->pParticleManager->FindEffect(rejectEffect.effect[slot].c_str());

		if (m_shellFXSpeed == 0.0f)
		{
			
			if (pParticleEffect)
			{
				const ParticleParams& particleParams = pParticleEffect->GetParticleParams();
				m_shellFXSpeed = particleParams.fSpeed.GetMaxValue();
			}
		}
		const Vec3 shellDirection = pWeapon->GetSlotHelperRotation(slot, rejectEffect.helper[slot].c_str(), true).GetColumn1();
		const Vec3 shellVelocity = m_shellHelperVelocity + (shellDirection * m_shellFXSpeed);

		EntityEffects::SEffectSpawnParams spawnParams(ZERO, shellVelocity.GetNormalized(), rejectEffect.scale[slot], shellVelocity.GetLength(), false);
		EntityEffects::SpawnParticleWithEntity(pWeapon->GetEntity(), slot, pParticleEffect, rejectEffect.helper[slot].c_str(), spawnParams);
	}
}
コード例 #3
0
ファイル: MikeBullet.cpp プロジェクト: Xydrel/Infected
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);
}