Ejemplo n.º 1
0
 public static void AddLines(Mesh mesh, IList<LineF> lines)
 {
     for (int i = 0; i < lines.Count; i++)
     {
         Vector3 v;
         v = new Vector3(lines[i][0].X, lines[i][0].Y, 0);
         int index0 = mesh.AddVertex(new Vertex(v, new Vector2()));
         v = new Vector3(lines[i][1].X, lines[i][1].Y, 0);
         int index1 = mesh.AddVertex(new Vertex(v, new Vector2()));
         mesh.AddTriangle(index0, index1, index1);
     }
 }
Ejemplo n.º 2
0
        public static Model CreateLineStrip(Vector2[] vertices, Vector3[] colors)
        {
            Debug.Assert(vertices.Length >= 2);
            Mesh mesh = new Mesh();
            for (int i = 0; i < vertices.Length - 1; i++)
            {
                Vector3 v, color = new Vector3();
                if (colors != null)
                {
                    color = colors[i];
                }

                v = new Vector3(vertices[i].X, vertices[i].Y, 0);
                int index0 = mesh.AddVertex(new Vertex(v, new Vector2(), color));
                v = new Vector3(vertices[i + 1].X, vertices[i + 1].Y, 0);
                int index1 = mesh.AddVertex(new Vertex(v, new Vector2(), color));
                mesh.AddTriangle(index0, index1, index1);
            }
            Model model = new Model(mesh);
            model.Wireframe = true;
            return model;
        }