//-----------------------------------------------------------------------------
// Purpose: 
// Input  : *pInParticle - 
//			*pDraw - 
//			&sortKey - 
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
bool C_PerfTest::SimulateAndRender(Particle *pInParticle, ParticleDraw *pDraw, float &sortKey)
{
	PerfTestParticle *pParticle = (PerfTestParticle*)pInParticle;

	// Render.
	Vector tPos;
	TransformParticle(m_pParticleMgr->GetModelView(), pParticle->m_Pos, tPos);
	sortKey = tPos.z;

	Vector vColor( 0, 0, 0 );
	for( int i=0; i < NUM_LIGHTS; i++ )
	{
		float fDist = pParticle->m_Pos.DistToSqr( m_LightPos[i] );
		float fAmt;
		if( fDist > 0.0001f )
			fAmt = m_LightIntensity[i] / fDist;
		else
			fAmt = 1000;

		vColor += m_LightColor[i] * fAmt;
	}
	vColor = vColor.Min( Vector(255.1,255.1,255.1) );

	RenderParticle_Color255Size(
		pDraw,
		tPos,
		vColor,		// color
		255,		// alpha
		1			// size
		);

	return true;
}
Beispiel #2
0
void CDustEffect::RenderParticles( CParticleRenderIterator *pIterator )
{
	const CFuncDustParticle *pParticle = (const CFuncDustParticle*)pIterator->GetFirst();
	while ( pParticle )
	{
		// Velocity.
		float flAlpha;
		if( m_pDust->m_DustFlags & DUSTFLAGS_FROZEN )
		{
			flAlpha = 1;
		}
		else
		{
			// Alpha.
			float flAngle = (pParticle->m_flLifetime / pParticle->m_flDieTime) * M_PI * 2;
			flAlpha = sin( flAngle - (M_PI * 0.5f) ) * 0.5f + 0.5f;
		}

		Vector tPos;
		TransformParticle( ParticleMgr()->GetModelView(), pParticle->m_Pos, tPos );
		float sortKey = (int) tPos.z;

		if( -tPos.z <= m_pDust->m_DistMax )
		{
			flAlpha *= 1 + (tPos.z / m_pDust->m_DistMax);

			// Draw it.
			float flSize = pParticle->m_flSize;
			if( m_pDust->m_DustFlags & DUSTFLAGS_SCALEMOTES )
				flSize *= -tPos.z;

			RenderParticle_Color255Size(
				pIterator->GetParticleDraw(),
				tPos,
				Vector( m_pDust->m_Color.r, m_pDust->m_Color.g, m_pDust->m_Color.b ),
				flAlpha * m_pDust->m_Color.a,
				flSize
				);
		}

		pParticle = (const CFuncDustParticle*)pIterator->GetNext( sortKey );
	}
}