Ejemplo n.º 1
0
        public PointLightEquation(PointLightBase light, Matrix3D viewMatrix)
            : base(light.Color, viewMatrix)
        {
            // Account for model hierarchy transform
            position = MatrixUtils.Transform(light.Position, light.Transform);
            // Account for view dependent transform
            position = MatrixUtils.Transform(position, viewMatrix);

            // We want lights to scale with the transform, but don't want to do all lighting in
            // light space. Our compromise is to use the average scale factor of the matrix to
            // scale our lights. This means we're exactly right for uniform scales and arbitrarily
            // wrong for non-uniform scales. This was an Avalon design decision.

            double averageScaleFactor = 1.0;

            if (light.Transform != null)
            {
                averageScaleFactor = MatrixUtils.GetAverageScaleFactor(light.Transform.Value);
            }

            // Now we need to account for scaled attenuation and range
            constantAttenuation  = light.ConstantAttenuation;
            linearAttenuation    = light.LinearAttenuation / averageScaleFactor;
            quadraticAttenuation = light.QuadraticAttenuation / (averageScaleFactor * averageScaleFactor);
            range = light.Range * averageScaleFactor;
        }
Ejemplo n.º 2
0
 private static void SetLocalLightParameters(PointLightBase light, Variation v)
 {
     light.Position             = StringConverter.ToPoint3D(v["LightPosition"]);
     light.Range                = StringConverter.ToDouble(v["LightRange"]);
     light.ConstantAttenuation  = StringConverter.ToDouble(v["LightConstantAttenuation"]);
     light.LinearAttenuation    = StringConverter.ToDouble(v["LightLinearAttenuation"]);
     light.QuadraticAttenuation = StringConverter.ToDouble(v["LightQuadraticAttenuation"]);
 }
Ejemplo n.º 3
0
        public override void Perform()
        {
            PointLightBase PointLightBase = GetPointLightBaseFromViewport3D(Viewport3D);

            switch (PropertyToAnimate)
            {
            case Properties.RangeProperty:
                PointLightBase.BeginAnimation(PointLightBase.RangeProperty, DoubleAnimation, HandoffBehavior);
                break;

            case Properties.ConstantAttenuationProperty:
                PointLightBase.BeginAnimation(PointLightBase.ConstantAttenuationProperty, DoubleAnimation, HandoffBehavior);
                break;

            case Properties.LinearAttenuationProperty:
                PointLightBase.BeginAnimation(PointLightBase.LinearAttenuationProperty, DoubleAnimation, HandoffBehavior);
                break;

            case Properties.QuadraticAttenuationProperty:
                PointLightBase.BeginAnimation(PointLightBase.QuadraticAttenuationProperty, DoubleAnimation, HandoffBehavior);
                break;
            }
        }
Ejemplo n.º 4
0
 public WpfLight(PointLightBase light)
 {
     _light = light;
 }