protected virtual void FindLightsAffectingFrustum( Camera camera )
{
// Basic iteration for this scene manager
this.lightsAffectingFrustum.Clear();
MovableObjectCollection lightList = this.GetMovableObjectCollection( LightFactory.TypeName );
// sphere to use for testing
Sphere sphere = new Sphere();
foreach ( Light light in lightList.Values )
{
if ( light.IsVisible )
{
if ( light.Type == LightType.Directional )
{
// Always visible
this.lightsAffectingFrustum.Add( light );
}
else
{
// treating spotlight as point for simplicity
// Just see if the lights attenuation range is within the frustum
sphere.Center = light.DerivedPosition;
sphere.Radius = light.AttenuationRange;
if ( camera.IsObjectVisible( sphere ) )
{
this.lightsAffectingFrustum.Add( light );
}
}
}
}
// notify light dirty, so all movable objects will re-populate
// their light list next time
NotifyLightsDirty();
}