Example #1
0
        private static void ConstantAttenuationPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            PointLightBase target = ((PointLightBase)d);


            target.PropertyChanged(ConstantAttenuationProperty);
        }
Example #2
0
        private static void RangePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            PointLightBase target = ((PointLightBase)d);


            target.PropertyChanged(RangeProperty);
        }
Example #3
0
        /// <summary>
        /// This sets the attenuation and range of a light so that it's a percent of its intensity at some distance
        /// </summary>
        public static void SetAttenuation(PointLightBase light, double distance, double percentAtDistance)
        {
            // % = 1/max(1, q*d^2)
            // % = 1/(q*d^2)
            // q=1(d^2 * %)
            light.ConstantAttenuation = 0d;
            light.LinearAttenuation = 0d;
            light.QuadraticAttenuation = 1 / (distance * percentAtDistance);

            // Now limit the range
            light.Range = 1 / Math.Sqrt(.01 * light.QuadraticAttenuation);		// stop it at 1% intensity
        }