Game Development Reference
In-Depth Information
// 2. Apply Initial Force
Vector3 FVector = new Vector3(DirectionNormalized.x, DirectionNormalized.y,
DirectionNormalized.z);
FVector.Multiply(Force);
GetObjectPhysics().ApplyTranslationalForce(FVector);
// 3. Apply Time
m_TimeStamp = CurrentTime;
// 4. Calculate Color for Fade
m_Color.x = m_OriginalColor.x;
m_Color.y = m_OriginalColor.y;
m_Color.z = m_OriginalColor.z;
}
The FadeColor() function takes as input a reference to a color, ColorIn , and reduces the brightness
( m_ColorBrightness ) by m_FadeDelta , with a minimum value of 0 for m_ColorBrightness . The color is
then scaled by m_ColorBrightness . (See Listing 7-38.)
Listing 7-38. Fading the Color of the Particle
void FadeColor(Vector3 ColorIn)
{
// Fade Color to Black.
// Adjust Brightness Level Down from full brightness = 1 to no brightness = 0;
m_ColorBrightness -= m_FadeDelta;
if (m_ColorBrightness < 0)
{
m_ColorBrightness = 0;
}
// 1. Adjust Color so that everything is at the same Brightness Level
ColorIn.x *= m_ColorBrightness;
ColorIn.y *= m_ColorBrightness;
ColorIn.z *= m_ColorBrightness;
}
The FadeColor() function fades the particle's color by calling FadeColor() and then calls SetColor()
to set the color of the particle. (See Listing 7-39.)
Listing 7-39. Fading the Particle's Color
void FadeColor(long ElapsedTime)
{
FadeColor(m_Color);
SetColor(m_Color);
}
 
Search WWH ::




Custom Search