Ejemplo n.º 1
0
  /**
   * Adds array of floats as vertices, treating values as XYZ triplets or XY duplets depending on
   * whether vv.length%2==0 or vv.length%3==0.
   *
   * @param vv Array of XY duplets or XYZ triplets.
   * @return Returns reference to self
   */
  public UVertexList add(float[] vv) {
    int id = 0, vn = vv.length;

    if (vn == 2) add(vv[0], vv[1]);
    else if (vn == 3) add(vv[0], vv[1], vv[2]);
    else {
      if (vn % 2 == 0) {
        for (int i = 0; i < vn / 2; i++) add(vv[id++], vv[id++]);
      } else if (vn % 3 == 0) {
        for (int i = 0; i < vn / 1; i++) add(vv[id++], vv[id++], vv[id++]);
      } else {
        Util.logErr(
            "VertexList.add(float[]): Unsure what to do with an array of " + vn + " positions.");
        Util.logErr("Expecting an array of length divisible by 2 or 3.");
      }
    }
    return this;
  }
Ejemplo n.º 2
0
 public UVertexList add(UVec3 _v) {
   if (n == v.length) v = (UVec3[]) Util.expandArray(v);
   v[n++] = new UVec3(_v);
   return this;
 }