Example #1
0
        /// <summary>
        /// Construct new light info instance
        /// </summary>
        /// <param name="intensity">Base intensity</param>
        /// <param name="color">Base color</param>
        /// <param name="attenuation">Attenuation information</param>
        public Light(float intensity, Color color, LightAttenuation attenuation) : this()
        {
            this.intensity   = intensity;
            this.attenuation = attenuation;

            SetColor(color);
        }
Example #2
0
        /// <summary>
        /// Clone this instance
        /// </summary>
        /// <returns>Deep copy of this instance</returns>
        public object Clone()
        {
            var other = new LightAttenuation()
            {
                radius       = this.radius,
                useRadius    = this.useRadius,
                attenFactors = new float[3]
            };

            attenFactors.CopyTo(other.attenFactors, 0);

            return(other);
        }
Example #3
0
        /// <summary>
        /// Create new light attenuation instance from given explicit factors.
        /// </summary>
        /// <param name="factors">An array of exactly 3 float values, describing the three factors a, b and c of the
        /// attenuation polynomial</param>
        /// <returns>Light attenuation instance based on given factors</returns>
        /// <exception cref="ArgumentException">If the length of given factor array is not exactly 3</exception>
        public static LightAttenuation FromFactors(params float[] factors)
        {
            if (factors.Length != 3)
            {
                throw new ArgumentException(String.Format("Expected 3 factors, got {0}", factors.Length));
            }

            var att = new LightAttenuation()
            {
                useRadius    = 0,
                attenFactors = new float[3]
            };

            factors.CopyTo(att.attenFactors, 0);

            return(att);
        }