Talk:Muzzle Flash (CSS Style)
Jump to navigation
Jump to search
nice but the velocity thing is kinda hacky. i took a look at the pistol code and got this:
VPROF_BUDGET( "FX_MuzzleEffect", VPROF_BUDGETGROUP_PARTICLE_RENDERING );
CSmartPtr<CSimpleEmitter> pSimple = CSimpleEmitter::Create( "MuzzleFlash" );
pSimple->SetDrawBeforeViewModel( true );
pSimple->GetBinding().SetBBox( origin - Vector( 4, 4, 4 ), origin + Vector( 4, 4, 4 ) );
Vector forward;
AngleVectors( angles, &forward, NULL, NULL );
SimpleParticle *pParticle;
Vector offset;
float flScale = random->RandomFloat( scale-0.25f, scale+0.25f );
if ( flScale < 0.5f )
{
flScale = 0.5f;
}
else if ( flScale > 8.0f )
{
flScale = 8.0f;
}
//
// Flash
//
int i;
for ( i = 1; i < 9; i++ )
{
offset = origin + (forward * (i*4.0f*flScale));
pParticle = (SimpleParticle *) pSimple->AddParticle( sizeof( SimpleParticle ), pSimple->GetPMaterial( VarArgs( "effects/muzzleflash%d", random->RandomInt(1,4) ) ), offset );
if ( pParticle == NULL )
return;
pParticle->m_flLifetime = 0.0f;
pParticle->m_flDieTime = 0.01f;
pParticle->m_vecVelocity.Init();
pParticle->m_uchColor[0] = 255;
pParticle->m_uchColor[1] = 255;
pParticle->m_uchColor[2] = 200+random->RandomInt(0,55);
pParticle->m_uchStartAlpha = 255;
pParticle->m_uchEndAlpha = 255;
pParticle->m_uchStartSize = ( (random->RandomFloat( 6.0f, 8.0f ) * (8-(i))/6) * flScale );
pParticle->m_uchEndSize = pParticle->m_uchStartSize;
pParticle->m_flRoll = random->RandomInt( 0, 360 );
pParticle->m_flRollDelta = 0.0f;
}