1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#include "cbase.h"
#include "particles_simple.h"
#include "particlemgr.h"
#include "particle_collision.h"
#include "env_objecteffects.h"
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CObjectSmokeParticles::Setup( const Vector &origin, const Vector *direction, float angularSpread, float minSpeed, float maxSpeed, float gravity, float dampen, int flags )
{
// See if we've specified a direction
m_ParticleCollision.Setup( origin, direction, angularSpread, minSpeed, maxSpeed, gravity, dampen );
}
void CObjectSmokeParticles::SimulateParticles( CParticleSimulateIterator *pIterator )
{
float timeDelta = pIterator->GetTimeDelta();
ObjectSmokeParticle *pParticle = (ObjectSmokeParticle*)pIterator->GetFirst();
while ( pParticle )
{
//Update velocity
UpdateVelocity( pParticle, timeDelta );
pParticle->m_Pos += (pParticle->m_vecVelocity * timeDelta);
pParticle->m_vecVelocity += pParticle->m_vecAcceleration * 2 * timeDelta;
//Should this particle die?
pParticle->m_flLifetime += timeDelta;
UpdateRoll( pParticle, timeDelta );
if ( pParticle->m_flLifetime >= pParticle->m_flDieTime )
pIterator->RemoveParticle( pParticle );
pParticle = (ObjectSmokeParticle*)pIterator->GetNext();
}
}
void CObjectSmokeParticles::RenderParticles( CParticleRenderIterator *pIterator )
{
const ObjectSmokeParticle *pParticle = (const ObjectSmokeParticle *)pIterator->GetFirst();
while ( pParticle )
{
//Render
Vector tPos;
TransformParticle( ParticleMgr()->GetModelView(), pParticle->m_Pos, tPos );
float sortKey = (int) tPos.z;
//Render it
RenderParticle_ColorSizeAngle(
pIterator->GetParticleDraw(),
tPos,
UpdateColor( pParticle ),
UpdateAlpha( pParticle ) * GetAlphaDistanceFade( tPos, m_flNearClipMin, m_flNearClipMax ),
UpdateScale( pParticle ),
pParticle->m_flRoll );
pParticle = (const ObjectSmokeParticle *)pIterator->GetNext( sortKey );
}
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CObjectFireParticles::Setup( const Vector &origin, const Vector *direction, float angularSpread, float minSpeed, float maxSpeed, float gravity, float dampen, int flags )
{
}
void CObjectFireParticles::SimulateParticles( CParticleSimulateIterator *pIterator )
{
float timeDelta = pIterator->GetTimeDelta();
ObjectFireParticle *pParticle = (ObjectFireParticle*)pIterator->GetFirst();
while ( pParticle )
{
// Lost our parent?
if ( !pParticle->m_hParent )
{
pIterator->RemoveParticle( pParticle );
}
else
{
// Update position to match our parent
Vector vecFire;
QAngle angFire;
if ( pParticle->m_hParent->GetAttachment( pParticle->m_iAttachmentPoint, vecFire, angFire ) )
{
pParticle->m_Pos = vecFire;
}
// Should this particle die?
pParticle->m_flLifetime += timeDelta;
UpdateRoll( pParticle, timeDelta );
if ( pParticle->m_flLifetime >= pParticle->m_flDieTime )
pIterator->RemoveParticle( pParticle );
}
pParticle = (ObjectFireParticle*)pIterator->GetNext();
}
}
void CObjectFireParticles::RenderParticles( CParticleRenderIterator *pIterator )
{
const ObjectFireParticle *pParticle = (const ObjectFireParticle *)pIterator->GetFirst();
while ( pParticle )
{
// Render
Vector tPos;
TransformParticle( ParticleMgr()->GetModelView(), pParticle->m_Pos, tPos );
float sortKey = (int) tPos.z;
// Render it
RenderParticle_ColorSizeAngle(
pIterator->GetParticleDraw(),
tPos,
UpdateColor( pParticle ),
UpdateAlpha( pParticle ) * GetAlphaDistanceFade( tPos, m_flNearClipMin, m_flNearClipMax ),
UpdateScale( pParticle ),
pParticle->m_flRoll
);
pParticle = (const ObjectFireParticle *)pIterator->GetNext( sortKey );
}
}
|