Exemplo n.º 1
0
void LightingDemo::SetHSSpotights( ShaderLightManager& shader_light_mgr, bool random_color )
{
	int x = m_NumLightsX;
	int z = m_NumLightsZ;
	float span_x = 32.0f;
	float span_z = 32.0f;
//	int num_point_lights = 4;
//	for( int i=0; i<num_point_lights; i++ )
	float interval_x = (2 <= x) ? span_x / (float)(x-1) : 0.0f;
	float interval_z = (2 <= z) ? span_z / (float)(z-1) : 0.0f;
	int num_point_lights = z * x;
	int light_index = 0;
	for( int i=0; i<z; i++ )
	{
		for( int j=0; j<x; j++ )
		{
			HemisphericSpotlight light;
//			light.Attribute.UpperDiffuseColor.SetRGBA( 1.0f, 1.0f, 1.0f, 1.0f );
			int color_index = light_index % numof(s_rand_colors);
			light_index++;
			light.Attribute.UpperDiffuseColor = s_rand_colors[color_index];
			light.Attribute.LowerDiffuseColor.SetRGBA( 0.0f, 0.0f, 0.0f, 1.0f );
			light.vPosition = Vector3(
				(float)j * interval_x - span_x * 0.5f,
				1.0f,
				(float)i * interval_z - span_z * 0.5f );
//			light.fAttenuation[0] = 0.1f;
//			light.fAttenuation[1] = 0.1f;
//			light.fAttenuation[2] = 0.1f;
			shader_light_mgr.SetHemisphericSpotlight( light );
		}
	}
}