title: How to make sense of JavaFX triangle mesh?
body: <p>Just trying to make sense of JavaFX documentation re triangle mesh.
  This code works and draws a rectangle.</p>
  
  <pre><code>public class Shape3DRectangle extends TriangleMesh {
  
      public Shape3DRectangle(float Width, float Height) {
          float[] points = {
              -Width/2,  Height/2, 0, // idx p0
              -Width/2, -Height/2, 0, // idx p1
               Width/2,  Height/2, 0, // idx p2
               Width/2, -Height/2, 0  // idx p3
          };
          float[] texCoords = {
              1, 1, // idx t0
              1, 0, // idx t1
              0, 1, // idx t2
              0, 0  // idx t3
          };
          /**
           * points:
           * 1      3
           *  -------   texture:
           *  |\    |  1,1    1,0
           *  | \   |    -------
           *  |  \  |    |     |
           *  |   \ |    |     |
           *  |    \|    -------
           *  -------  0,1    0,0
           * 0      2
           *
           * texture[3] 0,0 maps to vertex 2
           * texture[2] 0,1 maps to vertex 0
           * texture[0] 1,1 maps to vertex 1
           * texture[1] 1,0 maps to vertex 3
           * 
           * Two triangles define rectangular faces:
           * p0, t0, p1, t1, p2, t2 // First triangle of a textured rectangle 
           * p0, t0, p2, t2, p3, t3 // Second triangle of a textured rectangle
           */
          int[] faces = {
              2, 2, 1, 1, 0, 0,
              2, 2, 3, 3, 1, 1
          };
  
          this.getPoints().setAll(points);
          this.getTexCoords().setAll(texCoords);
          this.getFaces().setAll(faces);
      }
  }
  </code></pre>
  
  <p>The last 3 lines of the comment come from <a href="http://download.java.net/jdk8/jfxdocs/javafx/scene/shape/TriangleMesh.html" rel="nofollow">Class TriangleMesh</a>. My problem is that I do not see a match between their definition of the faces array and the faces array in the code. Thus don't understand how to use faces array in general for other cases. Should it not be this instead:</p>
  
  <pre><code>        int[] faces = {
              2, 3, 0, 2, 1, 0,
              2, 3, 1, 0, 3, 1
          };
  </code></pre>
  
  <p>But then nothing renders of the rectangle.
  What am I missing and what should go into the faces array in general?</p>