public void Constructors() { { var v = new bvec2(false); Assert.AreEqual(false, v.x); Assert.AreEqual(false, v.y); } { var v = new bvec2(true, false); Assert.AreEqual(true, v.x); Assert.AreEqual(false, v.y); } { var v = new bvec2(new bvec2(false, false)); Assert.AreEqual(false, v.x); Assert.AreEqual(false, v.y); } { var v = new bvec2(new bvec3(false, false, true)); Assert.AreEqual(false, v.x); Assert.AreEqual(false, v.y); } { var v = new bvec2(new bvec4(true, false, false, true)); Assert.AreEqual(true, v.x); Assert.AreEqual(false, v.y); } }
/// <summary> /// ベジェ関数 /// </summary> /// <param name="v1">ベジェ形状パラメータ1</param> /// <param name="v2">ベジェ形状パラメータ2</param> /// <param name="s">変数</param> /// <returns>ベジェ関数値</returns> private float BezEvaluate(bvec2 v1, bvec2 v2, float s) { var curve = new MMDFileParser.MotionParser.ベジェ曲線(); curve.v1 = v1.ToSharpDX() / 127; curve.v2 = v2.ToSharpDX() / 127; return(curve.横位置Pxに対応する縦位置Pyを返す(s)); }
/// <summary> /// ベジェ関数 /// </summary> /// <param name="v1">ベジェ形状パラメータ1</param> /// <param name="v2">ベジェ形状パラメータ2</param> /// <param name="s">変数</param> /// <returns>ベジェ関数値</returns> private float BezEvaluate(bvec2 v1, bvec2 v2, float s) { var curve = new MMDFileParser.MotionParser.BezierCurve(); curve.v1 = v1.ToSlimDX() / 127; curve.v2 = v2.ToSlimDX() / 127; return(curve.Evaluate(s)); }
public void PropertyValues() { var v = new bvec2(true, false); var vals = v.Values; Assert.AreEqual(true, vals[0]); Assert.AreEqual(false, vals[1]); Assert.That(vals.SequenceEqual(v.ToArray())); }
public void SerializationJson() { var v0 = new bvec2(true, false); var s0 = JsonConvert.SerializeObject(v0); var v1 = JsonConvert.DeserializeObject <bvec2>(s0); var s1 = JsonConvert.SerializeObject(v1); Assert.AreEqual(v0, v1); Assert.AreEqual(s0, s1); }
public void Operators() { var v1 = new bvec2(false, true); var v2 = new bvec2(false, true); var v3 = new bvec2(true, false); Assert.That(v1 == new bvec2(v1)); Assert.That(v2 == new bvec2(v2)); Assert.That(v3 == new bvec2(v3)); Assert.That(v1 == v2); Assert.That(v1 != v3); Assert.That(v2 != v3); }
public void InlineRGBA() { { var v0 = new bvec2(false, false); var v1 = true; var v2 = v0.r; v0.r = v1; var v3 = v0.r; Assert.AreEqual(v1, v3); Assert.AreEqual(true, v0.x); Assert.AreEqual(false, v0.y); Assert.AreEqual(false, v2); } { var v0 = new bvec2(false, true); var v1 = false; var v2 = v0.g; v0.g = v1; var v3 = v0.g; Assert.AreEqual(v1, v3); Assert.AreEqual(false, v0.x); Assert.AreEqual(false, v0.y); Assert.AreEqual(true, v2); } { var v0 = new bvec2(true, true); var v1 = new bvec2(true, false); var v2 = v0.rg; v0.rg = v1; var v3 = v0.rg; Assert.AreEqual(v1, v3); Assert.AreEqual(true, v0.x); Assert.AreEqual(false, v0.y); Assert.AreEqual(true, v2.x); Assert.AreEqual(true, v2.y); } }
/// <summary> /// </summary> /// <param name="uniformName"></param> /// <param name="values"></param> /// <returns></returns> public int SetUniform(string uniformName, bvec2[] values) { int location = GetUniformLocation(uniformName); if (location >= 0) { if (glUniform2iv == null) { glUniform2iv = OpenGL.GetDelegateFor<OpenGL.glUniform2iv>(); } int count = values.Length; var value = new int[count * 2]; 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; } glUniform2iv(location, count, value); } return location; }
public void InlineXYZW() { { var v0 = new bvec2(true, true); var v1 = new bvec2(true, true); var v2 = v0.xy; v0.xy = v1; var v3 = v0.xy; Assert.AreEqual(v1, v3); Assert.AreEqual(true, v0.x); Assert.AreEqual(true, v0.y); Assert.AreEqual(true, v2.x); Assert.AreEqual(true, v2.y); } }
public void Indexer() { var v = new bvec2(false, true); Assert.AreEqual(false, v[0]); Assert.AreEqual(true, v[1]); 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[2]; }); Assert.Throws <ArgumentOutOfRangeException>(() => { v[2] = 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]); }
public void StringInterop() { var v = new bvec2(true, false); var s0 = v.ToString(); var s1 = v.ToString("#"); var v0 = bvec2.Parse(s0); var v1 = bvec2.Parse(s1, "#"); Assert.AreEqual(v, v0); Assert.AreEqual(v, v1); var b0 = bvec2.TryParse(s0, out v0); var b1 = bvec2.TryParse(s1, "#", out v1); Assert.That(b0); Assert.That(b1); Assert.AreEqual(v, v0); Assert.AreEqual(v, v1); b0 = bvec2.TryParse(null, out v0); Assert.False(b0); b0 = bvec2.TryParse("", out v0); Assert.False(b0); b0 = bvec2.TryParse(s0 + ", 0", out v0); Assert.False(b0); Assert.Throws <NullReferenceException>(() => { bvec2.Parse(null); }); Assert.Throws <FormatException>(() => { bvec2.Parse(""); }); Assert.Throws <FormatException>(() => { bvec2.Parse(s0 + ", 0"); }); var s2 = v.ToString(";", CultureInfo.InvariantCulture); Assert.That(s2.Length > 0); }
/// <summary> /// Returns the component-wise compare of x != y. /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <returns></returns> public static bvec2 notEqual(bvec2 x, bvec2 y) { return(null); }
public bvec4(bvec2 xy, bool z, bool w) { throw _invalidAccess; }
protected bvec2 not(bvec2 x, bvec2 y) { throw new NotImplementedException(); }
public bvec4(bool x, bvec2 yz, bool w) { throw _invalidAccess; }
public bvec4(bvec2 xy, bvec2 zw) { throw _invalidAccess; }
public static bool any(bvec2 x) { return x.x || x.y; }
public bvec3(bool x, bvec2 yz) { throw _invalidAccess; }
protected extern vec2 mix(vec2 x, vec2 y, bvec2 a);
protected extern bvec2 notEqual(bvec2 x, bvec2 y);
public bvec3(bvec2 xy, bool z) { throw _invalidAccess; }
public bvec3(bool x, bvec2 yz) { throw _invalidAccess; }
public bvec4(bvec2 xy, bvec2 zw) { throw _invalidAccess; }
public bvec4(bool x, bool y, bvec2 zw) { throw _invalidAccess; }
public bvec4(bool x, bvec2 yz, bool w) { throw _invalidAccess; }
/// <summary> /// Returns true only if all components of x are true. /// </summary> /// <param name="x"></param> /// <returns></returns> public static bool all(bvec2 x) { return(false); }
protected extern bvec2 any(bvec2 x, bvec2 y);
/// <summary> /// Returns the component-wise logical complement of x. /// </summary> /// <param name="x"></param> /// <returns></returns> public static bvec2 not(bvec2 x) { return(null); }
public static bvec2 notEqual(bvec2 x, bvec2 y) { bvec2 r; r.x = x.x != y.x; r.y = x.y != y.y; return r; }
public bvec3(bvec2 xy, bool z) { throw _invalidAccess; }
public static bool all(bvec2 a) { return(a.x && a.y); }
public bvec4(bvec2 xy, bool z, bool w) { throw _invalidAccess; }
/// <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 dvec2 Lerp(dvec2 x, dvec2 y, bvec2 a) { throw _invalidAccess; }
public bvec4(bool x, bool y, bvec2 zw) { throw _invalidAccess; }
protected vec2 mix(vec2 x, vec2 y, bvec2 a) { throw new NotImplementedException(); }
public static bool all(bvec2 x) { return x.x && x.y; }
public static bvec2 not(bvec2 x) { bvec2 r; r.x = !x.x; r.y = !x.y; return r; }
protected extern bvec2 equal(bvec2 x, bvec2 y);
public void XYZW() { { var ov = new bvec2(false, false); var v = ov.swizzle.xx; Assert.AreEqual(false, v.x); Assert.AreEqual(false, v.y); } { var ov = new bvec2(false, false); var v = ov.swizzle.xxx; Assert.AreEqual(false, v.x); Assert.AreEqual(false, v.y); Assert.AreEqual(false, v.z); } { var ov = new bvec2(true, false); var v = ov.swizzle.xxxx; Assert.AreEqual(true, v.x); Assert.AreEqual(true, v.y); Assert.AreEqual(true, v.z); Assert.AreEqual(true, v.w); } { var ov = new bvec2(false, true); var v = ov.swizzle.xxxy; Assert.AreEqual(false, v.x); Assert.AreEqual(false, v.y); Assert.AreEqual(false, v.z); Assert.AreEqual(true, v.w); } { var ov = new bvec2(true, false); var v = ov.swizzle.xxy; Assert.AreEqual(true, v.x); Assert.AreEqual(true, v.y); Assert.AreEqual(false, v.z); } { var ov = new bvec2(true, false); var v = ov.swizzle.xxyx; Assert.AreEqual(true, v.x); Assert.AreEqual(true, v.y); Assert.AreEqual(false, v.z); Assert.AreEqual(true, v.w); } { var ov = new bvec2(false, true); var v = ov.swizzle.xxyy; Assert.AreEqual(false, v.x); Assert.AreEqual(false, v.y); Assert.AreEqual(true, v.z); Assert.AreEqual(true, v.w); } { var ov = new bvec2(false, true); var v = ov.swizzle.xy; Assert.AreEqual(false, v.x); Assert.AreEqual(true, v.y); } { var ov = new bvec2(true, true); var v = ov.swizzle.xyx; Assert.AreEqual(true, v.x); Assert.AreEqual(true, v.y); Assert.AreEqual(true, v.z); } { var ov = new bvec2(false, false); var v = ov.swizzle.xyxx; Assert.AreEqual(false, v.x); Assert.AreEqual(false, v.y); Assert.AreEqual(false, v.z); Assert.AreEqual(false, v.w); } { var ov = new bvec2(false, true); var v = ov.swizzle.xyxy; Assert.AreEqual(false, v.x); Assert.AreEqual(true, v.y); Assert.AreEqual(false, v.z); Assert.AreEqual(true, v.w); } { var ov = new bvec2(true, false); var v = ov.swizzle.xyy; Assert.AreEqual(true, v.x); Assert.AreEqual(false, v.y); Assert.AreEqual(false, v.z); } { var ov = new bvec2(true, true); var v = ov.swizzle.xyyx; Assert.AreEqual(true, v.x); Assert.AreEqual(true, v.y); Assert.AreEqual(true, v.z); Assert.AreEqual(true, v.w); } { var ov = new bvec2(true, false); var v = ov.swizzle.xyyy; Assert.AreEqual(true, v.x); Assert.AreEqual(false, v.y); Assert.AreEqual(false, v.z); Assert.AreEqual(false, v.w); } { var ov = new bvec2(false, false); var v = ov.swizzle.yx; Assert.AreEqual(false, v.x); Assert.AreEqual(false, v.y); } { var ov = new bvec2(true, true); var v = ov.swizzle.yxx; Assert.AreEqual(true, v.x); Assert.AreEqual(true, v.y); Assert.AreEqual(true, v.z); } { var ov = new bvec2(true, false); var v = ov.swizzle.yxxx; Assert.AreEqual(false, v.x); Assert.AreEqual(true, v.y); Assert.AreEqual(true, v.z); Assert.AreEqual(true, v.w); } { var ov = new bvec2(true, false); var v = ov.swizzle.yxxy; Assert.AreEqual(false, v.x); Assert.AreEqual(true, v.y); Assert.AreEqual(true, v.z); Assert.AreEqual(false, v.w); } { var ov = new bvec2(false, false); var v = ov.swizzle.yxy; Assert.AreEqual(false, v.x); Assert.AreEqual(false, v.y); Assert.AreEqual(false, v.z); } { var ov = new bvec2(true, true); var v = ov.swizzle.yxyx; Assert.AreEqual(true, v.x); Assert.AreEqual(true, v.y); Assert.AreEqual(true, v.z); Assert.AreEqual(true, v.w); } { var ov = new bvec2(true, false); var v = ov.swizzle.yxyy; Assert.AreEqual(false, v.x); Assert.AreEqual(true, v.y); Assert.AreEqual(false, v.z); Assert.AreEqual(false, v.w); } { var ov = new bvec2(true, false); var v = ov.swizzle.yy; Assert.AreEqual(false, v.x); Assert.AreEqual(false, v.y); } { var ov = new bvec2(false, false); var v = ov.swizzle.yyx; Assert.AreEqual(false, v.x); Assert.AreEqual(false, v.y); Assert.AreEqual(false, v.z); } { var ov = new bvec2(true, false); var v = ov.swizzle.yyxx; Assert.AreEqual(false, v.x); Assert.AreEqual(false, v.y); Assert.AreEqual(true, v.z); Assert.AreEqual(true, v.w); } { var ov = new bvec2(false, false); var v = ov.swizzle.yyxy; Assert.AreEqual(false, v.x); Assert.AreEqual(false, v.y); Assert.AreEqual(false, v.z); Assert.AreEqual(false, v.w); } { var ov = new bvec2(true, true); var v = ov.swizzle.yyy; Assert.AreEqual(true, v.x); Assert.AreEqual(true, v.y); Assert.AreEqual(true, v.z); } { var ov = new bvec2(false, false); var v = ov.swizzle.yyyx; Assert.AreEqual(false, v.x); Assert.AreEqual(false, v.y); Assert.AreEqual(false, v.z); Assert.AreEqual(false, v.w); } { var ov = new bvec2(true, false); var v = ov.swizzle.yyyy; Assert.AreEqual(false, v.x); Assert.AreEqual(false, v.y); Assert.AreEqual(false, v.z); Assert.AreEqual(false, v.w); } }
protected extern bvec2 all(bvec2 x, bvec2 y);
public void RGBA() { { var ov = new bvec2(true, false); var v = ov.swizzle.rr; Assert.AreEqual(true, v.x); Assert.AreEqual(true, v.y); } { var ov = new bvec2(true, false); var v = ov.swizzle.rrr; Assert.AreEqual(true, v.x); Assert.AreEqual(true, v.y); Assert.AreEqual(true, v.z); } { var ov = new bvec2(false, true); var v = ov.swizzle.rrrr; Assert.AreEqual(false, v.x); Assert.AreEqual(false, v.y); Assert.AreEqual(false, v.z); Assert.AreEqual(false, v.w); } { var ov = new bvec2(false, false); var v = ov.swizzle.rrrg; Assert.AreEqual(false, v.x); Assert.AreEqual(false, v.y); Assert.AreEqual(false, v.z); Assert.AreEqual(false, v.w); } { var ov = new bvec2(false, true); var v = ov.swizzle.rrg; Assert.AreEqual(false, v.x); Assert.AreEqual(false, v.y); Assert.AreEqual(true, v.z); } { var ov = new bvec2(true, true); var v = ov.swizzle.rrgr; Assert.AreEqual(true, v.x); Assert.AreEqual(true, v.y); Assert.AreEqual(true, v.z); Assert.AreEqual(true, v.w); } { var ov = new bvec2(false, false); var v = ov.swizzle.rrgg; Assert.AreEqual(false, v.x); Assert.AreEqual(false, v.y); Assert.AreEqual(false, v.z); Assert.AreEqual(false, v.w); } { var ov = new bvec2(false, false); var v = ov.swizzle.rg; Assert.AreEqual(false, v.x); Assert.AreEqual(false, v.y); } { var ov = new bvec2(false, false); var v = ov.swizzle.rgr; Assert.AreEqual(false, v.x); Assert.AreEqual(false, v.y); Assert.AreEqual(false, v.z); } { var ov = new bvec2(false, true); var v = ov.swizzle.rgrr; Assert.AreEqual(false, v.x); Assert.AreEqual(true, v.y); Assert.AreEqual(false, v.z); Assert.AreEqual(false, v.w); } { var ov = new bvec2(true, true); var v = ov.swizzle.rgrg; Assert.AreEqual(true, v.x); Assert.AreEqual(true, v.y); Assert.AreEqual(true, v.z); Assert.AreEqual(true, v.w); } { var ov = new bvec2(true, true); var v = ov.swizzle.rgg; Assert.AreEqual(true, v.x); Assert.AreEqual(true, v.y); Assert.AreEqual(true, v.z); } { var ov = new bvec2(false, true); var v = ov.swizzle.rggr; Assert.AreEqual(false, v.x); Assert.AreEqual(true, v.y); Assert.AreEqual(true, v.z); Assert.AreEqual(false, v.w); } { var ov = new bvec2(true, false); var v = ov.swizzle.rggg; Assert.AreEqual(true, v.x); Assert.AreEqual(false, v.y); Assert.AreEqual(false, v.z); Assert.AreEqual(false, v.w); } { var ov = new bvec2(true, false); var v = ov.swizzle.gr; Assert.AreEqual(false, v.x); Assert.AreEqual(true, v.y); } { var ov = new bvec2(false, true); var v = ov.swizzle.grr; Assert.AreEqual(true, v.x); Assert.AreEqual(false, v.y); Assert.AreEqual(false, v.z); } { var ov = new bvec2(true, false); var v = ov.swizzle.grrr; Assert.AreEqual(false, v.x); Assert.AreEqual(true, v.y); Assert.AreEqual(true, v.z); Assert.AreEqual(true, v.w); } { var ov = new bvec2(true, false); var v = ov.swizzle.grrg; Assert.AreEqual(false, v.x); Assert.AreEqual(true, v.y); Assert.AreEqual(true, v.z); Assert.AreEqual(false, v.w); } { var ov = new bvec2(false, false); var v = ov.swizzle.grg; Assert.AreEqual(false, v.x); Assert.AreEqual(false, v.y); Assert.AreEqual(false, v.z); } { var ov = new bvec2(false, false); var v = ov.swizzle.grgr; Assert.AreEqual(false, v.x); Assert.AreEqual(false, v.y); Assert.AreEqual(false, v.z); Assert.AreEqual(false, v.w); } { var ov = new bvec2(false, true); var v = ov.swizzle.grgg; Assert.AreEqual(true, v.x); Assert.AreEqual(false, v.y); Assert.AreEqual(true, v.z); Assert.AreEqual(true, v.w); } { var ov = new bvec2(false, false); var v = ov.swizzle.gg; Assert.AreEqual(false, v.x); Assert.AreEqual(false, v.y); } { var ov = new bvec2(false, true); var v = ov.swizzle.ggr; Assert.AreEqual(true, v.x); Assert.AreEqual(true, v.y); Assert.AreEqual(false, v.z); } { var ov = new bvec2(false, false); var v = ov.swizzle.ggrr; Assert.AreEqual(false, v.x); Assert.AreEqual(false, v.y); Assert.AreEqual(false, v.z); Assert.AreEqual(false, v.w); } { var ov = new bvec2(false, false); var v = ov.swizzle.ggrg; Assert.AreEqual(false, v.x); Assert.AreEqual(false, v.y); Assert.AreEqual(false, v.z); Assert.AreEqual(false, v.w); } { var ov = new bvec2(true, false); var v = ov.swizzle.ggg; Assert.AreEqual(false, v.x); Assert.AreEqual(false, v.y); Assert.AreEqual(false, v.z); } { var ov = new bvec2(true, true); var v = ov.swizzle.gggr; Assert.AreEqual(true, v.x); Assert.AreEqual(true, v.y); Assert.AreEqual(true, v.z); Assert.AreEqual(true, v.w); } { var ov = new bvec2(true, true); var v = ov.swizzle.gggg; Assert.AreEqual(true, v.x); Assert.AreEqual(true, v.y); Assert.AreEqual(true, v.z); Assert.AreEqual(true, v.w); } }
protected extern bvec2 not(bvec2 x, bvec2 y);
public static bvec2 equal(bvec2 x, bvec2 y) { bvec2 r; r.x = x.x == y.x; r.y = x.y == y.y; return r; }