예제 #1
0
        public void TestLayoutAssignmentAndReset()
        {
            var pool = new GeometryPool {
                Layout = new VertexLayout {
                    texcoord0 = new TexcoordInfo {
                        size = 2
                    },
                    texcoord1 = new TexcoordInfo {
                        size = 3
                    },
                    texcoord2 = new TexcoordInfo {
                        size = 4
                    },
                }
            };

            Assert.IsNotNull(pool.m_Texcoord0.v2);
            Assert.IsNotNull(pool.m_Texcoord1.v3);
            Assert.IsNotNull(pool.m_Texcoord2.v4);

            int N = 30;

            pool.m_Texcoord0.v2.AddRange(MathTestUtils.RandomVector2List(N));
            pool.m_Texcoord1.v3.AddRange(MathTestUtils.RandomVector3List(N));
            pool.m_Texcoord2.v4.AddRange(MathTestUtils.RandomVector4List(N));
            pool.Reset();
            Assert.AreEqual(0, pool.m_Texcoord0.v2.Count);
            Assert.AreEqual(0, pool.m_Texcoord1.v3.Count);
            Assert.AreEqual(0, pool.m_Texcoord2.v4.Count);
        }
예제 #2
0
        public void TestListRoundTrip()
        {
            // Test a list going into and out of the stream.
            List <Vector3> lst = MathTestUtils.RandomVector3List(20);

            MemoryStream stream = new MemoryStream();

            using (var writer = new SketchBinaryWriter(stream)) {
                writer.WriteLengthPrefixed(lst);
                writer.BaseStream = null;
            }

            stream.Position = 0;
            List <Vector3> lst2 = new List <Vector3>();

            using (var reader = new SketchBinaryReader(stream)) {
                Assert.IsTrue(reader.ReadIntoExact(lst2, lst.Count));
            }
            Assert.AreEqual(lst, lst2);
        }
예제 #3
0
        private static GeometryPool RandomGeometryPool()
        {
            int vertexCount = 20;
            int indexCount  = 60;
            var pool        = new GeometryPool();

            pool.Layout = new VertexLayout {
                texcoord0 = new TexcoordInfo {
                    size = 2, semantic = Semantic.XyIsUv
                },
                bUseNormals  = true,
                bUseColors   = true,
                bUseTangents = true
            };
            pool.m_Vertices     = MathTestUtils.RandomVector3List(vertexCount);
            pool.m_Tris         = MathTestUtils.RandomIntList(indexCount, 0, vertexCount);
            pool.m_Normals      = MathTestUtils.RandomVector3List(vertexCount);
            pool.m_Colors       = MathTestUtils.RandomColor32List(vertexCount);
            pool.m_Tangents     = MathTestUtils.RandomVector4List(vertexCount);
            pool.m_Texcoord0.v2 = MathTestUtils.RandomVector2List(vertexCount);
            return(pool);
        }