Kav/Effects/PointLightCollection.cs

36 lines
1.1 KiB
C#

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace Kav
{
public class PointLightCollection
{
private readonly Vector3[] positions;
private readonly Vector3[] colors;
private readonly float[] intensities;
readonly EffectParameter lightPositionsParam;
readonly EffectParameter lightColorsParam;
public PointLightCollection(EffectParameter lightPositionsParam, EffectParameter lightColorsParam, int maxLights)
{
this.positions = new Vector3[maxLights];
this.colors = new Vector3[maxLights];
this.intensities = new float[maxLights];
this.lightPositionsParam = lightPositionsParam;
this.lightColorsParam = lightColorsParam;
}
public PointLight this[int i]
{
set
{
positions[i] = value.Position;
colors[i] = value.Color.ToVector3() * value.Radius;
lightPositionsParam.SetValue(positions);
lightColorsParam.SetValue(colors);
}
}
}
}