Kav/Effects/PointLightCollection.cs

34 lines
1011 B
C#
Raw Permalink Normal View History

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace Kav
{
public class PointLightCollection
{
private readonly Vector3[] positions;
private readonly Vector3[] colors;
readonly EffectParameter lightPositionsParam;
readonly EffectParameter lightColorsParam;
public PointLightCollection(EffectParameter lightPositionsParam, EffectParameter lightColorsParam, int maxLights)
{
2020-12-10 06:28:51 +00:00
positions = new Vector3[maxLights];
colors = new Vector3[maxLights];
this.lightPositionsParam = lightPositionsParam;
this.lightColorsParam = lightColorsParam;
}
public PointLight this[int i]
{
set
{
positions[i] = value.Position;
2020-12-10 00:28:40 +00:00
colors[i] = value.Color.ToVector3() * value.Radius;
lightPositionsParam.SetValue(positions);
lightColorsParam.SetValue(colors);
}
}
}
}