public void NormalizedShort2() { Assert.AreEqual(0x0, new NormalizedShort2(Vector2.Zero).PackedValue); Assert.AreEqual(0x7FFF7FFF, new NormalizedShort2(Vector2.One).PackedValue); Assert.AreEqual(0x80018001, new NormalizedShort2(-Vector2.One).PackedValue); Assert.AreEqual(Vector2.One, new NormalizedShort2(Vector2.One).ToVector2()); Assert.AreEqual(Vector2.Zero, new NormalizedShort2(Vector2.Zero).ToVector2()); Assert.AreEqual(-Vector2.One, new NormalizedShort2(-Vector2.One).ToVector2()); Assert.AreEqual(Vector2.One, new NormalizedShort2(Vector2.One * 1234.0f).ToVector2()); Assert.AreEqual(-Vector2.One, new NormalizedShort2(Vector2.One * -1234.0f).ToVector2()); Assert.AreEqual(new Vector4(1, 1, 0, 1), ((IPackedVector) new NormalizedShort2(Vector2.One)).ToVector4()); Assert.AreEqual(new Vector4(0, 0, 0, 1), ((IPackedVector) new NormalizedShort2(Vector2.Zero)).ToVector4()); //Test Ordering float x = 0.35f; float y = -0.2f; Assert.AreEqual(0xE6672CCC, new NormalizedShort2(x, y).PackedValue); x = 0.1f; y = -0.3f; Assert.AreEqual(3650751693, new NormalizedShort2(x, y).PackedValue); var packed = new NormalizedShort2(x, y).PackedValue; var unpacked = new NormalizedShort2() { PackedValue = packed }.ToVector2(); Assert.AreEqual(x, unpacked.X, 0.01f); Assert.AreEqual(y, unpacked.Y, 0.01f); }
public void NormalizedShort2_ToRgb24() { // arrange var short2 = new NormalizedShort2(0.1f, -0.3f); var actual = default(Rgb24); var expected = new Rgb24(141, 90, 0); // act short2.ToRgb24(ref actual); // assert Assert.Equal(expected, actual); }
public void NormalizedShort2_ToArgb32() { // arrange var short2 = new NormalizedShort2(0.1f, -0.3f); var actual = default(Argb32); var expected = new Argb32(141, 90, 0, 255); // act short2.ToArgb32(ref actual); // assert Assert.Equal(expected, actual); }
public void NormalizedShort2_FromScaledVector4() { // arrange Vector4 scaled = new NormalizedShort2(-Vector2.One).ToScaledVector4(); var short2 = default(NormalizedShort2); uint expected = 0x80018001; // act short2.FromScaledVector4(scaled); uint actual = short2.PackedValue; // assert Assert.Equal(expected, actual); }
public void NormalizedShort2_ToScaledVector4() { // arrange var short2 = new NormalizedShort2(-Vector2.One); // act Vector4 actual = short2.ToScaledVector4(); // assert Assert.Equal(0, actual.X); Assert.Equal(0, actual.Y); Assert.Equal(0, actual.Z); Assert.Equal(1, actual.W); }
public void NormalizedShort2() { Assert.Equal((uint)0x0, new NormalizedShort2(Vector2.Zero).PackedValue); Assert.Equal((uint)0x7FFF7FFF, new NormalizedShort2(Vector2.One).PackedValue); Assert.Equal(0x80018001, new NormalizedShort2(-Vector2.One).PackedValue); Assert.True(Equal(Vector2.One, new NormalizedShort2(Vector2.One).ToVector2())); Assert.True(Equal(Vector2.Zero, new NormalizedShort2(Vector2.Zero).ToVector2())); Assert.True(Equal(-Vector2.One, new NormalizedShort2(-Vector2.One).ToVector2())); Assert.True(Equal(Vector2.One, new NormalizedShort2(Vector2.One * 1234.0f).ToVector2())); Assert.True(Equal(-Vector2.One, new NormalizedShort2(Vector2.One * -1234.0f).ToVector2())); Assert.True(Equal(new Vector4(1, 1, 0, 1), (new NormalizedShort2(Vector2.One)).ToVector4())); Assert.True(Equal(new Vector4(0, 0, 0, 1), (new NormalizedShort2(Vector2.Zero)).ToVector4())); // Test Ordering float x = 0.35f; float y = -0.2f; Assert.Equal(0xE6672CCC, new NormalizedShort2(x, y).PackedValue); x = 0.1f; y = -0.3f; Assert.Equal(3650751693, new NormalizedShort2(x, y).PackedValue); byte[] rgb = new byte[3]; byte[] rgba = new byte[4]; byte[] bgr = new byte[3]; byte[] bgra = new byte[4]; NormalizedShort2 n = new NormalizedShort2(); n.PackFromBytes(141, 90, 0, 0); n.ToXyzBytes(rgb, 0); Assert.Equal(rgb, new byte[] { 141, 90, 0 }); // TODO: I don't think this can ever pass since the bytes are already truncated. // Assert.Equal(3650751693, n.PackedValue); new NormalizedShort2(x, y).ToXyzBytes(rgb, 0); Assert.Equal(rgb, new byte[] { 141, 90, 0 }); new NormalizedShort2(x, y).ToXyzwBytes(rgba, 0); Assert.Equal(rgba, new byte[] { 141, 90, 0, 255 }); new NormalizedShort2(x, y).ToZyxBytes(bgr, 0); Assert.Equal(bgr, new byte[] { 0, 90, 141 }); new NormalizedShort2(x, y).ToZyxwBytes(bgra, 0); Assert.Equal(bgra, new byte[] { 0, 90, 141, 255 }); }
public void NormalizedShort2() { Assert.Equal((uint)0x0, new NormalizedShort2(Vector2.Zero).PackedValue); Assert.Equal((uint)0x7FFF7FFF, new NormalizedShort2(Vector2.One).PackedValue); Assert.Equal(0x80018001, new NormalizedShort2(-Vector2.One).PackedValue); Assert.True(Equal(Vector2.One, new NormalizedShort2(Vector2.One).ToVector2())); Assert.True(Equal(Vector2.Zero, new NormalizedShort2(Vector2.Zero).ToVector2())); Assert.True(Equal(-Vector2.One, new NormalizedShort2(-Vector2.One).ToVector2())); Assert.True(Equal(Vector2.One, new NormalizedShort2(Vector2.One * 1234.0f).ToVector2())); Assert.True(Equal(-Vector2.One, new NormalizedShort2(Vector2.One * -1234.0f).ToVector2())); Assert.True(Equal(new Vector4(1, 1, 0, 1), (new NormalizedShort2(Vector2.One)).ToVector4())); Assert.True(Equal(new Vector4(0, 0, 0, 1), (new NormalizedShort2(Vector2.Zero)).ToVector4())); // Test Ordering float x = 0.35f; float y = -0.2f; Assert.Equal(0xE6672CCC, new NormalizedShort2(x, y).PackedValue); x = 0.1f; y = -0.3f; Assert.Equal(3650751693, new NormalizedShort2(x, y).PackedValue); var rgb = default(Rgb24); var rgba = default(Rgba32); var bgr = default(Bgr24); var bgra = default(Bgra32); var n = new NormalizedShort2(); n.PackFromRgba32(new Rgba32(141, 90, 0, 0)); n.ToRgb24(ref rgb); Assert.Equal(rgb, new Rgb24(141, 90, 0)); // TODO: I don't think this can ever pass since the bytes are already truncated. // Assert.Equal(3650751693, n.PackedValue); new NormalizedShort2(x, y).ToRgb24(ref rgb); Assert.Equal(rgb, new Rgb24(141, 90, 0)); new NormalizedShort2(x, y).ToRgba32(ref rgba); Assert.Equal(rgba, new Rgba32(141, 90, 0, 255)); new NormalizedShort2(x, y).ToBgr24(ref bgr); Assert.Equal(bgr, new Bgr24(141, 90, 0)); new NormalizedShort2(x, y).ToBgra32(ref bgra); Assert.Equal(bgra, new Bgra32(141, 90, 0, 255)); }
public void NormalizedShort2_PackFromRgba32_ToRgb24() { // arrange var actual = default(Rgb24); var short2 = new NormalizedShort2(); var rgba = new Rgba32(141, 90, 0, 0); var expected = new Rgb24(141, 90, 0); // act short2.PackFromRgba32(rgba); short2.ToRgb24(ref actual); // assert Assert.Equal(expected, actual); }
public IntVertexPositionTexture(Short4 position, NormalizedShort2 textureCoordinate) { this.Position = position; this.TextureCoordinate = textureCoordinate; }