Game Development Reference
In-Depth Information
The SphericalPolygonExplosion constructor creates and initializes a new explosion. It creates and
initializes m_NumberParticles new particles that will have random directions when the explosion is
started. (See Listing 7-45.)
Listing 7-45. SphericalPolygonExplosion() Constructor
SphericalPolygonExplosion(int NumberParticles, Vector3 Color,long ParticleLifeSpan,boolean
RandomColors, boolean ColorAnimation,float FadeDelta,Vector3 ParticleSize,Context iContext, Mesh
iMesh, MeshEx iMeshEx, Texture[] iTextures, Material iMaterial, Shader iShader )
{
m_NumberParticles = NumberParticles;
m_ParticleColor = new Vector3(Color.x, Color.y, Color.z);
m_ParticleLifeSpan = ParticleLifeSpan;
m_RandomColors = RandomColors; // true if Particles set to have Random colors
m_ParticleColorAnimation = ColorAnimation;
m_ExplosionActive = false;
m_ParticleSize = new Vector3(ParticleSize.x, ParticleSize.y, ParticleSize.z);
if (NumberParticles > MAX_POLYGONS)
{
m_NumberParticles = MAX_POLYGONS;
}
// For each new Particle
for (int i = 0; i < m_NumberParticles; i++)
{
int signx = 1;
int signy = 1;
int signz = 1;
if (m_RandNumber.nextFloat() > 0.5f)
{
signx = -1;
}
if (m_RandNumber.nextFloat() > 0.5f)
{
signy = -1;
}
if (m_RandNumber.nextFloat() > 0.5f)
{
signz = -1;
}
// Find random direction for particle
float randomx = (float)signx * m_RandNumber.nextFloat();
float randomy = (float)signy * m_RandNumber.nextFloat();
float randomz = (float)signz * m_RandNumber.nextFloat();
 
Search WWH ::




Custom Search