コード例 #1
0
ファイル: CascadedShadow.cs プロジェクト: Zolniu/DigitalRune
 //--------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="CascadedShadow"/> class.
 /// </summary>
 public CascadedShadow()
 {
     NumberOfCascades = 4;
       Distances = new Vector4F(4, 12, 20, 80);
       MinLightDistance = 100;
       DepthBias = new Vector4F(5);
       NormalOffset = new Vector4F(2);
       NumberOfSamples = -1;
       FilterRadius = 1;
       JitterResolution = 2048;
       FadeOutRange = 0.1f;
       ShadowFog = 0;
     #if XBOX
       CascadeSelection = ShadowCascadeSelection.Fast;
     #else
       CascadeSelection = ShadowCascadeSelection.Best;
     #endif
       IsCascadeLocked = new[] { false, false, false, false };
     #pragma warning disable 618
       SplitDistribution = 0.9f;
       FadeOutDistance = 50;
       MaxDistance = 70;
       DepthBiasScale = new Vector4F(0.99f);
       DepthBiasOffset = new Vector4F(-0.001f);
     #pragma warning restore 618
 }
コード例 #2
0
ファイル: Vector4FTest.cs プロジェクト: Zolniu/DigitalRune
 public void Addition()
 {
     Vector4F a = new Vector4F(1.0f, 2.0f, 3.0f, 4.0f);
       Vector4F b = new Vector4F(2.0f, 3.0f, 4.0f, 5.0f);
       Vector4F c = Vector4F.Add(a, b);
       Assert.AreEqual(new Vector4F(3.0f, 5.0f, 7.0f, 9.0f), c);
 }
コード例 #3
0
 //--------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="GradientTextureSkyNode" /> class.
 /// </summary>
 public GradientTextureSkyNode()
 {
     SunDirection = new Vector3F(1, 1, 1);
       TimeOfDay = new TimeSpan(12, 0, 0);
       Color = new Vector4F(1, 1, 1, 1);
       CieSkyParameters = CieSkyParameters.Type12;
 }
コード例 #4
0
ファイル: Vector4FTest.cs プロジェクト: Zolniu/DigitalRune
 public void AdditionOperator()
 {
     Vector4F a = new Vector4F(1.0f, 2.0f, 3.0f, 4.0f);
       Vector4F b = new Vector4F(2.0f, 3.0f, 4.0f, 5.0f);
       Vector4F c = a + b;
       Assert.AreEqual(new Vector4F(3.0f, 5.0f, 7.0f, 9.0f), c);
 }
コード例 #5
0
 public void IdentityTest()
 {
     var traits = Vector4FTraits.Instance;
       var value = new Vector4F(-1, -2, 3, 1);
       Assert.AreEqual(value, traits.Add(value, traits.Identity()));
       Assert.AreEqual(value, traits.Add(traits.Identity(), value));
 }
コード例 #6
0
        public void Normalize()
        {
            Vector4F v, n1, n2;
            float magnitude;

            v = new Vector4F(3.0f, 4.0f, 0.0f, 0.0f);
            n1 = v.Normalize();
            n2 = v.Normalize(out magnitude);
            Assert.AreEqual(1.0f, n1.Magnitude, 1e-14);
            Assert.AreEqual(1.0f, n2.Magnitude, 1e-14);
            Assert.AreEqual(5.0f, magnitude, 1e-14);

            v = new Vector4F(3.0f, 0.0f, 4.0f, 0.0f);
            n1 = v.Normalize();
            n2 = v.Normalize(out magnitude);
            Assert.AreEqual(1.0f, n1.Magnitude, 1e-14);
            Assert.AreEqual(1.0f, n2.Magnitude, 1e-14);
            Assert.AreEqual(5.0f, magnitude, 1e-14);

            v = new Vector4F(0.0f, 3.0f, 4.0f, 0.0f);
            n1 = v.Normalize();
            n2 = v.Normalize(out magnitude);
            Assert.AreEqual(1.0f, n1.Magnitude, 1e-14);
            Assert.AreEqual(1.0f, n2.Magnitude, 1e-14);
            Assert.AreEqual(5.0f, magnitude, 1e-14);

            v = new Vector4F(0.0f, 0.0f, 3.0f, 4.0f);
            n1 = v.Normalize();
            n2 = v.Normalize(out magnitude);
            Assert.AreEqual(1.0f, n1.Magnitude, 1e-14);
            Assert.AreEqual(1.0f, n2.Magnitude, 1e-14);
            Assert.AreEqual(5.0f, magnitude, 1e-14);
        }
コード例 #7
0
 public void Construct2()
 {
     Vector4F v = new Vector4F(new Vector2F(1.0f, 2.0f), 3.0f, 4.0f);
     Assert.AreEqual(1.0f, v.X);
     Assert.AreEqual(2.0f, v.Y);
     Assert.AreEqual(3.0f, v.Z);
     Assert.AreEqual(4.0f, v.W);
 }
コード例 #8
0
 public void InterpolationTest()
 {
     var traits = Vector4FTraits.Instance;
       var value0 = new Vector4F(1, 2, 3, 1);
       var value1 = new Vector4F(-4, 5, -6, 5);
       Assert.IsTrue(Vector4F.AreNumericallyEqual(value0, traits.Interpolate(value0, value1, 0.0f)));
       Assert.IsTrue(Vector4F.AreNumericallyEqual(value1, traits.Interpolate(value0, value1, 1.0f)));
       Assert.IsTrue(Vector4F.AreNumericallyEqual(0.25f * value0 + 0.75f * value1, traits.Interpolate(value0, value1, 0.75f)));
 }
コード例 #9
0
 public static Vector4F VectorMultiply(Matrix4x4F a, Vector4F b)
 {
     return new Vector4F(
         a.M11 * b.X + a.M21 * b.Y + a.M31 * b.Z + a.M41 * b.W,
         a.M12 * b.X + a.M22 * b.Y + a.M32 * b.Z + a.M42 * b.W,
         a.M13 * b.X + a.M23 * b.Y + a.M33 * b.Z + a.M43 * b.W,
         a.M14 * b.X + a.M24 * b.Y + a.M34 * b.Z + a.M44 * b.W
         );
 }
コード例 #10
0
    public static UnityEngine.Vector3 ToUnityVector(Vector4F vector4F)
    {
        if (!vector4F.W.NearlyEquals(1))
        {
            Debug.Log("Losing accuracy on " + vector4F + " conversion, as w is not one!");
        }

        return(new UnityEngine.Vector3(vector4F.X, vector4F.Y, vector4F.Z));
    }
コード例 #11
0
        public static Vector4F CrossProduct3D(Vector4FParam1_3 left, Vector4FParam1_3 right)
        {
            if (Sse.IsSupported)
            {
                #region Comments

                /* Cross product of A(x, y, z, _) and B(x, y, z, _) is
                 *                    0  1  2  3        0  1  2  3
                 *
                 * '(X = (Ay * Bz) - (Az * By), Y = (Az * Bx) - (Ax * Bz), Z = (Ax * By) - (Ay * Bx)'
                 *           1           2              1           2              1            2
                 * So we can do (Ay, Az, Ax, _) * (Bz, Bx, By, _) (last elem is irrelevant, as this is for Vector3)
                 * which leaves us with a of the first subtraction element for each (marked 1 above)
                 * Then we repeat with the right hand of subtractions (Az, Ax, Ay, _) * (By, Bz, Bx, _)
                 * which leaves us with the right hand sides (marked 2 above)
                 * Then we subtract them to get the correct vector
                 * We then mask out W to zero, because that is required for the Vector3 representation
                 *
                 * We perform the first 2 multiplications by shuffling the vectors and then multiplying them
                 * Helpers.Shuffle is the same as the C++ macro _MM_SHUFFLE, and you provide the order you wish the elements
                 * to be in *reversed* (no clue why), so here (3, 0, 2, 1) means you have the 2nd elem (1, 0 indexed) in the first slot,
                 * the 3rd elem (2) in the next one, the 1st elem (0) in the next one, and the 4th (3, W/_, unused here) in the last reg
                 */

                #endregion

                /*
                 * lhs1 goes from x, y, z, _ to y, z, x, _
                 * rhs1 goes from x, y, z, _ to z, x, y, _
                 */

                Vector4F leftHandSide1  = Sse.Shuffle(left, left, Helpers.Shuffle(3, 0, 2, 1));
                Vector4F rightHandSide1 = Sse.Shuffle(right, right, Helpers.Shuffle(3, 1, 0, 2));

                /*
                 * lhs2 goes from x, y, z, _ to z, x, y, _
                 * rhs2 goes from x, y, z, _ to y, z, x, _
                 */


                Vector4F leftHandSide2  = Sse.Shuffle(left, left, Helpers.Shuffle(3, 1, 0, 2));
                Vector4F rightHandSide2 = Sse.Shuffle(right, right, Helpers.Shuffle(3, 0, 2, 1));

                Vector4F mul1 = Sse.Multiply(leftHandSide1, rightHandSide1);

                Vector4F mul2 = Sse.Multiply(leftHandSide2, rightHandSide2);

                Vector4F resultNonMaskedW = Sse.Subtract(mul1, mul2);

                return(Sse.And(resultNonMaskedW, MaskW));

                // TODO reuse vectors (minimal register usage) - potentially prevent any stack spilling
            }

            return(CrossProduct3D_Software(left, right));
        }
コード例 #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RenderState"/> class.
        /// </summary>
        public RenderState()
        {
            FlagsMode      = RenderStateFlagsMode.Opaque;
            FlagsBlendMode = RenderStateFlagsBlendMode.None;

            PolygonControl = new PolygonControl()
            {
                CullBack                  = false,
                CullFront                 = false,
                FrontFace                 = GX2FrontFaceMode.CounterClockwise,
                PolygonModeBack           = GX2PolygonMode.Triangle,
                PolygonModeFront          = GX2PolygonMode.Triangle,
                PolygonOffsetBackEnabled  = false,
                PolygonOffsetFrontEnabled = false,
                PolygonLineOffsetEnabled  = false,
                PolygonModeEnabled        = true,
            };

            AlphaControl = new AlphaControl()
            {
                AlphaFunc = GX2CompareFunction.GreaterOrEqual,
            };

            DepthControl = new DepthControl()
            {
                BackStencilEnabled = false,
                BackStencilFail    = GX2StencilFunction.Replace,
                BackStencilFunc    = GX2CompareFunction.Always,
                BackStencilZFail   = GX2StencilFunction.Replace,
                BackStencilZPass   = GX2StencilFunction.Replace,
                DepthFunc          = GX2CompareFunction.LessOrEqual,
                DepthTestEnabled   = true,
                DepthWriteEnabled  = true,
                FrontStencilFail   = GX2StencilFunction.Replace,
                FrontStencilFunc   = GX2CompareFunction.Always,
                FrontStencilZFail  = GX2StencilFunction.Replace,
                FrontStencilZPass  = GX2StencilFunction.Replace,
                StencilTestEnabled = false,
            };

            AlphaRefValue = 0.5F;


            BlendControl = new BlendControl()
            {
                AlphaCombine          = GX2BlendCombine.Add,
                AlphaDestinationBlend = GX2BlendFunction.Zero,
                AlphaSourceBlend      = GX2BlendFunction.Zero,
                ColorCombine          = GX2BlendCombine.Add,
                ColorDestinationBlend = GX2BlendFunction.OneMinusSourceAlpha,
                ColorSourceBlend      = GX2BlendFunction.SourceAlpha,
                SeparateAlphaBlend    = true,
            };

            BlendColor = new Vector4F(0, 0, 0, 0);
        }
コード例 #13
0
            public void example_2()
            {
                var left     = new Vector4F(1.0f, 3.0f, 4.0f, 9.0f);
                var right    = new Vector4F(-2.0f, 5.6f, -9.0f, 0.1f);
                var expected = 1.7537363654297111f;

                var actual = left.GetAngleBetween(right);

                Assert.Equal(expected, actual, 10);
            }
コード例 #14
0
            public void opposite_vector_angle_is_pi()
            {
                var left     = new Vector4F(14.0f, 98, -19, 88);
                var right    = left.GetNegative();
                var expected = (float)Math.PI;

                var actual = left.GetAngleBetween(right);

                Assert.Equal(expected, actual, 10);
            }
コード例 #15
0
        public static Vector4F Divide(Vector4FParam1_3 dividend, float scalarDivisor)
        {
            if (Sse.IsSupported)
            {
                Vector4F expand = Vector128.Create(scalarDivisor);
                return(Sse.Divide(dividend, expand));
            }

            return(SoftwareFallbacks.SoftwareFallbacksVector4F.Divide_Software(dividend, scalarDivisor));
        }
コード例 #16
0
            public void right_angle_is_half_pi()
            {
                var left     = new Vector4F(1.0f, 0, 1, 0);
                var right    = new Vector4F(0.0f, 1, 0, 1);
                var expected = (float)(Math.PI / 2.0);

                var actual = left.GetAngleBetween(right);

                Assert.Equal(expected, actual, 10);
            }
コード例 #17
0
            public void projecting_against_zero_results_in_same_vector()
            {
                var u        = new Vector4F();
                var v        = new Vector4F(-3.0f, 8, 5, -10);
                var expected = new Vector4F(v);

                var actual = u.GetProjected(v);

                Assert.Equal(expected, actual);
            }
コード例 #18
0
            public void projection_example_1()
            {
                var u        = new Vector4F(-1.0f, 2, 1, 3);
                var v        = new Vector4F(2.0f, -1, 3, 1);
                var expected = u.GetScaled(2.0f / 15.0f);

                var actual = u.GetProjected(v);

                Assert.Equal(expected, actual);
            }
コード例 #19
0
            public void can_find_distance()
            {
                var a        = new Vector4F(1.0f, -2, 3, 0);
                var b        = new Vector4F(4.0f, 0, -3, 5);
                var expected = (float)Math.Sqrt(74);

                var actual = a.GetDistance(b);

                Assert.Equal(expected, actual);
            }
コード例 #20
0
            public void can_find_distance()
            {
                var a        = new Vector4F(1.0f, -2, 3, 0);
                var b        = new Vector4F(4.0f, 0, -3, 5);
                var expected = 74.0f;

                var actual = a.GetDistanceSquared(b);

                Assert.Equal(expected, actual);
            }
コード例 #21
0
            public void adding_vector_produces_sum_vector()
            {
                var left     = new Vector4F(1.0f, 2, 10, -4);
                var right    = new Vector4F(3.0f, 4, 11, 1);
                var expected = new Vector4F(4.0f, 6, 21, -3);

                var actual = left.GetSum(right);

                Assert.Equal(expected, actual);
            }
コード例 #22
0
            public void adding_vector_adds_to_components()
            {
                var actual   = new Vector4F(1.0f, 2, 10, -4);
                var right    = new Vector4F(3.0f, 4, 11, 1);
                var expected = new Vector4F(4.0f, 6, 21, -3);

                actual.Add(right);

                Assert.Equal(expected, actual);
            }
コード例 #23
0
            public void op_multiply_scalar_mimics_scale_first()
            {
                var vector   = new Vector4F(1.0f, 2, 3, 4);
                var scalar   = 2.4f;
                var expected = vector.GetScaled(scalar);

                var actual = scalar * vector;

                Assert.Equal(expected, actual);
            }
コード例 #24
0
            public void op_multiply_scalar_mimics_divide()
            {
                var vector   = new Vector4F(1.0f, 2, 3, 4);
                var divisor  = 2.4f;
                var expected = vector.GetQuotient(divisor);

                var actual = vector / divisor;

                Assert.Equal(expected, actual);
            }
コード例 #25
0
            public void op_multiply_mimics_dot()
            {
                var left     = new Vector4F(1.0f, 2, 4, 5);
                var right    = new Vector4F(-3.0f, -100, 40, 52);
                var expected = left.GetDot(right);

                var actual = left * right;

                Assert.Equal(expected, actual);
            }
コード例 #26
0
            public void op_subtraction_mimics_subtract()
            {
                var left     = new Vector4F(1.0f, 2, 4, 5);
                var right    = new Vector4F(-3.0f, -100, 40, 52);
                var expected = left.GetDifference(right);

                var actual = left - right;

                Assert.Equal(expected, actual);
            }
コード例 #27
0
            public void op_addition_mimics_add()
            {
                var left     = new Vector4F(1.0f, 2, 4, 5);
                var right    = new Vector4F(-3.0f, -100, 40, 52);
                var expected = left.GetSum(right);

                var actual = left + right;

                Assert.Equal(expected, actual);
            }
コード例 #28
0
            public void example_1()
            {
                var left     = new Vector4F(1.0f, 0, 0, 0);
                var right    = new Vector4F(1.0f, 0, 1, 0);
                var expected = (float)Math.Acos(1.0 / Math.Sqrt(2.0));

                var actual = left.GetAngleBetween(right);

                Assert.Equal(expected, actual, 5);
            }
コード例 #29
0
            public void adding_vectors_leaves_right_unchanged()
            {
                var left          = new Vector4F(1.0f, 2, 10, -4);
                var right         = new Vector4F(3.0f, 4, 11, 1);
                var expectedRight = new Vector4F(right);

                left.Add(right);

                Assert.Equal(expectedRight, right);
            }
コード例 #30
0
        /// <inheritdoc/>
        public void Interpolate(ref Vector4F source, ref Vector4F target, float parameter, ref Vector4F result)
        {
            //result = source + (target - source) * parameter;

            // Optimized by inlining.
            result.X = source.X + (target.X - source.X) * parameter;
            result.Y = source.Y + (target.Y - source.Y) * parameter;
            result.Z = source.Z + (target.Z - source.Z) * parameter;
            result.W = source.W + (target.W - source.W) * parameter;
        }
コード例 #31
0
            public void subtracting_vector_produces_diff_vector()
            {
                var left     = new Vector4F(1.0f, 15, 5, 3);
                var right    = new Vector4F(3.0f, 2, 10, 1);
                var expected = new Vector4F(-2.0f, 13, -5, 2);

                var actual = left.GetDifference(right);

                Assert.Equal(expected, actual);
            }
コード例 #32
0
            public void can_find_distance_in_both_directions()
            {
                var a        = new Vector4F(1.0f, -2, -5, 0);
                var b        = new Vector4F(3.0f, 5, 1, 9);
                var expected = a.GetDistance(b);

                var actual = b.GetDistance(a);

                Assert.Equal(expected, actual);
            }
コード例 #33
0
            public void subtracting_vector_subtracts_from_components()
            {
                var actual   = new Vector4F(1.0f, 15, 5, 3);
                var right    = new Vector4F(3.0f, 4, 10, 1);
                var expected = new Vector4F(-2.0f, 11, -5, 2);

                actual.Subtract(right);

                Assert.Equal(expected, actual);
            }
コード例 #34
0
            public void can_find_distance_in_both_directions()
            {
                var a        = new Vector4F(16.0f, 2, 5, 3);
                var b        = new Vector4F(3.0f, 5, 1, -1);
                var expected = a.GetDistanceSquared(b);

                var actual = b.GetDistanceSquared(a);

                Assert.Equal(expected, actual);
            }
コード例 #35
0
            public void subtracting_vectors_leaves_right_unchanged()
            {
                var left          = new Vector4F(1.0f, 2, 3, 4);
                var right         = new Vector4F(3.0f, 4, 5, 6);
                var expectedRight = new Vector4F(right);

                left.Subtract(right);

                Assert.Equal(expectedRight, right);
            }
コード例 #36
0
        public static Vector4F Subtract(Vector4FParam1_3 vector, float scalar)
        {
            if (Sse.IsSupported)
            {
                Vector4F expand = Vector128.Create(scalar);
                return(Sse.Add(vector, expand));
            }

            return(SoftwareFallbacks.SoftwareFallbacksVector4F.Subtract_Software(vector, scalar));
        }
コード例 #37
0
            public void can_get_dot()
            {
                var left     = new Vector4F(9.0f, 1.2f, 3.5f, 0.1f);
                var right    = new Vector4F(-0.3f, 3.0f, -0.9f, 2.1f);
                var expected = (9.0f * -0.3f) + (1.2f * 3.0f) + (3.5f * -0.9f) + (0.1f * 2.1f);

                var actual = left.GetDot(right);

                Assert.Equal(expected, actual, 5);
            }
コード例 #38
0
        public static Vector4F Clamp(Vector4FParam1_3 vector, Vector4FParam1_3 low, Vector4FParam1_3 high)
        {
            if (Sse.IsSupported)
            {
                Vector4F temp = Sse.Min(vector, high);
                return(Sse.Max(temp, low));
            }

            return(SoftwareFallbacks.SoftwareFallbacksVector4F.Clamp_Software(vector, low, high));
        }
コード例 #39
0
            public void projecting_zero_against_another_vector_results_in_zero()
            {
                var u        = new Vector4F(3.0f, -17, 5, -6);
                var v        = new Vector4F();
                var expected = new Vector4F();

                var actual = u.GetProjected(v);

                Assert.Equal(expected, actual);
            }
コード例 #40
0
ファイル: Fog.cs プロジェクト: Zolniu/DigitalRune
 //--------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="Fog"/> class.
 /// </summary>
 public Fog()
 {
     Density = 1f;
       Height0 = 0;
       Color0 = new Vector4F(0.5f, 0.5f, 0.5f, 1);
       Height1 = 100;
       Color1 = new Vector4F(0.5f, 0.5f, 0.5f, 1);
       HeightFalloff = 0;
       Start = 0;
       End = 50;
 }
コード例 #41
0
 public void MultiplyTest()
 {
     var traits = Vector4FTraits.Instance;
       var value = new Vector4F(-1, -2, 3, 1);
       Assert.IsTrue(Vector4F.AreNumericallyEqual(Vector4F.Zero, traits.Multiply(value, 0)));
       Assert.IsTrue(Vector4F.AreNumericallyEqual(value, traits.Multiply(value, 1)));
       Assert.IsTrue(Vector4F.AreNumericallyEqual(value + value, traits.Multiply(value, 2)));
       Assert.IsTrue(Vector4F.AreNumericallyEqual(value + value + value, traits.Multiply(value, 3)));
       Assert.IsTrue(Vector4F.AreNumericallyEqual(-value, traits.Multiply(value, -1)));
       Assert.IsTrue(Vector4F.AreNumericallyEqual(-value - value, traits.Multiply(value, -2)));
       Assert.IsTrue(Vector4F.AreNumericallyEqual(-value - value - value, traits.Multiply(value, -3)));
 }
コード例 #42
0
ファイル: Terrain.cs プロジェクト: Zolniu/DigitalRune
        //--------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="Terrain"/> class.
        /// </summary>
        public Terrain()
        {
            InvalidBaseRegions = new List<Aabb>();
              InvalidDetailRegions = new List<Aabb>();
              Shape = Shape.Infinite;
              BaseClearValues = new Vector4F[4];
              DetailClearValues = new Vector4F[4];
              BaseClearValues[0] = new Vector4F(-10000, 0, 0, 1);

              Tiles = new TerrainTileCollection(this);

              Aabb = new Aabb();
        }
コード例 #43
0
ファイル: GradientSkyNode.cs プロジェクト: Zolniu/DigitalRune
        //--------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="GradientSkyNode" /> class.
        /// </summary>
        public GradientSkyNode()
        {
            SunDirection = new Vector3F(1, 1, 1);
              FrontColor = new Vector4F(0.9f, 0.5f, 0, 1);
              ZenithColor = new Vector4F(0, 0.4f, 0.9f, 1);
              BackColor = new Vector4F(0.4f, 0.6f, 0.9f, 1);
              GroundColor = new Vector4F(1, 0.8f, 0.6f, 1);
              FrontZenithShift = 0.5f;
              BackZenithShift = 0.5f;
              FrontGroundShift = 0.5f;
              BackGroundShift = 0.5f;

              CieSkyParameters = CieSkyParameters.Type12;
        }
コード例 #44
0
        public void FromByTest()
        {
            // IAnimationValueTraits<T> is used in a from-by animation to a add a relative offset to
              // the start value.

              var traits = Vector4FTraits.Instance;
              var from = new Vector4F(-1, -2, 3, 1);
              var by = new Vector4F(4, -5, 6, 1);

              var to = traits.Add(from, by);
              Assert.IsTrue(Vector4F.AreNumericallyEqual(by + from, to));

              Assert.IsTrue(Vector4F.AreNumericallyEqual(from, traits.Add(to, traits.Inverse(by))));
              Assert.IsTrue(Vector4F.AreNumericallyEqual(by, traits.Add(traits.Inverse(from), to)));
        }
コード例 #45
0
ファイル: Vector4FTest.cs プロジェクト: Zolniu/DigitalRune
        public void AreEqual()
        {
            float originalEpsilon = Numeric.EpsilonF;
              Numeric.EpsilonF = 1e-8f;

              Vector4F u = new Vector4F(1.0f, 2.0f, 3.0f, 4.0f);
              Vector4F v = new Vector4F(1.000001f, 2.000001f, 3.000001f, 4.000001f);
              Vector4F w = new Vector4F(1.00000001f, 2.00000001f, 3.00000001f, 4.00000001f);

              Assert.IsTrue(Vector4F.AreNumericallyEqual(u, u));
              Assert.IsFalse(Vector4F.AreNumericallyEqual(u, v));
              Assert.IsTrue(Vector4F.AreNumericallyEqual(u, w));

              Numeric.EpsilonF = originalEpsilon;
        }
コード例 #46
0
ファイル: Vector4FTest.cs プロジェクト: Zolniu/DigitalRune
        public void AbsoluteStatic()
        {
            Vector4F v = new Vector4F(-1, -2, -3, -4);
              Vector4F absoluteV = Vector4F.Absolute(v);

              Assert.AreEqual(1, absoluteV.X);
              Assert.AreEqual(2, absoluteV.Y);
              Assert.AreEqual(3, absoluteV.Z);
              Assert.AreEqual(4, absoluteV.W);

              v = new Vector4F(1, 2, 3, 4);
              absoluteV = Vector4F.Absolute(v);
              Assert.AreEqual(1, absoluteV.X);
              Assert.AreEqual(2, absoluteV.Y);
              Assert.AreEqual(3, absoluteV.Z);
              Assert.AreEqual(4, absoluteV.W);
        }
コード例 #47
0
ファイル: Vector4FTest.cs プロジェクト: Zolniu/DigitalRune
        public void Absolute()
        {
            Vector4F v = new Vector4F(-1, -2, -3, -4);
              v.Absolute();

              Assert.AreEqual(1, v.X);
              Assert.AreEqual(2, v.Y);
              Assert.AreEqual(3, v.Z);
              Assert.AreEqual(4, v.W);

              v = new Vector4F(1, 2, 3, 4);
              v.Absolute();
              Assert.AreEqual(1, v.X);
              Assert.AreEqual(2, v.Y);
              Assert.AreEqual(3, v.Z);
              Assert.AreEqual(4, v.W);
        }
コード例 #48
0
ファイル: FigureNode.cs プロジェクト: Zolniu/DigitalRune
        //--------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="FigureNode" /> class.
        /// </summary>
        /// <param name="figure">The figure.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="figure"/> is <see langword="null"/>.
        /// </exception>
        public FigureNode(Figure figure)
        {
            if (figure == null)
            throw new ArgumentNullException("figure");

              IsRenderable = true;
              _figure = figure;
              Shape = figure.BoundingShape;

              StrokeColor = new Vector3F(1, 1, 1);
              StrokeAlpha = 1;
              StrokeThickness = 1;
              StrokeDashPattern = new Vector4F(1, 0, 0, 0);
              DashInWorldSpace = true;
              FillColor = new Vector3F(1, 1, 1);
              FillAlpha = 1;
        }
コード例 #49
0
        public void Magnitude()
        {
            Vector4F v = new Vector4F(3.0f, 4.0f, 0.0f, 0.0f);
            Assert.AreEqual(25.0f, v.MagnitudeSquared, 1e-14);
            Assert.AreEqual(5.0f, v.Magnitude, 1e-14);

            v = new Vector4F(3.0f, 0.0f, 4.0f, 0.0f);
            Assert.AreEqual(25.0f, v.MagnitudeSquared, 1e-14);
            Assert.AreEqual(5.0f, v.Magnitude, 1e-14);

            v = new Vector4F(0.0f, 3.0f, 4.0f, 0.0f);
            Assert.AreEqual(25.0f, v.MagnitudeSquared, 1e-14);
            Assert.AreEqual(5.0f, v.Magnitude, 1e-14);

            v = new Vector4F(0.0f, 0.0f, 3.0f, 4.0f);
            Assert.AreEqual(25.0f, v.MagnitudeSquared, 1e-14);
            Assert.AreEqual(5.0f, v.Magnitude, 1e-14);
        }
コード例 #50
0
        public void CycleOffsetTest()
        {
            // IAnimationValueTraits<T> is used in a cyclic animation to a add the cycle offset in
              // each iteration.

              var traits = Vector4FTraits.Instance;
              var first = new Vector4F(1, 2, 3, 1);    // Animation value of first key frame.
              var last = new Vector4F(-4, 5, -6, 5);   // Animation value of last key frame.
              var cycleOffset = traits.Add(traits.Inverse(first), last);

              // Cycle offset should be the difference between last and first key frame.
              Assert.IsTrue(Vector4F.AreNumericallyEqual(last, traits.Add(first, cycleOffset)));
              Assert.IsTrue(Vector4F.AreNumericallyEqual(last, cycleOffset + first));

              // Check multiple cycles (post-loop).
              Assert.IsTrue(Vector4F.AreNumericallyEqual(last, traits.Add(first, traits.Multiply(cycleOffset, 1))));
              Assert.IsTrue(Vector4F.AreNumericallyEqual(cycleOffset + cycleOffset + last, traits.Add(first, traits.Multiply(cycleOffset, 3))));

              // Check multiple cycles (pre-loop).
              Assert.IsTrue(Vector4F.AreNumericallyEqual(first, traits.Add(last, traits.Multiply(cycleOffset, -1))));
              Assert.IsTrue(Vector4F.AreNumericallyEqual(first - cycleOffset - cycleOffset, traits.Add(last, traits.Multiply(cycleOffset, -3))));
        }
コード例 #51
0
ファイル: Window.cs プロジェクト: Prashant-Jonny/phever
        private void ScaleCameraDistance(float scale)
        {
            Vector4F eye4 = new Vector4F(Eye.X, Eye.Y, Eye.Z, 0);
            Matrix4x4F transform = MatrixMath.MatrixScale(scale, scale, scale);
            eye4 = MatrixMath.VectorMultiply(transform, eye4);
            Eye = new Vector3F(eye4.X, eye4.Y, eye4.Z);

            effects.ViewMatrix = DXUtil.Camera.MatrixLookAtLH(Eye, At, Up);
        } 
コード例 #52
0
ファイル: Window.cs プロジェクト: Prashant-Jonny/phever
        private void RenderFlag(float t, double a, int shells)
        {
            TechniqueDescription techDesc = effects.Technique.Description;
            for (int x = -shells; x <= shells; x++)
            {
                for (int z = -shells; z <= shells; z++)
                {
                    float height = ((float)Math.Sin(0.5 * (x + 4 * t)) + (float)Math.Cos(0.25 * (z + 2 * t)));
                    Vector4F vBaseColor = new Vector4F( 0.0f, 0.0f, 0.0f, 1.0f );
                    if (x < 0 && z > 0)
                        vBaseColor.X = 0.75f + 0.125f * height; //red
                    else if (x > 0 && z > 0)
                        vBaseColor.Y = 0.75f + 0.125f * height; //green
                    else if (x < 0 && z < 0)
                        vBaseColor.Z = 0.75f + 0.125f * height; //blue
                    else if (x > 0 && z < 0)
                    {//yellow
                        vBaseColor.X= 0.75f + 0.125f * height;
                        vBaseColor.Y = 0.75f + 0.125f * height;
                    }
                    else
                        continue;
                    effects.BaseColor = vBaseColor;
                    
                    float yScale = 5f + 0.5f * height;
                    effects.WorldMatrix = 
                        MatrixMath.MatrixScale(0.35f, yScale, 0.35f) * 
                        MatrixMath.MatrixTranslate(x, yScale - 10 , z);

                    for (uint p = 0; p < techDesc.Passes; ++p)
                    {
                        effects.Technique.GetPassByIndex(p).Apply();
                        device.DrawIndexed(36, 0, 0);
                    }
                }
            }
        }
コード例 #53
0
        /// <summary>
        /// Gets the bounds of the specified sphere relative to the viewport.
        /// </summary>
        /// <param name="cameraNode">The camera node.</param>
        /// <param name="positionWorld">The sphere center in world space.</param>
        /// <param name="radius">The sphere radius.</param>
        /// <returns>
        /// The bounds (left, top, right, bottom) where each entry is in the range [0, 1].
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="cameraNode"/> is <see langword="null"/>.
        /// </exception>
        internal static Vector4F GetBounds(CameraNode cameraNode, Vector3F positionWorld, float radius)
        {
            var camera = cameraNode.Camera;
              var projection = camera.Projection;
              float near = projection.Near;
              float left = projection.Left;
              float width = projection.Width;
              float top = projection.Top;
              float height = projection.Height;

              Vector3F l = cameraNode.PoseWorld.ToLocalPosition(positionWorld);
              float r = radius;

              // Default bounds (left, top, right, bottom)
              var bounds = new Vector4F(0, 0, 1, 1);

              // ----- Solve for N = (x, 0, z).

              // Discriminant already divided by 4:
              float d = (r * r * l.X * l.X - (l.X * l.X + l.Z * l.Z) * (r * r - l.Z * l.Z));
              if (d > 0)
              {
            // Camera is outside the sphere.

            float rootD = (float)Math.Sqrt(d);

            // Now check two possible solutions (+/- rootD):
            float nx1 = (r * l.X + rootD) / (l.X * l.X + l.Z * l.Z);
            float nx2 = (r * l.X - rootD) / (l.X * l.X + l.Z * l.Z);

            float nz1 = (r - nx1 * l.X) / l.Z;
            float nz2 = (r - nx2 * l.X) / l.Z;

            // Compute tangent position (px, 0, pz) on the sphere.
            float pz1 = (l.X * l.X + l.Z * l.Z - r * r) / (l.Z - (nz1 / nx1) * l.X);
            float pz2 = (l.X * l.X + l.Z * l.Z - r * r) / (l.Z - (nz2 / nx2) * l.X);

            if (pz1 < 0)
            {
              // Plane (nx1, 0, nz1) is within camera frustum.

              float px = -pz1 * nz1 / nx1;

              float x = nz1 * near / nx1;             // x coordinate on the near plane.
              float boundsX = (x - left) / width;    // Value relative to viewport. (0 = left, 1 = right)

              // Shrink the scissor rectangle on the left or on the right side.
              if (px < l.X)
            bounds.X = Math.Max(bounds.X, boundsX);
              else
            bounds.Z = Math.Min(bounds.Z, boundsX);
            }

            if (pz2 < 0)
            {
              float px = -pz2 * nz2 / nx2;

              float x = nz2 * near / nx2;
              float scissorX = (x - left) / width;

              if (px < l.X)
            bounds.X = Math.Max(bounds.X, scissorX);
              else
            bounds.Z = Math.Min(bounds.Z, scissorX);
            }
              }

              // ----- Solve for N = (0, y, z) first.

              d = (r * r * l.Y * l.Y - (l.Y * l.Y + l.Z * l.Z) * (r * r - l.Z * l.Z));
              if (d > 0)
              {
            // Camera is outside the sphere.

            float rootD = (float)Math.Sqrt(d);

            float ny1 = (r * l.Y + rootD) / (l.Y * l.Y + l.Z * l.Z);
            float ny2 = (r * l.Y - rootD) / (l.Y * l.Y + l.Z * l.Z);

            float nz1 = (r - ny1 * l.Y) / l.Z;
            float nz2 = (r - ny2 * l.Y) / l.Z;

            float pz1 = (l.Y * l.Y + l.Z * l.Z - r * r) / (l.Z - (nz1 / ny1) * l.Y);
            float pz2 = (l.Y * l.Y + l.Z * l.Z - r * r) / (l.Z - (nz2 / ny2) * l.Y);

            if (pz1 < 0)
            {
              float py = -pz1 * nz1 / ny1;

              float y = nz1 * near / ny1;
              float scissorY = -(y - top) / height;

              if (py > l.Y)
            bounds.Y = Math.Max(bounds.Y, scissorY);
              else
            bounds.W = Math.Min(bounds.W, scissorY);
            }

            if (pz2 < 0)
            {
              float py = -pz2 * nz2 / ny2;

              float y = nz2 * near / ny2;
              float scissorY = -(y - top) / height;

              if (py > l.Y)
            bounds.Y = Math.Max(bounds.Y, scissorY);
              else
            bounds.W = Math.Min(bounds.W, scissorY);
            }
              }

              bounds.X = MathHelper.Clamp(bounds.X, 0, 1);
              bounds.Y = MathHelper.Clamp(bounds.Y, 0, 1);
              bounds.Z = MathHelper.Clamp(bounds.Z, bounds.X, 1);
              bounds.W = MathHelper.Clamp(bounds.W, bounds.Y, 1);

              return bounds;
        }
コード例 #54
0
ファイル: EffectHelper.cs プロジェクト: Zolniu/DigitalRune
 public static void SetColor(this EffectParameter parameter, Vector4F color)
 {
     if (parameter.ColumnCount == 4)
       {
     parameter.SetValue((Vector4)color);
       }
       else
       {
     Vector3 value = new Vector3(color.X, color.Y, color.Z);
     parameter.SetValue(value);
       }
 }
コード例 #55
0
        private void Render(RenderContext context, Vector4F color, Texture2D colorTexture, bool preserveColor)
        {
            if (context == null)
            throw new ArgumentNullException("context");

              context.Validate(_effect);
              context.ThrowIfCameraMissing();
              context.ThrowIfGBuffer0Missing();

              var graphicsDevice = _effect.GraphicsDevice;
              var savedRenderState = new RenderStateSnapshot(graphicsDevice);
              graphicsDevice.DepthStencilState = GraphicsHelper.DepthStencilStateAlways;
              graphicsDevice.RasterizerState = RasterizerState.CullNone;

              if (preserveColor)
            graphicsDevice.BlendState = GraphicsHelper.BlendStateNoColorWrite;
              else
            graphicsDevice.BlendState = BlendState.Opaque;

              if (colorTexture != null)
              {
            if (TextureHelper.IsFloatingPointFormat(colorTexture.Format))
              graphicsDevice.SamplerStates[1] = SamplerState.PointClamp;
            else
              graphicsDevice.SamplerStates[1] = SamplerState.LinearClamp;
              }

              var projection = context.CameraNode.Camera.Projection;
              bool isPerspective = projection is PerspectiveProjection;
              float near = projection.Near * NearBias;
              float far = projection.Far * FarBias;
              var biasedProjection = isPerspective
                               ? Matrix44F.CreatePerspectiveOffCenter(
                                 projection.Left, projection.Right,
                                 projection.Bottom, projection.Top,
                                 near, far)
                               : Matrix44F.CreateOrthographicOffCenter(
                                 projection.Left, projection.Right,
                                 projection.Bottom, projection.Top,
                                 near, far);

              var viewport = graphicsDevice.Viewport;
              _parameterViewportSize.SetValue(new Vector2(viewport.Width, viewport.Height));
              _parameterProjection.SetValue((Matrix)biasedProjection);
              _parameterCameraFar.SetValue(projection.Far);
              _parameterGBuffer0.SetValue(context.GBuffer0);
              _parameterColor.SetValue((Vector4)color);
              _parameterSourceTexture.SetValue(colorTexture);

              _effect.CurrentTechnique = isPerspective ? _techniquePerspective : _techniqueOrthographic;
              _effect.CurrentTechnique.Passes[(colorTexture == null) ? 0 : 1].Apply();

              graphicsDevice.DrawFullScreenQuad();

              graphicsDevice.ResetTextures();

              savedRenderState.Restore();
        }
コード例 #56
0
 //--------------------------------------------------------------
 /// <overloads>
 /// <summary>
 /// Rebuilds the current hardware Z-buffer from the G-Buffer and optionally writes a color or
 /// texture to the render target.
 /// </summary>
 /// </overloads>
 /// 
 /// <summary>
 /// Rebuilds the current hardware Z-buffer from the G-Buffer and writes the specified color 
 /// value to the current render target.
 /// </summary>
 /// <param name="context">
 /// The render context. (<see cref="RenderContext.CameraNode"/> and 
 /// <see cref="RenderContext.GBuffer0"/> need to be set.)
 /// </param>
 /// <param name="color">The color to be written to the render target.</param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="context"/> is <see langword="null"/>.
 /// </exception>
 public void Render(RenderContext context, Vector4F color)
 {
     Render(context, color, null, false);
 }
コード例 #57
0
ファイル: GodRayFilter.cs プロジェクト: Zolniu/DigitalRune
        protected override void OnProcess(RenderContext context)
        {
            context.ThrowIfCameraMissing();
              context.ThrowIfGBuffer0Missing();

              var graphicsDevice = GraphicsService.GraphicsDevice;
              var renderTargetPool = GraphicsService.RenderTargetPool;

              var source = context.SourceTexture;
              var target = context.RenderTarget;
              var viewport = context.Viewport;

              // Get temporary render targets.
              var sourceSize = new Vector2F(source.Width, source.Height);
              var isFloatingPointFormat = TextureHelper.IsFloatingPointFormat(source.Format);

              var sceneFormat = new RenderTargetFormat(source.Width, source.Height, false, source.Format, DepthFormat.None);
              var maskedScene = renderTargetPool.Obtain2D(sceneFormat);

              var rayFormat = new RenderTargetFormat(
            Math.Max(1, (int)(sourceSize.X / DownsampleFactor)),
            Math.Max(1, (int)(sourceSize.Y / DownsampleFactor)),
            false,
            source.Format,
            DepthFormat.None);
              var rayImage0 = renderTargetPool.Obtain2D(rayFormat);
              var rayImage1 = renderTargetPool.Obtain2D(rayFormat);

              // Get view and view-projection transforms.
              var cameraNode = context.CameraNode;
              Matrix44F projection = cameraNode.Camera.Projection.ToMatrix44F();
              Matrix44F view = cameraNode.View;
              Matrix44F viewProjection = projection * view;

              // We simply place the light source "far away" in opposite light ray direction.
              Vector4F lightPositionWorld = new Vector4F(-LightDirection * 10000, 1);

              // Convert to clip space.
              Vector4F lightPositionProj = viewProjection * lightPositionWorld;
              Vector3F lightPositionClip = Vector4F.HomogeneousDivide(lightPositionProj);

              // Convert from clip space [-1, 1] to texture space [0, 1].
              Vector2 lightPosition = new Vector2(lightPositionClip.X * 0.5f + 0.5f, -lightPositionClip.Y * 0.5f + 0.5f);

              // We use dot²(forward, -LightDirection) as a smooth S-shaped attenuation
              // curve to reduce the god ray effect when we look orthogonal or away from the sun.
              var lightDirectionView = view.TransformDirection(LightDirection);
              float z = Math.Max(0, lightDirectionView.Z);
              float attenuation = z * z;

              // Common effect parameters.
              _parameters0Parameter.SetValue(new Vector4(lightPosition.X, lightPosition.Y, LightRadius * LightRadius, Scale));
              _parameters1Parameter.SetValue(new Vector2(Softness, graphicsDevice.Viewport.AspectRatio));
              _intensityParameter.SetValue((Vector3)Intensity * attenuation);
              _numberOfSamplesParameter.SetValue(NumberOfSamples);
              _gBuffer0Parameter.SetValue(context.GBuffer0);

              // First, create a scene image where occluders are black.
              graphicsDevice.SetRenderTarget(maskedScene);
              _viewportSizeParameter.SetValue(new Vector2(graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height));
              _sourceTextureParameter.SetValue(source);
              graphicsDevice.SamplerStates[0] = isFloatingPointFormat ? SamplerState.PointClamp : SamplerState.LinearClamp;
              graphicsDevice.SamplerStates[1] = SamplerState.PointClamp;   // G-Buffer 0.
              _createMaskPass.Apply();
              graphicsDevice.DrawFullScreenQuad();

              // Downsample image.
              context.SourceTexture = maskedScene;
              context.RenderTarget = rayImage0;
              context.Viewport = new Viewport(0, 0, rayImage0.Width, rayImage0.Height);
              _downsampleFilter.Process(context);

              // Compute light shafts.
              _viewportSizeParameter.SetValue(new Vector2(context.Viewport.Width, context.Viewport.Height));
              graphicsDevice.SamplerStates[0] = isFloatingPointFormat ? SamplerState.PointClamp : SamplerState.LinearClamp;
              for (int i = 0; i < NumberOfPasses; i++)
              {
            graphicsDevice.SetRenderTarget(rayImage1);
            _sourceTextureParameter.SetValue(rayImage0);
            _blurPass.Apply();
            graphicsDevice.DrawFullScreenQuad();

            // Put the current result in variable rayImage0.
            MathHelper.Swap(ref rayImage0, ref rayImage1);
              }

              // Combine light shaft image with scene.
              graphicsDevice.SetRenderTarget(target);
              graphicsDevice.Viewport = viewport;
              _viewportSizeParameter.SetValue(new Vector2(graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height));
              _sourceTextureParameter.SetValue(source);
              _rayTextureParameter.SetValue(rayImage0);
              graphicsDevice.SamplerStates[0] = isFloatingPointFormat ? SamplerState.PointClamp : SamplerState.LinearClamp;
              graphicsDevice.SamplerStates[1] = isFloatingPointFormat ? SamplerState.PointClamp : SamplerState.LinearClamp;
              _combinePass.Apply();
              graphicsDevice.DrawFullScreenQuad();

              // Clean-up
              _sourceTextureParameter.SetValue((Texture2D)null);
              _gBuffer0Parameter.SetValue((Texture2D)null);
              _rayTextureParameter.SetValue((Texture2D)null);
              renderTargetPool.Recycle(maskedScene);
              renderTargetPool.Recycle(rayImage0);
              renderTargetPool.Recycle(rayImage1);
              context.SourceTexture = source;
              context.RenderTarget = target;
              context.Viewport = viewport;
        }
コード例 #58
0
ファイル: EffectHelper.cs プロジェクト: Zolniu/DigitalRune
 public static void SetDirection(this EffectParameter parameter, Vector4F direction)
 {
     CheckDirectionVector(parameter, (Vector4)direction);
       if (parameter.ColumnCount == 4)
       {
     parameter.SetValue((Vector4)direction);
       }
       else
       {
     Vector3 value = new Vector3(direction.X, direction.Y, direction.Z);
     parameter.SetValue(value);
       }
 }
コード例 #59
0
ファイル: EffectHelper.cs プロジェクト: Zolniu/DigitalRune
 public static void SetPosition(this EffectParameter parameter, Vector4F position)
 {
     CheckPositionVector(parameter, (Vector4)position);
       if (parameter.ColumnCount == 4)
       {
     parameter.SetValue((Vector4)position);
       }
       else
       {
     Vector3 value = new Vector3(position.X, position.Y, position.Z);
     parameter.SetValue(value);
       }
 }
コード例 #60
0
        public void GetValueTest()
        {
            var animation = new AnimationClip<float>
              {
            Animation = new SingleFromToByAnimation
            {
              From = 100,
              To = 200,
              Duration = TimeSpan.FromSeconds(6.0),
            },
            Delay = TimeSpan.FromSeconds(10),
            Speed = 2,
            FillBehavior = FillBehavior.Hold,
              };

              var animation2 = new AnimationClip<float>
              {
            Animation = new SingleFromToByAnimation
            {
              From = 10,
              To = 20,
              Duration = TimeSpan.FromSeconds(5.0),
            },
            Delay = TimeSpan.Zero,
            Speed = 1,
            FillBehavior = FillBehavior.Hold,
              };

              var animation3 = new AnimationClip<float>
              {
            Animation = new SingleFromToByAnimation
            {
              From = 5,
              To = -5,
              Duration = TimeSpan.FromSeconds(10),
            },
            Delay = TimeSpan.FromSeconds(5),
            Speed = 1,
            FillBehavior = FillBehavior.Hold,
              };

              var animation4 = new AnimationClip<float>
              {
            Animation = new SingleFromToByAnimation
            {
              From = 1000,
              To = 1100,
              Duration = TimeSpan.FromSeconds(5.0),
            },
            Delay = TimeSpan.FromSeconds(5),
            Speed = 1,
            FillBehavior = FillBehavior.Stop,
              };

              var animationEx = new Vector4FAnimation
              {
            X = animation,
            Y = animation2,
            Z = animation3,
            W = animation4,
              };

              var defaultSource = new Vector4F(1, 2, 3, 4);
              var defaultTarget = new Vector4F(5, 6, 7, 8);

              var result = animationEx.GetValue(TimeSpan.FromSeconds(0.0), defaultSource, defaultTarget);
              Assert.AreEqual(defaultSource.X, result.X); // animation has not started.
              Assert.AreEqual(10.0f, result.Y);           // animation2 has started.
              Assert.AreEqual(defaultSource.Z, result.Z); // animation3 has not started.
              Assert.AreEqual(defaultSource.W, result.W); // animation4 has not started.

              result = animationEx.GetValue(TimeSpan.FromSeconds(5.0), defaultSource, defaultTarget);
              Assert.AreEqual(defaultSource.X, result.X); // animation has not started.
              Assert.AreEqual(20.0f, result.Y);           // animation2 has ended.
              Assert.AreEqual(5, result.Z);               // animation3 has started.
              Assert.AreEqual(1000, result.W);            // animation4 has started.

              result = animationEx.GetValue(TimeSpan.FromSeconds(5.0), defaultSource, defaultTarget);
              Assert.AreEqual(defaultSource.X, result.X); // animation has not started.
              Assert.AreEqual(20.0f, result.Y);           // animation2 has ended.
              Assert.AreEqual(5, result.Z);               // animation3 has started.
              Assert.AreEqual(1000, result.W);            // animation4 has started.

              result = animationEx.GetValue(TimeSpan.FromSeconds(13.0), defaultSource, defaultTarget);
              Assert.AreEqual(200, result.X);             // animation has ended.
              Assert.AreEqual(20.0f, result.Y);           // animation2 is filling.
              Assert.AreEqual(-3, result.Z);              // animation3 is active.
              Assert.AreEqual(defaultSource.W, result.W); // animation4 is stopped.
        }