예제 #1
0
        private void GetReferences(string data, out Vect4f v, out Vect3f t, out Vect3f n)
        {
            v = null;
            t = null;
            n = null;
            var split = data.Split('/');

            switch (split.Length)
            {
            case 3:
                n = Normals[int.Parse(split[2]) - 1];
                goto case 2;

            case 2:
                t = TextureVertices[int.Parse(split[1]) - 1];
                goto case 1;

            case 1:
                v = Vertices[int.Parse(split[0]) - 1];
                break;

            default:
                throw new Exception();
            }
        }
예제 #2
0
        public void LengthResult()
        {
            var v4 = new Vect4f(2.0f, 3.0f, 5.0f, 7.0f);

            Assert.AreEqual(87, v4.LengthSquared, Constants.Delta);
            Assert.AreEqual(9.32737922668457, v4.Length, Constants.Delta);
        }
예제 #3
0
        public static dynamic Swizzle(this Vect4f v)
        {
            var s = new Swizzle <float>();

            s.Add('X', v.X);
            s.Add('Y', v.Y);
            s.Add('Z', v.Z);
            s.Add('W', v.W);
            return(s);
        }
예제 #4
0
        public void CreationFromDoubles()
        {
            var x = 2.0f;
            var y = 3.0f;
            var z = 5.0f;
            var w = 7.0f;

            var v4 = new Vect4f(x, y, z, w);

            Assert.AreEqual(x, v4.X, Constants.Delta);
            Assert.AreEqual(y, v4.Y, Constants.Delta);
            Assert.AreEqual(z, v4.Z, Constants.Delta);
            Assert.AreEqual(w, v4.W, Constants.Delta);
        }
예제 #5
0
 public void CreationFromListTooLong()
 {
     try
     {
         var v = new Vect4f(new[] { 2.0f, 3.0f, 5.0f, 7.0f, 7.0f });
         Assert.Fail(); // If it gets to this line, no exception was thrown
     }
     catch (ArgumentException)
     {
     }
     catch (Exception)
     {
         Assert.Fail();
     }
 }
예제 #6
0
        public void SwizzleTypes()
        {
            var vd = new Vect4(5, 6, 7, 8);
            var vf = new Vect4f(5, 6, 7, 8);

            Assert.AreEqual(typeof(double), vd.Swizzle().X.GetType());
            Assert.AreEqual(typeof(Vect2), vd.Swizzle().XX.GetType());
            Assert.AreEqual(typeof(Vect3), vd.Swizzle().XXX.GetType());
            Assert.AreEqual(typeof(Vect4), vd.Swizzle().XXXX.GetType());
            Assert.AreEqual(typeof(Vect), vd.Swizzle().XXXXX.GetType());

            Assert.AreEqual(typeof(float), vf.Swizzle().X.GetType());
            Assert.AreEqual(typeof(Vect2f), vf.Swizzle().XX.GetType());
            Assert.AreEqual(typeof(Vect3f), vf.Swizzle().XXX.GetType());
            Assert.AreEqual(typeof(Vect4f), vf.Swizzle().XXXX.GetType());
            Assert.AreEqual(typeof(Vectf), vf.Swizzle().XXXXX.GetType());
        }
예제 #7
0
        public void Vect4fEquality()
        {
            var a = new Vect4f(2.0f, 3.0f, 5.0f, 6.0f);
            var b = new Vect4f(2.0f, 3.0f, 5.0f, 6.0f);
            var c = new Vect4f(3.0f, 3.0f, 6.0f, 7.0f);
            var d = a;

            Assert.IsTrue(a.Equals(b));
            Assert.IsFalse(a.Equals(c));
            Assert.IsTrue(a.Equals(d));

            Assert.AreEqual(a, b);
            Assert.AreNotEqual(a, c);
            Assert.AreEqual(a, d);

            Assert.IsTrue(a == b);
            Assert.IsTrue(a != c);

            Assert.IsTrue(a != null);
        }