/** * Constructs a triangle group with specified vertex coordinates. * <p> * The (x,y,z) coordinates of vertices are packed into the specified * array xyz. The number of vertices is nv = xyz.length/3. * <p> * The (u,v,w) components of normal vectors are packed into the specified * array uvw. The number of normal vectors equals the number of vertices. * @param xyz array[3*nv] of packed vertex coordinates. * @param uvw array[3*nv] of packed normal vector components. */ public TriangleGroup(float[] xyz, float[] uvw) { this(indexVertices(true,xyz),xyz,uvw,null); }
/** * Constructs a triangle group with specified vertex coordinates * and optional corresponding normal vectors and colors. * <p> * The (x,y,z) coordinates of vertices are packed into the specified * array xyz. The number of vertices is nv = xyz.length/3. * <p> * The (u,v,w) components of normal vectors are packed into the specified * array uvw. The number of normal vectors equals the number of vertices. * <p> * The (r,g,b) components of colors are packed into the specified array * rgb. The number of colors equals the number of vertices. * @param xyz array[3*nv] of packed vertex coordinates. * @param uvw array[3*nv] of packed normal vector components. * @param rgb array[3*nv] of packed color components. */ public TriangleGroup(float[] xyz, float[] uvw, float[] rgb) { this(indexVertices(true,xyz),xyz,uvw,rgb); }
/** * Constructs a triangle group with specified vertex coordinates. * <p> * The (x,y,z) coordinates of vertices are packed into the specified * array xyz. The number of vertices is nv = xyz.length/3. The number * of triangles is nt = nv/3 = xyz.length/9. * <p> * The (r,g,b) components of colors are packed into the specified * array rgb. The number of colors equals the number of vertices. * <p> * Normal vectors may be computed for either vertices or triangles. * When computed for a vertex, a normal vector is the area-weighted * average of the normal vectors for all triangles with that vertex. * <p> * If no vertices have the same (x,y,z) coordinates, then vertex and * triangle normal vectors are the same vectors, but triangle normal * vectors are less costly to compute. * @param vn true, for vertex normals; false, for triangle normals. * @param xyz array[3*nv] of packed vertex coordinates. * @param rgb array[3*nv] of packed color components. */ public TriangleGroup(boolean vn, float[] xyz, float[] rgb) { int[] ijk = indexVertices(!vn,xyz); float[] uvw = computeNormals(ijk,xyz); buildTree(ijk,xyz,uvw,rgb); setDefaultStates(); }