public int FillSplineVU2(Spliner spliner, Color colorStart, Color colorEnd, ref NativeMeshInfo meshInfo)
        {
            Assert.IsTrue(meshInfo.Vertices.IsCreated);
            Assert.IsTrue(meshInfo.UVs.IsCreated);
            Assert.IsTrue(meshInfo.Colors.IsCreated);

            int line = spliner.GetLineCount();

            Assert.AreEqual(meshInfo.Vertices.Length, line * 2);
            Assert.AreEqual(meshInfo.UVs.Length, line * 2);
            Assert.AreEqual(meshInfo.Colors.Length, line * 2);

            float addPerc = 1f / line;
            float acc     = 0;

            for (int i = 0; i < line; ++i)
            {
                (Vector3 p1, Vector3 up) = spliner.Interpolate(acc);
                Vector3 width = (up * 0.5f);
                Vector3 p0    = p1 - width;
                Vector3 p2    = p1 + width;

                // p0                    p2
                // |---------------------|
                int index = (i * 2);
                meshInfo.Vertices[index + 0] = p0;
                meshInfo.Vertices[index + 1] = p2;

                meshInfo.UVs[index + 0] = new Vector2(0, acc);
                meshInfo.UVs[index + 1] = new Vector2(1, acc);

                acc += addPerc;
            }
            return(line);
        }
Exemple #2
0
        public void FillTrackI2(ref NativeMeshInfo meshInfo)
        {
            Assert.IsTrue(meshInfo.Indices.IsCreated);

            int indexLoopCount = meshInfo.Indices.Length / 6;

            for (int i = 0; i < indexLoopCount; ++i)
            {
                int ci = i * 2;
                int ni = ci + 2;

                int index = i * 6;

                // c0                    c1
                // 2---------------------|
                // |          |          |
                // 0---------------------1
                // n0                    n1
                meshInfo.Indices[index + 0] = ni + 0;
                meshInfo.Indices[index + 1] = ni + 1;
                meshInfo.Indices[index + 2] = ci + 0;

                // c0                    c1
                // 5---------------------4
                // |          |          |
                // |---------------------3
                // n0                    n1
                meshInfo.Indices[index + 3] = ni + 1;
                meshInfo.Indices[index + 4] = ci + 1;
                meshInfo.Indices[index + 5] = ci + 0;
            }
        }
Exemple #3
0
        public void FillRect(int width, int height, ref NativeMeshInfo info)
        {
            Assert.IsTrue(info.Vertices.IsCreated);
            Assert.IsTrue(info.UVs.IsCreated);
            Assert.IsTrue(info.Indices.IsCreated);

            Assert.AreEqual(info.Vertices.Length, 4);
            Assert.AreEqual(info.UVs.Length, 4);
            Assert.AreEqual(info.Indices.Length, 6);

            float halfWidth  = width / 2;
            float halfHeight = height / 2;

            info.Vertices[0] = new Vector3(-halfWidth, 0, halfHeight);
            info.Vertices[1] = new Vector3(halfWidth, 0, halfHeight);
            info.Vertices[2] = new Vector3(-halfWidth, 0, -halfHeight);
            info.Vertices[3] = new Vector3(halfWidth, 0, -halfHeight);

            info.UVs[0] = new Vector2(0, 0);
            info.UVs[1] = new Vector2(1, 0);
            info.UVs[2] = new Vector2(0, 1);
            info.UVs[3] = new Vector2(1, 1);

            info.Indices[0] = 0;
            info.Indices[1] = 1;
            info.Indices[2] = 3;

            info.Indices[3] = 3;
            info.Indices[4] = 2;
            info.Indices[5] = 0;
        }
Exemple #4
0
        public void FillTrackCI3(Color color, ref NativeMeshInfo meshInfo)
        {
            Assert.IsTrue(meshInfo.Colors.IsCreated);
            Assert.IsTrue(meshInfo.Indices.IsCreated);
            for (int i = 0; i < meshInfo.Colors.Length; ++i)
            {
                meshInfo.Colors[i] = color;
            }

            int indexLoopCount = meshInfo.Indices.Length / 12;

            for (int i = 0; i < indexLoopCount; ++i)
            {
                int ci = i * 3;
                int ni = ci + 3;

                int index = i * 12;

                // c0         c1         c2
                // 2---------------------|
                // |          |          |
                // 0----------1----------|
                // n0         n1         n2
                meshInfo.Indices[index + 0] = ni + 0;
                meshInfo.Indices[index + 1] = ni + 1;
                meshInfo.Indices[index + 2] = ci + 0;

                // c0         c1         c2
                // 5----------4----------|
                // |          |          |
                // |----------3----------|
                // n0         n1         n2
                meshInfo.Indices[index + 3] = ni + 1;
                meshInfo.Indices[index + 4] = ci + 1;
                meshInfo.Indices[index + 5] = ci + 0;

                // c0         c1         c2
                // |----------8----------|
                // |          |          |
                // |----------6----------7
                // n0         n1         n2
                meshInfo.Indices[index + 6] = ni + 1;
                meshInfo.Indices[index + 7] = ni + 2;
                meshInfo.Indices[index + 8] = ci + 1;

                // c0         c1         c2
                // |----------11---------10
                // |          |          |
                // |----------|----------9
                // n0         n1         n2
                meshInfo.Indices[index + 9]  = ni + 2;
                meshInfo.Indices[index + 10] = ci + 2;
                meshInfo.Indices[index + 11] = ci + 1;
            }
        }
        public void FillRing(float innerRadius, float outerRadius, int angle, ref NativeMeshInfo info)
        {
            Assert.IsTrue(info.Vertices.IsCreated);
            Assert.IsTrue(info.UVs.IsCreated);
            Assert.IsTrue(info.Indices.IsCreated);

            const int detailAngle = 10;
            var initialAngle = -angle / 2;
            var seg = (angle / detailAngle);
            int numVerts = 2 + (2 * seg);
            int numIndices = 6 * seg;

            Assert.AreEqual(info.Vertices.Length, numVerts);
            Assert.AreEqual(info.UVs.Length, numVerts);
            Assert.AreEqual(info.Indices.Length, numIndices);

            float totalRadius = innerRadius + outerRadius;

            for (int i = 0; i <= seg; ++i)
            {
                var v = Quaternion.AngleAxis(initialAngle + (detailAngle * i), Vector3.up) * Vector3.forward;
                int index = i * 2;
                info.Vertices[index + 0] = v * innerRadius;
                info.Vertices[index + 1] = v * totalRadius;

                float normedHorizontal = (info.Vertices[index].x + 1.0f) * 0.5f;
                float normedVertical = (info.Vertices[index].x + 1.0f) * 0.5f;
                info.UVs[index + 0] = new Vector2(normedHorizontal, normedVertical);
                info.UVs[index + 1] = new Vector2(normedHorizontal, normedVertical);
            }

            for (int i = 0; i < seg; ++i)
            {
                int index = i * 6;
                int vi = i * 2;
                info.Indices[index + 0] = vi + 0;
                info.Indices[index + 1] = vi + 1;
                info.Indices[index + 2] = vi + 2;

                info.Indices[index + 3] = vi + 2;
                info.Indices[index + 4] = vi + 1;
                info.Indices[index + 5] = vi + 3;
            }
        }
        public void FillCircle(int angle, ref NativeMeshInfo info)
        {
            Assert.IsTrue(info.Vertices.IsCreated);
            Assert.IsTrue(info.UVs.IsCreated);
            Assert.IsTrue(info.Indices.IsCreated);

            var initialAngle = -angle / 2;
            var seg          = (angle / 10);
            int numVerts     = seg + 2;
            int numIndices   = 3 * seg;

            Assert.AreEqual(info.Vertices.Length, numVerts);
            Assert.AreEqual(info.UVs.Length, numVerts);
            Assert.AreEqual(info.Indices.Length, numIndices);

            info.Vertices[0] = Vector3.zero;
            info.UVs[0]      = new Vector2(0.5f, 0.5f);

            float detailAngle = 10;

            for (int i = 1; i < numVerts; ++i)
            {
                info.Vertices[i] = Quaternion.AngleAxis(initialAngle + (detailAngle * (i - 1)), Vector3.up) * Vector3.forward;

                float normedHorizontal = (info.Vertices[i].x + 1.0f) * 0.5f;
                float normedVertical   = (info.Vertices[i].x + 1.0f) * 0.5f;
                info.UVs[i] = new Vector2(normedHorizontal, normedVertical);
            }

            for (int i = 0; i < seg; ++i)
            {
                int index = i * 3;
                info.Indices[index + 0] = 0;
                info.Indices[index + 1] = i + 1;
                info.Indices[index + 2] = i + 2;
            }
        }
Exemple #7
0
        public int FillTrackVU3(NF.Collections.Generic.LinkedList <LineInfo> lines, int maxLineCount, Color colorStart, Color colorEnd, ref NativeMeshInfo meshInfo)
        {
            Assert.IsTrue(meshInfo.Vertices.IsCreated);
            Assert.IsTrue(meshInfo.UVs.IsCreated);
            Assert.IsTrue(meshInfo.Colors.IsCreated);

            int line = Math.Min(lines.Count, maxLineCount);

            if (line < 2)
            {
                return(line);
            }
            Assert.IsTrue(meshInfo.Vertices.Length >= line * 3);
            Assert.IsTrue(meshInfo.UVs.Length >= line * 3);
            Assert.IsTrue(meshInfo.Colors.Length >= line * 3);

            float addPerc     = 1f / line;
            float acc         = 0;
            int   recordIndex = 0;

            for (var node = lines.GetHeadNode(); node != null; node = node.Next)
            {
                if (recordIndex >= line)
                {
                    break;
                }
                var     record = node.Item;
                Vector3 p0     = record.BasePosition;
                Vector3 p1     = record.Position;
                Vector3 p2     = record.TipPosition;

                // p0         p1         p2
                // |----------|----------|
                int index = (recordIndex * 3);
                meshInfo.Vertices[index + 0] = p0;
                meshInfo.Vertices[index + 1] = p1;
                meshInfo.Vertices[index + 2] = p2;

                meshInfo.UVs[index + 0] = new Vector2(0, acc);
                meshInfo.UVs[index + 1] = new Vector2(0.5f, acc);
                meshInfo.UVs[index + 2] = new Vector2(1, acc);

                Color c = Color.Lerp(colorStart, colorEnd, acc);
                meshInfo.Colors[index + 0] = c;
                meshInfo.Colors[index + 1] = c;
                meshInfo.Colors[index + 2] = c;

                acc += addPerc;
                recordIndex++;
            }
            return(line);
        }
Exemple #8
0
        public int FillTrackVUCI3(NF.Collections.Generic.LinkedList <LineInfo> lines, int maxLineCount, Color colorStart, Color colorEnd, ref NativeMeshInfo meshInfo)
        {
            Assert.IsTrue(meshInfo.Vertices.IsCreated);
            Assert.IsTrue(meshInfo.UVs.IsCreated);
            Assert.IsTrue(meshInfo.Colors.IsCreated);
            Assert.IsTrue(meshInfo.Indices.IsCreated);

            int line = Math.Min(lines.Count, maxLineCount);

            if (line < 2)
            {
                return(line);
            }
            Assert.AreEqual(meshInfo.Vertices.Length, line * 3);
            Assert.AreEqual(meshInfo.UVs.Length, line * 3);
            Assert.AreEqual(meshInfo.Colors.Length, line * 3);
            Assert.AreEqual(meshInfo.Indices.Length, (line - 1) * 12);

            float addPerc     = 1f / line;
            float acc         = 0;
            int   recordIndex = 0;

            for (var node = lines.GetHeadNode(); node != null; node = node.Next)
            {
                if (recordIndex >= line)
                {
                    break;
                }
                var     record = node.Item;
                Vector3 p0     = record.BasePosition;
                Vector3 p1     = record.Position;
                Vector3 p2     = record.TipPosition;

                // p0         p1         p2
                // |----------|----------|
                int index = (recordIndex * 3);
                meshInfo.Vertices[index + 0] = p0;
                meshInfo.Vertices[index + 1] = p1;
                meshInfo.Vertices[index + 2] = p2;

                meshInfo.UVs[index + 0] = new Vector2(0, acc);
                meshInfo.UVs[index + 1] = new Vector2(0.5f, acc);
                meshInfo.UVs[index + 2] = new Vector2(1, acc);

                Color c = Color.Lerp(colorStart, colorEnd, acc);
                meshInfo.Colors[index + 0] = c;
                meshInfo.Colors[index + 1] = c;
                meshInfo.Colors[index + 2] = c;

                acc += addPerc;
                recordIndex++;
            }

            for (int i = 0; i < line - 1; ++i)
            {
                int ci = i * 3;
                int ni = ci + 3;

                int index = i * 12;

                // c0         c1         c2
                // 2---------------------|
                // |          |          |
                // 0----------1----------|
                // n0         n1         n2
                meshInfo.Indices[index + 0] = ni + 0;
                meshInfo.Indices[index + 1] = ni + 1;
                meshInfo.Indices[index + 2] = ci + 0;

                // c0         c1         c2
                // 5----------4----------|
                // |          |          |
                // |----------3----------|
                // n0         n1         n2
                meshInfo.Indices[index + 3] = ni + 1;
                meshInfo.Indices[index + 4] = ci + 1;
                meshInfo.Indices[index + 5] = ci + 0;

                // c0         c1         c2
                // |----------8----------|
                // |          |          |
                // |----------6----------7
                // n0         n1         n2
                meshInfo.Indices[index + 6] = ni + 1;
                meshInfo.Indices[index + 7] = ni + 2;
                meshInfo.Indices[index + 8] = ci + 1;

                // c0         c1         c2
                // |----------11---------10
                // |          |          |
                // |----------|----------9
                // n0         n1         n2
                meshInfo.Indices[index + 9]  = ni + 2;
                meshInfo.Indices[index + 10] = ci + 2;
                meshInfo.Indices[index + 11] = ci + 1;
            }
            return(line);
        }
        public int FillSplineVUCI3(Spliner spliner, Color colorStart, Color colorEnd, ref NativeMeshInfo meshInfo)
        {
            Assert.IsTrue(meshInfo.Vertices.IsCreated);
            Assert.IsTrue(meshInfo.UVs.IsCreated);
            Assert.IsTrue(meshInfo.Colors.IsCreated);
            Assert.IsTrue(meshInfo.Indices.IsCreated);

            int line = spliner.GetLineCount();

            Assert.AreEqual(meshInfo.Vertices.Length, line * 3);
            Assert.AreEqual(meshInfo.UVs.Length, line * 3);
            Assert.AreEqual(meshInfo.Colors.Length, line * 3);
            Assert.AreEqual(meshInfo.Indices.Length, (line - 1) * 12);

            float addPerc = 1f / line;
            float acc     = 0;

            for (int i = 0; i < line; ++i)
            {
                (Vector3 p1, Vector3 up) = spliner.Interpolate(acc);
                Vector3 width = (up * 0.5f);
                Vector3 p0    = p1 - width;
                Vector3 p2    = p1 + width;

                // p0         p1         p2
                // |----------|----------|
                int index = (i * 3);
                meshInfo.Vertices[index + 0] = p0;
                meshInfo.Vertices[index + 1] = p1;
                meshInfo.Vertices[index + 2] = p2;

                meshInfo.UVs[index + 0] = new Vector2(0, acc);
                meshInfo.UVs[index + 1] = new Vector2(0.5f, acc);
                meshInfo.UVs[index + 2] = new Vector2(1, acc);

                Color c = Color.Lerp(colorStart, colorEnd, acc);
                meshInfo.Colors[index + 0] = c;
                meshInfo.Colors[index + 1] = c;
                meshInfo.Colors[index + 2] = c;

                acc += addPerc;
            }

            for (int i = 0; i < line - 1; ++i)
            {
                int ci = i * 3;
                int ni = ci + 3;

                int index = i * 12;

                // c0         c1         c2
                // 2---------------------|
                // |          |          |
                // 0----------1----------|
                // n0         n1         n2
                meshInfo.Indices[index + 0] = ni + 0;
                meshInfo.Indices[index + 1] = ni + 1;
                meshInfo.Indices[index + 2] = ci + 0;

                // c0         c1         c2
                // 5----------4----------|
                // |          |          |
                // |----------3----------|
                // n0         n1         n2
                meshInfo.Indices[index + 3] = ni + 1;
                meshInfo.Indices[index + 4] = ci + 1;
                meshInfo.Indices[index + 5] = ci + 0;

                // c0         c1         c2
                // |----------8----------|
                // |          |          |
                // |----------6----------7
                // n0         n1         n2
                meshInfo.Indices[index + 6] = ni + 1;
                meshInfo.Indices[index + 7] = ni + 2;
                meshInfo.Indices[index + 8] = ci + 1;

                // c0         c1         c2
                // |----------11---------10
                // |          |          |
                // |----------|----------9
                // n0         n1         n2
                meshInfo.Indices[index + 9]  = ni + 2;
                meshInfo.Indices[index + 10] = ci + 2;
                meshInfo.Indices[index + 11] = ci + 1;
            }
            return(line);
        }