Game Development Reference
In-Depth Information
Listing 4-37. PointLight Constructor
public PointLight(Context context)
{
m_light_ambient[0] = 1.0f;
m_light_ambient[1] = 1.0f;
m_light_ambient[2] = 1.0f;
m_light_diffuse[0] = 1.0f;
m_light_diffuse[1] = 1.0f;
m_light_diffuse[2] = 1.0f;
m_light_specular[0] = 1.0f;
m_light_specular[1] = 1.0f;
m_light_specular[2] = 1.0f;
m_Position = new Vector3(0,0,0);
}
The SetAmbientColor() function sets the ambient color of the light taking a float array as input.
The SetDiffuseColor() function sets the diffuse color of the light taking a float array as input.
The SetSpecularColor() function sets the specular color of the light taking a float array as input
(see Listing 4-38).
Listing 4-38. Set Light Functions
void SetAmbientColor(float[] ambient)
{
m_light_ambient[0] = ambient[0];
m_light_ambient[1] = ambient[1];
m_light_ambient[2] = ambient[2];
}
void SetDiffuseColor(float[] diffuse)
{
m_light_diffuse[0] = diffuse[0];
m_light_diffuse[1] = diffuse[1];
m_light_diffuse[2] = diffuse[2];
}
void SetSpecularColor(float[] spec)
{
m_light_specular[0] = spec[0];
m_light_specular[1] = spec[1];
m_light_specular[2] = spec[2];
}
The input float array holds the red, green, and blue values in the array position 0, 1, and 2, respectively.
Search WWH ::




Custom Search