本文整理汇总了C++中TimedEvent::NextEvent方法的典型用法代码示例。如果您正苦于以下问题:C++ TimedEvent::NextEvent方法的具体用法?C++ TimedEvent::NextEvent怎么用?C++ TimedEvent::NextEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimedEvent
的用法示例。
在下文中一共展示了TimedEvent::NextEvent方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
//-----------------------------------------------------------------------------
// Purpose:
// Input : fTimeDelta -
//-----------------------------------------------------------------------------
void C_Plasma::Update( void )
{
//Update all our parts
UpdateScale();
UpdateAnimation();
UpdateFlames();
if (m_flScaleRegister > 0.1)
{
float tempDelta = gpGlobals->frametime;
while( m_tDecalSpawn.NextEvent( tempDelta ) )
{
// Add decal to floor
C_BaseEntity *ent = cl_entitylist->GetEnt( 0 );
if ( ent )
{
int index = decalsystem->GetDecalIndexForName( "PlasmaGlowFade" );
if ( index >= 0 )
{
effects->DecalShoot( index, 0, ent->GetModel(), ent->GetAbsOrigin(), ent->GetAbsAngles(), GetAbsOrigin(), 0, 0 );
}
}
}
}
}
示例2: Update
//-----------------------------------------------------------------------------
// Purpose:
// Input : fTimeDelta -
//-----------------------------------------------------------------------------
void C_SmokeStack::Update(float fTimeDelta)
{
if (!m_pParticleMgr)
{
assert(false);
return;
}
// Don't spawn particles unless we're visible.
if (m_bEmit && (m_ParticleEffect.WasDrawnPrevFrame() || m_ParticleEffect.GetAlwaysSimulate()))
{
// Add new particles.
Vector forward, right, up;
AngleVectors(GetAbsAngles(), &forward, &right, &up);
float tempDelta = fTimeDelta;
while (m_ParticleSpawn.NextEvent(tempDelta))
{
int iRandomFrame = random->RandomInt(0, m_iMaxFrames);
iRandomFrame = 0;
// Make a new particle.
if (SmokeStackParticle *pParticle = (SmokeStackParticle*) m_ParticleEffect.AddParticle(sizeof(SmokeStackParticle), m_MaterialHandle[iRandomFrame]))
{
float angle = FRand(0, 2.0f*M_PI_F);
pParticle->m_Pos = GetAbsOrigin() +
right * (cos(angle) * m_flBaseSpread) +
forward * (sin(angle) * m_flBaseSpread);
pParticle->m_Velocity =
FRand(-m_SpreadSpeed, m_SpreadSpeed) * right +
FRand(-m_SpreadSpeed, m_SpreadSpeed) * forward +
m_Speed * up;
pParticle->m_vAccel = m_vWind;
pParticle->m_Lifetime = 0;
pParticle->m_flAngle = 0.0f;
pParticle->m_flRollDelta = random->RandomFloat(-m_flRollSpeed, m_flRollSpeed);
pParticle->m_flSortPos = pParticle->m_Pos.z;
}
}
}
// Setup the twist matrix.
float flTwist = (m_flTwist * (M_PI_F * 2.f) / 360.0f) * Helper_GetFrameTime();
if ((m_bTwist = !!flTwist))
{
m_TwistMat[0][0] = cos(flTwist);
m_TwistMat[0][1] = sin(flTwist);
m_TwistMat[1][0] = -sin(flTwist);
m_TwistMat[1][1] = cos(flTwist);
}
QueueLightParametersInRenderer();
}
示例3: Update
//-----------------------------------------------------------------------------
// Purpose:
// Input : fTimeDelta -
//-----------------------------------------------------------------------------
void C_EntityParticleTrail::Update( float fTimeDelta )
{
float tempDelta = fTimeDelta;
studiohdr_t *pStudioHdr;
mstudiohitboxset_t *set;
matrix3x4_t *hitboxbones[MAXSTUDIOBONES];
C_BaseEntity *pMoveParent = GetMoveParent();
if ( !pMoveParent )
return;
C_BaseAnimating *pAnimating = pMoveParent->GetBaseAnimating();
if (!pAnimating)
goto trailNoHitboxes;
if ( !pAnimating->HitboxToWorldTransforms( hitboxbones ) )
goto trailNoHitboxes;
pStudioHdr = modelinfo->GetStudiomodel( pAnimating->GetModel() );
if (!pStudioHdr)
goto trailNoHitboxes;
set = pStudioHdr->pHitboxSet( pAnimating->GetHitboxSet() );
if ( !set )
goto trailNoHitboxes;
//Add new particles
while ( m_teParticleSpawn.NextEvent( tempDelta ) )
{
int nHitbox = random->RandomInt( 0, set->numhitboxes - 1 );
mstudiobbox_t *pBox = set->pHitbox(nHitbox);
AddParticle( tempDelta, pBox->bbmin, pBox->bbmax, *hitboxbones[pBox->bone] );
}
return;
trailNoHitboxes:
while ( m_teParticleSpawn.NextEvent( tempDelta ) )
{
AddParticle( tempDelta, pMoveParent->CollisionProp()->OBBMins(), pMoveParent->CollisionProp()->OBBMaxs(), pMoveParent->EntityToWorldTransform() );
}
}
示例4: ClientThink
//-----------------------------------------------------------------------------
// Purpose: Client-side think function for the entity
//-----------------------------------------------------------------------------
void C_Sparkler::ClientThink( void )
{
// We must have a valid emitter
if ( m_hEmitter == NULL )
return;
// We must be allowed to emit particles by the server
if ( m_bEmit == false )
return;
SimpleParticle *pParticle;
float curTime = gpGlobals->frametime;
// Add as many particles as required this frame
while ( m_tParticleTimer.NextEvent( curTime ) )
{
// Create the particle
pParticle = m_hEmitter->AddSimpleParticle( m_hMaterial, GetAbsOrigin() );
if ( pParticle == NULL )
return;
// Setup our size
pParticle->m_uchStartSize = (unsigned char) m_flScale;
pParticle->m_uchEndSize = 0;
// Setup our roll
pParticle->m_flRoll = random->RandomFloat( 0, 2*M_PI );
pParticle->m_flRollDelta = random->RandomFloat( -DEG2RAD( 180 ), DEG2RAD( 180 ) );
// Set our color
pParticle->m_uchColor[0] = 255;
pParticle->m_uchColor[1] = 255;
pParticle->m_uchColor[2] = 255;
// Setup our alpha values
pParticle->m_uchStartAlpha = 255;
pParticle->m_uchEndAlpha = 255;
// Obtain a random direction
Vector velocity = RandomVector( -1.0f, 1.0f );
VectorNormalize( velocity );
// Obtain a random speed
float speed = random->RandomFloat( 4.0f, 8.0f ) * m_flScale;
// Set our velocity
pParticle->m_vecVelocity = velocity * speed;
// Die in a short range of time
pParticle->m_flDieTime = random->RandomFloat( 0.25f, 0.5f );
}
}
示例5: Simulate
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void C_EntityFlame::Simulate( void )
{
if (m_bAttachedToHitboxes)
{
UpdateHitBoxFlames();
}
else
{
m_pEmitter->SetSortOrigin( GetAbsOrigin() );
float tempDelta = gpGlobals->frametime;
SimpleParticle *pParticle;
Vector offset;
while( m_ParticleSpawn.NextEvent( tempDelta ) )
{
offset.Random( -m_flSize, m_flSize );
pParticle = (SimpleParticle *) m_pEmitter->AddParticle( sizeof(SimpleParticle), m_MaterialHandle[random->RandomInt( 0, NUM_FLAMELETS-1 )], GetAbsOrigin() + offset );
if ( pParticle )
{
pParticle->m_flDieTime = 0.4f;
pParticle->m_flLifetime = 0.0f;
pParticle->m_flRoll = random->RandomInt( 0, 360 );
pParticle->m_flRollDelta= random->RandomFloat( -2.0f, 2.0f );
pParticle->m_uchStartSize = random->RandomInt( 4, 6 );
pParticle->m_uchEndSize = random->RandomInt( 12, 16 );
pParticle->m_uchStartAlpha = 255;
pParticle->m_uchEndAlpha = 0;
int cScale = 255;//random->RandomInt( 192, 255 );
pParticle->m_uchColor[0] = cScale;
pParticle->m_uchColor[1] = cScale;
pParticle->m_uchColor[2] = cScale;
Vector dir;
dir.x = random->RandomFloat( -1.0f, 1.0f );
dir.y = random->RandomFloat( -1.0f, 1.0f );
dir.z = random->RandomFloat( 0.5f, 1.0f );
pParticle->m_vecVelocity = dir * random->RandomInt( 4, 32 );
pParticle->m_vecVelocity[2] = random->RandomInt( 32, 64 );
}
}
}
}
示例6: AddRisingParticles
//-----------------------------------------------------------------------------
// Purpose:
// Input : flPerc -
//-----------------------------------------------------------------------------
void C_MortarShell::AddRisingParticles( float flPerc )
{
SimpleParticle *sParticle;
Vector offset;
float radius = m_flRadius * 0.25f * flPerc;
float val = RemapValClamped( gpGlobals->curtime, m_flStarttime, m_flStarttime + m_flLifespan, 0.0f, 1.0f );
float flCur = gpGlobals->frametime;
// Anime ground effects
while ( m_ParticleEvent.NextEvent( flCur ) )
{
offset.x = random->RandomFloat( -radius, radius );
offset.y = random->RandomFloat( -radius, radius );
offset.z = random->RandomFloat( -8.0f, 8.0f );
offset += GetAbsOrigin();
sParticle = (SimpleParticle *) m_pEmitter->AddParticle( sizeof(SimpleParticle), m_pEmitter->GetPMaterial( "effects/spark" ), offset );
if ( sParticle == NULL )
return;
sParticle->m_vecVelocity = Vector( Helper_RandomFloat( -4.0f, 4.0f ), Helper_RandomFloat( -4.0f, 4.0f ), Helper_RandomFloat( 32.0f, 256.0f ) * Bias( val, 0.25f ) );
sParticle->m_uchStartSize = random->RandomFloat( 4, 8 ) * flPerc;
sParticle->m_flDieTime = random->RandomFloat( 0.5f, 1.0f );
sParticle->m_flLifetime = 0.0f;
sParticle->m_flRoll = Helper_RandomInt( 0, 360 );
float alpha = 255 * flPerc;
sParticle->m_flRollDelta = Helper_RandomFloat( -8.0f * flPerc, 8.0f * flPerc );
sParticle->m_uchColor[0] = alpha;
sParticle->m_uchColor[1] = alpha;
sParticle->m_uchColor[2] = alpha;
sParticle->m_uchStartAlpha = alpha;
sParticle->m_uchEndAlpha = 0;
sParticle->m_uchEndSize = 0;
}
}
示例7: AddExplodingParticles
//-----------------------------------------------------------------------------
// Purpose:
// Input : flPerc -
//-----------------------------------------------------------------------------
void C_MortarShell::AddExplodingParticles( float flPerc )
{
SimpleParticle *sParticle;
Vector offset;
float radius = 48.0f * flPerc;
float flCur = gpGlobals->frametime;
// Anime ground effects
while ( m_ParticleEvent.NextEvent( flCur ) )
{
offset.x = random->RandomFloat( -radius, radius );
offset.y = random->RandomFloat( -radius, radius );
offset.z = random->RandomFloat( -8.0f, 8.0f );
offset += GetAbsOrigin();
sParticle = (SimpleParticle *) m_pEmitter->AddParticle( sizeof(SimpleParticle), m_pEmitter->GetPMaterial( "effects/spark" ), offset );
if ( sParticle == NULL )
return;
sParticle->m_vecVelocity = RandomVector( -1.0f, 1.0f ) + Vector( 0, 0, 1 );
sParticle->m_vecVelocity *= ( 750.0f * flPerc );
sParticle->m_uchStartSize = random->RandomFloat( 2, 4 ) * flPerc;
sParticle->m_flDieTime = random->RandomFloat( 0.25f, 0.5f );
sParticle->m_flLifetime = 0.0f;
sParticle->m_flRoll = Helper_RandomInt( 0, 360 );
float alpha = 255 * flPerc;
sParticle->m_flRollDelta = Helper_RandomFloat( -8.0f * flPerc, 8.0f * flPerc );
sParticle->m_uchColor[0] = alpha;
sParticle->m_uchColor[1] = alpha;
sParticle->m_uchColor[2] = alpha;
sParticle->m_uchStartAlpha = alpha;
sParticle->m_uchEndAlpha = 0;
sParticle->m_uchEndSize = 0;
}
}
示例8: Update
//-----------------------------------------------------------------------------
// Purpose:
// Input : fTimeDelta -
//-----------------------------------------------------------------------------
void C_ExtinguisherJet::Update( float fTimeDelta )
{
if ( m_bEmit == false )
return;
C_BasePlayer *player = C_BasePlayer::GetLocalPlayer();
if ( m_bUseMuzzlePoint )
{
C_BaseViewModel *vm = player ? player->GetViewModel( 0 ) : NULL;
if ( vm )
{
int iAttachment = vm->LookupAttachment( "muzzle" );
Vector origin;
QAngle angles;
vm->GetAttachment( iAttachment, origin, angles );
Assert( !GetMoveParent() );
SetLocalOrigin( origin );
SetLocalAngles( angles );
}
}
trace_t tr;
Vector shotDir, vRight, vUp;
AngleVectors( GetAbsAngles(), &shotDir, &vRight, &vUp );
//FIXME: Muzzle point is incorrect on the model!
if ( m_bUseMuzzlePoint )
{
shotDir.Negate();
}
Vector endPoint = GetAbsOrigin() + ( shotDir * 150.0f );
UTIL_TraceLine( GetAbsOrigin(), endPoint, MASK_SHOT, NULL, COLLISION_GROUP_NONE, &tr );
bool hitWall = ( tr.fraction < 1.0f );
//Add normal jet
if ( m_pEmitter.IsValid() )
{
SimpleParticle *pParticle;
m_pEmitter->SetSortOrigin( GetAbsOrigin() );
float tempDelta = fTimeDelta;
//FIXME: All particles need to be within this loop
while( m_ParticleSpawn.NextEvent( tempDelta ) )
{
pParticle = (SimpleParticle *) m_pEmitter->AddParticle( sizeof(SimpleParticle), m_MaterialHandle, GetAbsOrigin() );
if ( pParticle )
{
pParticle->m_flDieTime = 0.2f;
pParticle->m_flLifetime = 0.0f;
pParticle->m_flRoll = random->RandomInt( 0, 360 );
pParticle->m_flRollDelta= random->RandomFloat( -4.0f, 4.0f );
pParticle->m_uchStartSize = 1;
pParticle->m_uchEndSize = random->RandomInt( 32, 48 );
pParticle->m_uchStartAlpha = random->RandomInt( 128, 164 );
pParticle->m_uchEndAlpha = 0;
int cScale = random->RandomInt( 192, 255 );
pParticle->m_uchColor[0] = cScale;
pParticle->m_uchColor[1] = cScale;
pParticle->m_uchColor[2] = cScale;
Vector dir;
QAngle ofsAngles;
ofsAngles.Random( -8.0f, 8.0f );
ofsAngles += GetAbsAngles();
AngleVectors( ofsAngles, &dir );
if ( m_bUseMuzzlePoint )
{
dir.Negate();
}
pParticle->m_vecVelocity = dir * random->RandomInt( 400, 800 );
}
//Add muzzle effect
pParticle = (SimpleParticle *) m_pEmitter->AddParticle( sizeof(SimpleParticle), m_MaterialHandle, GetAbsOrigin() );
if ( pParticle )
{
pParticle->m_flDieTime = 0.1f;
pParticle->m_flLifetime = 0.0f;
//.........这里部分代码省略.........
示例9: AddParticles
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void C_HopwireExplosion::AddParticles( void )
{
// Make sure the emitters are setup properly
if ( SetupEmitters() == false )
return;
float tempDelta = gpGlobals->frametime;
while( m_ParticleTimer.NextEvent( tempDelta ) )
{
// ========================
// Attracted dust particles
// ========================
// Update our attractor point
m_pAttractorEmitter->SetAttractorOrigin( GetRenderOrigin() );
Vector offset;
SimpleParticle *sParticle;
offset = GetRenderOrigin() + RandomVector( -256.0f, 256.0f );
sParticle = (SimpleParticle *) m_pAttractorEmitter->AddParticle( sizeof(SimpleParticle), g_Mat_Fleck_Cement[0], offset );
if ( sParticle == NULL )
return;
sParticle->m_vecVelocity = Vector(0,0,8);
sParticle->m_flDieTime = 0.5f;
sParticle->m_flLifetime = 0.0f;
sParticle->m_flRoll = Helper_RandomInt( 0, 360 );
sParticle->m_flRollDelta = 1.0f;
float alpha = random->RandomFloat( 128.0f, 200.0f );
sParticle->m_uchColor[0] = alpha;
sParticle->m_uchColor[1] = alpha;
sParticle->m_uchColor[2] = alpha;
sParticle->m_uchStartAlpha = alpha;
sParticle->m_uchEndAlpha = alpha;
sParticle->m_uchStartSize = random->RandomInt( 1, 4 );
sParticle->m_uchEndSize = 0;
// ========================
// Core effects
// ========================
// Reset our sort origin
m_pSimpleEmitter->SetSortOrigin( GetRenderOrigin() );
// Base of the core effect
sParticle = (SimpleParticle *) m_pSimpleEmitter->AddParticle( sizeof(SimpleParticle), m_pSimpleEmitter->GetPMaterial( "effects/strider_muzzle" ), GetRenderOrigin() );
if ( sParticle == NULL )
return;
sParticle->m_vecVelocity = vec3_origin;
sParticle->m_flDieTime = 0.2f;
sParticle->m_flLifetime = 0.0f;
sParticle->m_flRoll = Helper_RandomInt( 0, 360 );
sParticle->m_flRollDelta = 4.0f;
alpha = random->RandomInt( 32, 200 );
sParticle->m_uchColor[0] = alpha;
sParticle->m_uchColor[1] = alpha;
sParticle->m_uchColor[2] = alpha;
sParticle->m_uchStartAlpha = 0;
sParticle->m_uchEndAlpha = alpha;
sParticle->m_uchStartSize = 255;
sParticle->m_uchEndSize = 0;
// Make sure we encompass the complete particle here!
m_pSimpleEmitter->SetParticleCullRadius( sParticle->m_uchEndSize );
// =========================
// Dust ring effect
// =========================
if ( random->RandomInt( 0, 5 ) != 1 )
return;
Vector vecDustColor;
vecDustColor.x = 0.35f;
vecDustColor.y = 0.3f;
vecDustColor.z = 0.25f;
Vector color;
int numRingSprites = 8;
float yaw;
Vector forward, vRight, vForward;
vForward = Vector( 0, 1, 0 );
//.........这里部分代码省略.........
示例10: UpdateDischarging
//-----------------------------------------------------------------------------
// Purpose:
// Input : percentage -
//-----------------------------------------------------------------------------
void C_AlyxEmpEffect::UpdateDischarging( void )
{
// Emitters must be valid
if ( SetupEmitters() == false )
return;
// Reset our sort origin
m_pSimpleEmitter->SetSortOrigin( GetAbsOrigin() );
float flScale = EMP_SCALE * 8.0f;
Vector forward, right, up;
AngleVectors( GetAbsAngles(), &forward, &right, &up );
SimpleParticle *sParticle;
float dTime = gpGlobals->frametime;
while ( m_tParticleSpawn.NextEvent( dTime ) )
{
// Base of the core effect
sParticle = (SimpleParticle *) m_pSimpleEmitter->AddParticle( sizeof(SimpleParticle), m_pSimpleEmitter->GetPMaterial( EMP_PARTICLES ), GetAbsOrigin() );
if ( sParticle == NULL )
return;
sParticle->m_vecVelocity = vec3_origin;
sParticle->m_flDieTime = 0.25f;
sParticle->m_flLifetime = 0.0f;
sParticle->m_flRoll = Helper_RandomInt( 0, 360 );
sParticle->m_flRollDelta = 0.0f;
float alpha = 64;
sParticle->m_uchColor[0] = alpha;
sParticle->m_uchColor[1] = alpha;
sParticle->m_uchColor[2] = alpha;
sParticle->m_uchStartAlpha = alpha;
sParticle->m_uchEndAlpha = 0;
sParticle->m_uchStartSize = flScale * 4.0f;
sParticle->m_uchEndSize = 0.0f;
// Base of the core effect
sParticle = (SimpleParticle *) m_pSimpleEmitter->AddParticle( sizeof(SimpleParticle), m_pSimpleEmitter->GetPMaterial( EMP_PARTICLES ), GetAbsOrigin() );
if ( sParticle == NULL )
return;
sParticle->m_vecVelocity = vec3_origin;
sParticle->m_flDieTime = 0.1f;
sParticle->m_flLifetime = 0.0f;
sParticle->m_flRoll = Helper_RandomInt( 0, 360 );
sParticle->m_flRollDelta = 0.0f;
alpha = 128;
sParticle->m_uchColor[0] = alpha;
sParticle->m_uchColor[1] = alpha;
sParticle->m_uchColor[2] = alpha;
sParticle->m_uchStartAlpha = alpha;
sParticle->m_uchEndAlpha = 0;
sParticle->m_uchStartSize = 0.0f;
sParticle->m_uchEndSize = flScale * 2.0f;
// Make sure we encompass the complete particle here!
m_pSimpleEmitter->SetParticleCullRadius( sParticle->m_uchEndSize );
// Do the core effects
sParticle = (SimpleParticle *) m_pSimpleEmitter->AddParticle( sizeof(SimpleParticle), m_pSimpleEmitter->GetPMaterial( EMP_PARTICLES ), GetAbsOrigin() );
if ( sParticle == NULL )
return;
sParticle->m_vecVelocity = RandomVector( -32.0f, 32.0f );
sParticle->m_flDieTime = 0.2f;
sParticle->m_flLifetime = 0.0f;
sParticle->m_flRoll = Helper_RandomInt( 0, 360 );
sParticle->m_flRollDelta = 0.0f;
alpha = 255;
sParticle->m_uchColor[0] = alpha;
sParticle->m_uchColor[1] = alpha;
sParticle->m_uchColor[2] = alpha;
sParticle->m_uchStartAlpha = alpha;
sParticle->m_uchEndAlpha = 0;
sParticle->m_uchStartSize = flScale;
sParticle->m_uchEndSize = 0.0f;
}
//.........这里部分代码省略.........
示例11: UpdateCharging
//-----------------------------------------------------------------------------
// Purpose:
// Input : percentage -
//-----------------------------------------------------------------------------
void C_AlyxEmpEffect::UpdateCharging( float percentage )
{
// Emitters must be valid
if ( SetupEmitters() == false )
return;
if ( percentage <= 0.0f )
return;
// Reset our sort origin
m_pSimpleEmitter->SetSortOrigin( GetAbsOrigin() );
float flScale = 4.0f * EMP_SCALE * percentage;
SimpleParticle *sParticle;
float dTime = gpGlobals->frametime;
while ( m_tParticleSpawn.NextEvent( dTime ) )
{
// Do the core effects
sParticle = (SimpleParticle *) m_pSimpleEmitter->AddParticle( sizeof(SimpleParticle), m_pSimpleEmitter->GetPMaterial( EMP_PARTICLES ), GetAbsOrigin() );
if ( sParticle == NULL )
return;
sParticle->m_vecVelocity = vec3_origin;
sParticle->m_flDieTime = 0.1f;
sParticle->m_flLifetime = 0.0f;
sParticle->m_flRoll = Helper_RandomInt( 0, 360 );
sParticle->m_flRollDelta = 0.0f;
float alpha = 255 * percentage;
sParticle->m_uchColor[0] = alpha;
sParticle->m_uchColor[1] = alpha;
sParticle->m_uchColor[2] = alpha;
sParticle->m_uchStartAlpha = alpha;
sParticle->m_uchEndAlpha = 0;
sParticle->m_uchStartSize = flScale;
sParticle->m_uchEndSize = sParticle->m_uchStartSize * 2.0f;
}
#if 0
// Do the charging particles
m_pAttractorEmitter->SetAttractorOrigin( GetAbsOrigin() );
Vector forward, right, up;
AngleVectors( GetAbsAngles(), &forward, &right, &up );
Vector offset;
float dist;
int numParticles = floor( 4.0f * percentage );
for ( i = 0; i < numParticles; i++ )
{
dist = random->RandomFloat( 4.0f * percentage, 64.0f * percentage );
offset = forward * dist;
dist = RemapValClamped( dist, 4.0f * percentage, 64.0f * percentage, 6.0f, 1.0f );
offset += right * random->RandomFloat( -4.0f * dist, 4.0f * dist );
offset += up * random->RandomFloat( -4.0f * dist, 4.0f * dist );
offset += GetAbsOrigin();
sParticle = (SimpleParticle *) m_pAttractorEmitter->AddParticle( sizeof(SimpleParticle), m_pAttractorEmitter->GetPMaterial( EMP_PARTICLES ), offset );
if ( sParticle == NULL )
return;
sParticle->m_vecVelocity = Vector(0,0,8);
sParticle->m_flDieTime = 0.5f;
sParticle->m_flLifetime = 0.0f;
sParticle->m_flRoll = Helper_RandomInt( 0, 360 );
sParticle->m_flRollDelta = 0.0f;
float alpha = 255 * percentage;
sParticle->m_uchColor[0] = alpha;
sParticle->m_uchColor[1] = alpha;
sParticle->m_uchColor[2] = alpha;
sParticle->m_uchStartAlpha = alpha;
sParticle->m_uchEndAlpha = 0;
sParticle->m_uchStartSize = random->RandomFloat( 1, 2 );
sParticle->m_uchEndSize = 0;
}
#endif
//.........这里部分代码省略.........
示例12: Update
void C_ParticleFire::Update(float fTimeDelta)
{
if(!m_pParticleMgr)
{
assert(false);
return;
}
// Add new emitters.
if(m_nEmitters < MAX_FIRE_EMITTERS)
{
float tempDelta = fTimeDelta;
while(m_EmitterSpawn.NextEvent(tempDelta))
{
FireEmitter *pEmitter = NULL;
if(m_nEmitters == 0)
{
// Make the first emitter.
trace_t trace;
UTIL_TraceLine(m_vOrigin, m_vOrigin+m_vDirection*1000, MASK_SOLID_BRUSHONLY, NULL, COLLISION_GROUP_NONE, &trace);
if(trace.fraction < 1)
{
pEmitter = &m_Emitters[m_nEmitters];
pEmitter->m_Pos = trace.endpos + trace.plane.normal * (size - 1);
pEmitter->m_DirectionsTested = 0;
}
}
else
{
static int nTries = 50;
for(int iTry=0; iTry < nTries; iTry++)
{
FireEmitter *pSourceEmitter = &m_Emitters[rand() % m_nEmitters];
int iOffset = rand() % NUM_FIREGRID_OFFSETS;
if(pSourceEmitter->m_DirectionsTested & (1 << iOffset))
continue;
// Test the corners of the new cube. If some points are solid and some are not, then
// we can put fire here.
Vector basePos = pSourceEmitter->m_Pos + g_Offsets[iOffset] * fireSpreadDist;
int nSolidCorners = 0;
for(int iCorner=0; iCorner < NUM_FIREGRID_OFFSETS; iCorner++)
{
Vector vCorner = basePos + g_Offsets[iCorner]*fireSpreadDist;
if ( enginetrace->GetPointContents(vCorner) & CONTENTS_SOLID )
++nSolidCorners;
}
// Don't test this square again.
pSourceEmitter->m_DirectionsTested |= 1 << iOffset;
if(nSolidCorners != 0 && nSolidCorners != NUM_FIREGRID_OFFSETS)
{
pEmitter = &m_Emitters[m_nEmitters];
pEmitter->m_Pos = basePos;
pEmitter->m_DirectionsTested = 1 << GetOppositeOffset(iOffset);
}
}
}
if(pEmitter)
{
pEmitter->m_Lifetime = 0;
pEmitter->m_SpawnEvent.Init(1);
++m_nEmitters;
}
}
}
// Spawn particles out of the emitters.
for(int i=0; i < m_nEmitters; i++)
{
FireEmitter *pEmitter = &m_Emitters[i];
float tempDelta = fTimeDelta;
while(pEmitter->m_SpawnEvent.NextEvent(tempDelta))
{
FireParticle *pParticle = (FireParticle*)m_ParticleEffect.AddParticle(sizeof(FireParticle), m_MaterialHandle);
if(pParticle)
{
static float particleSpeed = 15;
pParticle->m_StartPos = pEmitter->m_Pos;
pParticle->m_Direction = g_FireSpreadDirection * particleSpeed + RandomVector(0, particleSpeed*0.5);
pParticle->m_iRamp = rand() % NUM_FIRE_RAMPS;
pParticle->m_Lifetime = 0;
}
}
}
}
示例13: Update
void C_SteamJet::Update(float fTimeDelta)
{
if(!m_pParticleMgr)
{
assert(false);
return;
}
if( m_bEmit )
{
// Add new particles.
int nToEmit = 0;
float tempDelta = fTimeDelta;
while( m_ParticleSpawn.NextEvent(tempDelta) )
++nToEmit;
if ( nToEmit > 0 )
{
Vector forward, right, up;
AngleVectors(GetAbsAngles(), &forward, &right, &up);
// Legacy env_steamjet entities faced left instead of forward.
if (m_bFaceLeft)
{
Vector temp = forward;
forward = -right;
right = temp;
}
// EVIL: Ideally, we could tell the renderer our OBB, and let it build a big box that encloses
// the entity with its parent so it doesn't have to setup its parent's bones here.
Vector vEndPoint = GetAbsOrigin() + forward * m_Speed;
Vector vMin, vMax;
VectorMin( GetAbsOrigin(), vEndPoint, vMin );
VectorMax( GetAbsOrigin(), vEndPoint, vMax );
m_ParticleEffect.SetBBox( vMin, vMax );
if ( m_ParticleEffect.WasDrawnPrevFrame() )
{
while ( nToEmit-- )
{
// Make a new particle.
if( SteamJetParticle *pParticle = (SteamJetParticle*) m_ParticleEffect.AddParticle( sizeof(SteamJetParticle), m_MaterialHandle ) )
{
pParticle->m_Pos = GetAbsOrigin();
pParticle->m_Velocity =
FRand(-m_SpreadSpeed,m_SpreadSpeed) * right +
FRand(-m_SpreadSpeed,m_SpreadSpeed) * up +
m_Speed * forward;
pParticle->m_Lifetime = 0;
pParticle->m_DieTime = m_Lifetime;
pParticle->m_uchStartSize = m_StartSize;
pParticle->m_uchEndSize = m_EndSize;
pParticle->m_flRoll = random->RandomFloat( 0, 360 );
pParticle->m_flRollDelta = random->RandomFloat( -m_flRollSpeed, m_flRollSpeed );
}
}
}
UpdateLightingRamp();
}
}
}
示例14: Update
//.........这里部分代码省略.........
{
Vector effect_origin;
QAngle effect_angles;
GetAttachment( m_iAttachment, effect_origin, effect_angles );
//Raise the light a little bit away from the flare so it lights it up better.
dl->origin = effect_origin + Vector( 0, 0, 4 );
dl->color.r = 255;
dl->die = gpGlobals->curtime + 0.1f;
dl->radius = baseScale * random->RandomFloat( 245.0f, 256.0f );
dl->color.g = dl->color.b = random->RandomInt( 95, 128 );
dlight_t *el= effects->CL_AllocElight( index );
el->origin = effect_origin;
el->color.r = 255;
el->color.g = dl->color.b = random->RandomInt( 95, 128 );
el->radius = baseScale * random->RandomFloat( 260.0f, 290.0f );
el->die = gpGlobals->curtime + 0.1f;
}
}
}
//
// Smoke
//
float dt = timeDelta;
if ( m_bSmoke )
{
while ( m_teSmokeSpawn.NextEvent( dt ) )
{
Vector smokeOrg = GetAbsOrigin();
Vector flareScreenDir = ( smokeOrg - MainViewOrigin() );
VectorNormalize( flareScreenDir );
smokeOrg = smokeOrg + ( flareScreenDir * 2.0f );
smokeOrg[2] += baseScale * 4.0f;
SimpleParticle *sParticle = (SimpleParticle *) AddParticle( sizeof( SimpleParticle ), g_Mat_DustPuff[1], smokeOrg );
if ( sParticle == NULL )
return;
sParticle->m_flLifetime = 0.0f;
sParticle->m_flDieTime = 1.0f;
sParticle->m_vecVelocity = Vector( random->RandomFloat( -16.0f, 16.0f ), random->RandomFloat( -16.0f, 16.0f ), random->RandomFloat( 8.0f, 16.0f ) + 32.0f );
if ( m_bPropFlare )
{
sParticle->m_uchColor[0] = 255;
sParticle->m_uchColor[1] = 100;
sParticle->m_uchColor[2] = 100;
}
else
{
sParticle->m_uchColor[0] = 255;
sParticle->m_uchColor[1] = 48;
sParticle->m_uchColor[2] = 48;
}