Пример #1
0
        public static void BuildQuad(this IMeshBuilder meshBuilder, int bottomIndex, int topIndex)
        {
            var bl = bottomIndex;
            var tl = topIndex;
            var tr = topIndex + 1;
            var br = bottomIndex + 1;

            Log.Trace("Building quad: verts=[{0},{1},{2},{3}], indices=[{4},{5},{6},{7}]",
                      meshBuilder.Vertices[bl],
                      meshBuilder.Vertices[tl],
                      meshBuilder.Vertices[tr],
                      meshBuilder.Vertices[br],
                      bl,
                      tl,
                      tr,
                      br);

            meshBuilder.AddTriangle(bl, tl, br);
            meshBuilder.AddTriangle(br, tl, tr);
        }
Пример #2
0
        public Mesh BuildMesh(bool calculateNormals, bool calculateBounds)
        {
            log.Trace("Building mesh for {0} vertices, {1} colors, {2} triangles", this.Vertices.Count, this.Colors.Count, this.indices.Count);

            var mesh = new Mesh();

            mesh.vertices  = this.Vertices.ToArray();
            mesh.triangles = this.indices.ToArray();

            if (this.Normals.Count == this.Vertices.Count)
            {
                mesh.normals = this.Normals.ToArray();
            }

            if (this.UVs.Count == this.Vertices.Count)
            {
                mesh.uv = this.UVs.ToArray();
            }

            if (this.Colors.Count == this.Vertices.Count)
            {
                mesh.colors = this.Colors.ToArray();
            }

            // Have the mesh recalculate its bounding box (required for proper rendering).
            if (calculateBounds)
            {
                mesh.RecalculateBounds();
            }

            if (calculateNormals)
            {
                mesh.RecalculateNormals();
            }

            return(mesh);
        }