示例#1
0
 public void Constructors()
 {
     {
         var v = new bvec3(false);
         Assert.AreEqual(false, v.x);
         Assert.AreEqual(false, v.y);
         Assert.AreEqual(false, v.z);
     }
     {
         var v = new bvec3(false, true, false);
         Assert.AreEqual(false, v.x);
         Assert.AreEqual(true, v.y);
         Assert.AreEqual(false, v.z);
     }
     {
         var v = new bvec3(new bvec2(false, false));
         Assert.AreEqual(false, v.x);
         Assert.AreEqual(false, v.y);
         Assert.AreEqual(false, v.z);
     }
     {
         var v = new bvec3(new bvec3(true, false, true));
         Assert.AreEqual(true, v.x);
         Assert.AreEqual(false, v.y);
         Assert.AreEqual(true, v.z);
     }
     {
         var v = new bvec3(new bvec4(false, false, true, false));
         Assert.AreEqual(false, v.x);
         Assert.AreEqual(false, v.y);
         Assert.AreEqual(true, v.z);
     }
 }
示例#2
0
        public void PropertyValues()
        {
            var v    = new bvec3(false, true, false);
            var vals = v.Values;

            Assert.AreEqual(false, vals[0]);
            Assert.AreEqual(true, vals[1]);
            Assert.AreEqual(false, vals[2]);
            Assert.That(vals.SequenceEqual(v.ToArray()));
        }
示例#3
0
        public void SerializationJson()
        {
            var v0 = new bvec3(false, false, true);
            var s0 = JsonConvert.SerializeObject(v0);

            var v1 = JsonConvert.DeserializeObject <bvec3>(s0);
            var s1 = JsonConvert.SerializeObject(v1);

            Assert.AreEqual(v0, v1);
            Assert.AreEqual(s0, s1);
        }
示例#4
0
        public void Operators()
        {
            var v1 = new bvec3(true, true, false);
            var v2 = new bvec3(true, true, false);
            var v3 = new bvec3(false, true, true);

            Assert.That(v1 == new bvec3(v1));
            Assert.That(v2 == new bvec3(v2));
            Assert.That(v3 == new bvec3(v3));
            Assert.That(v1 == v2);
            Assert.That(v1 != v3);
            Assert.That(v2 != v3);
        }
示例#5
0
        public void Indexer()
        {
            var v = new bvec3(false, true, false);

            Assert.AreEqual(false, v[0]);
            Assert.AreEqual(true, v[1]);
            Assert.AreEqual(false, v[2]);

            Assert.Throws <ArgumentOutOfRangeException>(() => { var s = v[-2147483648]; });
            Assert.Throws <ArgumentOutOfRangeException>(() => { v[-2147483648] = false; });
            Assert.Throws <ArgumentOutOfRangeException>(() => { var s = v[-1]; });
            Assert.Throws <ArgumentOutOfRangeException>(() => { v[-1] = false; });
            Assert.Throws <ArgumentOutOfRangeException>(() => { var s = v[3]; });
            Assert.Throws <ArgumentOutOfRangeException>(() => { v[3] = false; });
            Assert.Throws <ArgumentOutOfRangeException>(() => { var s = v[2147483647]; });
            Assert.Throws <ArgumentOutOfRangeException>(() => { v[2147483647] = false; });
            Assert.Throws <ArgumentOutOfRangeException>(() => { var s = v[5]; });
            Assert.Throws <ArgumentOutOfRangeException>(() => { v[5] = false; });

            v[1] = false;
            Assert.AreEqual(false, v[1]);
            v[1] = true;
            Assert.AreEqual(true, v[1]);
        }
示例#6
0
        public void StringInterop()
        {
            var v = new bvec3(true, false, false);

            var s0 = v.ToString();
            var s1 = v.ToString("#");

            var v0 = bvec3.Parse(s0);
            var v1 = bvec3.Parse(s1, "#");

            Assert.AreEqual(v, v0);
            Assert.AreEqual(v, v1);

            var b0 = bvec3.TryParse(s0, out v0);
            var b1 = bvec3.TryParse(s1, "#", out v1);

            Assert.That(b0);
            Assert.That(b1);
            Assert.AreEqual(v, v0);
            Assert.AreEqual(v, v1);

            b0 = bvec3.TryParse(null, out v0);
            Assert.False(b0);
            b0 = bvec3.TryParse("", out v0);
            Assert.False(b0);
            b0 = bvec3.TryParse(s0 + ", 0", out v0);
            Assert.False(b0);

            Assert.Throws <NullReferenceException>(() => { bvec3.Parse(null); });
            Assert.Throws <FormatException>(() => { bvec3.Parse(""); });
            Assert.Throws <FormatException>(() => { bvec3.Parse(s0 + ", 0"); });

            var s2 = v.ToString(";", CultureInfo.InvariantCulture);

            Assert.That(s2.Length > 0);
        }
 /// <summary>
 /// Selects which vector each returned component comes from. For a component of a that is false, 
 /// the corresponding component of x is returned. For a component of a that is true, 
 /// the corresponding component of y is returned. Components of x and y that are not selected 
 /// are allowed to be invalid floating point values and will have no effect on the results. 
 /// Thus, this provides different functionality than, for example,
 /// genType Lerp(genType x, genType y, genType(a)) where a is a Boolean vector.
 /// </summary>
 protected internal static dvec3 Lerp(dvec3 x, dvec3 y, bvec3 a)
 {
     throw _invalidAccess;
 }
 public bvec4(bool x, bvec3 yzw)
 {
     throw _invalidAccess;
 }
示例#9
0
        public static bvec3 notEqual(bvec3 x, bvec3 y)
        {
            bvec3 r;

            r.x = x.x != y.x;
            r.y = x.y != y.y;
            r.z = x.z != y.z;

            return r;
        }
 protected extern bvec3 any(bvec3 x, bvec3 y);
 protected extern bvec3 notEqual(bvec3 x, bvec3 y);
 protected extern vec3 mix(vec3 x, vec3 y, bvec3 a);
示例#13
0
 public bvec4(bool x, bvec3 yzw)
 {
     throw _invalidAccess;
 }
示例#14
0
 /// <summary>
 /// Returns the component-wise logical complement of x.
 /// </summary>
 /// <param name="x"></param>
 /// <returns></returns>
 public static bvec3 not(bvec3 x)
 {
     return(null);
 }
示例#15
0
 /// <summary>
 /// Returns the component-wise compare of x != y.
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <returns></returns>
 public static bvec3 notEqual(bvec3 x, bvec3 y)
 {
     return(null);
 }
示例#16
0
 protected vec3 mix(vec3 x, vec3 y, bvec3 a)
 {
     throw new NotImplementedException();
 }
示例#17
0
 public static bool any(bvec3 x)
 {
     return x.x || x.y || x.z;
 }
示例#18
0
 public static bool all(bvec3 x)
 {
     return x.x && x.y && x.z;
 }
示例#19
0
        public static bvec3 not(bvec3 x)
        {
            bvec3 r;

            r.x = !x.x;
            r.y = !x.y;
            r.z = !x.z;

            return r;
        }
示例#20
0
 protected bvec3 not(bvec3 x, bvec3 y)
 {
     throw new NotImplementedException();
 }
示例#21
0
 public static dvec3 mix(dvec3 a, dvec3 b, bvec3 t)
 {
     return(new dvec3(t.x ? a.x : b.x, t.y ? a.y : b.y, t.z ? a.z : b.z));
 }
示例#22
0
 /// <summary>
 /// Returns true only if all components of x are true.
 /// </summary>
 /// <param name="x"></param>
 /// <returns></returns>
 public static bool all(bvec3 x)
 {
     return(false);
 }
示例#23
0
 public static ivec3 mix(ivec3 a, ivec3 b, bvec3 t)
 {
     return(new ivec3(t.x ? a.x : b.x, t.y ? a.y : b.y, t.z ? a.z : b.z));
 }
示例#24
0
 public bvec4(bvec3 xyz, bool w)
 {
     throw _invalidAccess;
 }
示例#25
0
 public static uvec3 mix(uvec3 a, uvec3 b, bvec3 t)
 {
     return(new uvec3(t.x ? a.x : b.x, t.y ? a.y : b.y, t.z ? a.z : b.z));
 }
 /// <summary>
 /// </summary>
 /// <param name="uniformName"></param>
 /// <param name="values"></param>
 /// <returns></returns>
 public int SetUniform(string uniformName, bvec3[] values)
 {
     int location = GetUniformLocation(uniformName);
     if (location >= 0)
     {
         if (glUniform3iv == null) { glUniform3iv = OpenGL.GetDelegateFor<OpenGL.glUniform3iv>(); }
         int count = values.Length;
         var value = new int[count * 3];
         int index = 0;
         for (int i = 0; i < value.Length; i++)
         {
             value[index++] = values[i].x ? 1 : 0;
             value[index++] = values[i].y ? 1 : 0;
             value[index++] = values[i].z ? 1 : 0;
         }
         glUniform3iv(location, count, value);
     }
     return location;
 }
示例#27
0
 public static bool any(bvec3 a)
 {
     return(a.x || a.y || a.z);
 }
 protected extern bvec3 equal(bvec3 x, bvec3 y);
示例#29
0
 public static bool all(bvec3 a)
 {
     return(a.x && a.y && a.z);
 }
 protected extern bvec3 all(bvec3 x, bvec3 y);
 public bvec4(bvec3 xyz, bool w)
 {
     throw _invalidAccess;
 }
 protected extern bvec3 not(bvec3 x, bvec3 y);
示例#33
0
        public static bvec3 equal(bvec3 x, bvec3 y)
        {
            bvec3 r;

            r.x = x.x == y.x;
            r.y = x.y == y.y;
            r.z = x.z == y.z;

            return r;
        }