Ejemplo n.º 1
0
  /**
   * Convenience method to calculate <code>res</code> vertices along a circle of <code>R</code>
   * radius
   *
   * @param R Radius of circle
   * @param res Number of points to calculate
   * @return
   */
  public static UVertexList getCircle(float R, int res) {
    UVertexList vl = new UVertexList();
    float D = TWO_PI / (float) (res - 1);
    for (int i = 0; i < res; i++)
      vl.add(PApplet.cos(D * (float) i) * R, PApplet.sin(D * (float) i) * R, 0);

    return vl;
  }
Ejemplo n.º 2
0
  /*
   *  Reorders a vertex list organized as a QUAD_STRIP duplets of vertices, so that it forms an outline path instead. The logic is as follows:
   *  <pre>
   *  int u=n/2;
   *  UVertexList tmp=new UVertexList();
   *
   *  for(int i=u-1; i>-1; i--) tmp.add(v[i*2]);
   *  for(int i=0; i<u; i++) tmp.add(v[i*2+1]);
   *  v=tmp.v;
   *  n=tmp.n;
   *  </pre>
   */
  public UVertexList QStoOutline() {
    int u = n / 2;
    UVertexList tmp = new UVertexList();

    for (int i = u - 1; i > -1; i--) tmp.add(v[i * 2]);
    for (int i = 0; i < u; i++) tmp.add(v[i * 2 + 1]);

    v = tmp.v;
    n = tmp.n;

    return this;
  }