public class QuadGroup extends Group implements Selectable
Quads may be specified by providing an array of packed vertex (x,y,z) coordinates and an array of packed (i,j,k,l) vertex indices. Each set (i,j,k,l) of four vertex indices corresponds to one quad.
Alternatively, quads may be specified by providing only the array of packed vertex (x,y,z) coordinates. In this case, a vertex index is assigned automatically to each vertex.
Normal vectors are computed for each vertex as an area-weighted average of the vectors normal to all quads that reference that vertex with the same index. These area-weighted normal vectors are used in lighting.
Constructor and Description |
---|
QuadGroup(boolean vn,
float[] xyz)
Constructs a quad group with specified vertex coordinates.
|
QuadGroup(boolean vn,
float[] xyz,
float[] rgb)
Constructs a quad group with specified vertex coordinates.
|
QuadGroup(boolean vn,
Sampling sx,
Sampling sy,
float[][] z)
Constructs a quad group for a sampled function z = f(x,y).
|
QuadGroup(boolean vn,
Sampling sx,
Sampling sy,
float[][] z,
float[][] r,
float[][] g,
float[][] b)
Constructs a quad group for a sampled function z = f(x,y).
|
QuadGroup(float[] xyz,
float[] uvw)
Constructs a quad group with specified vertex coordinates.
|
QuadGroup(float[] xyz,
float[] uvw,
float[] rgb)
Constructs a quad group with specified vertex coordinates
and optional corresponding normal vectors and colors.
|
QuadGroup(int[] ijkl,
float[] xyz)
Constructs a quad group with specified vertex coordinates.
|
QuadGroup(int[] ijkl,
float[] xyz,
float[] uvw)
Constructs a quad group with specified vertex coordinates.
|
QuadGroup(int[] ijkl,
float[] xyz,
float[] uvw,
float[] rgb)
Constructs a quad group with specified vertex coordinates
and optional corresponding normal vectors and colors.
|
Modifier and Type | Method and Description |
---|---|
static int[] |
indexVertices(boolean sequential,
float[] xyz)
Computes indices ijkl for quad vertex coordinates xyz.
|
protected void |
selectedChanged()
This method is called when the selected state of this node has changed.
|
void |
setColor(java.awt.Color color)
Sets the color of the quads in this quad group.
|
addChild, computeBoundingSphere, countChildren, cull, draw, getAttributeBits, getChildren, pick, removeChild
countParents, cullApply, cullBegin, cullEnd, dirtyBoundingSphere, dirtyDraw, drawApply, drawBegin, drawEnd, getBoundingSphere, getParents, getStates, getWorld, isSelected, pickApply, pickBegin, pickEnd, setSelected, setStates
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isSelected, setSelected
public QuadGroup(boolean vn, float[] xyz)
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 quads is nq = nv/4 = xyz.length/12.
Normal vectors may be computed for either vertices or quads. When computed for a vertex, a normal vector is the area-weighted average of the normal vectors for all quads with that vertex.
If no vertices have the same (x,y,z) coordinates, then vertex and quad normal vectors are the same vectors, but quad normal vectors are less costly to compute.
vn
- true, for vertex normals; false, for quad normals.xyz
- array[3*nv] of packed vertex coordinates.public QuadGroup(boolean vn, float[] xyz, float[] rgb)
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 quads is nq = nv/4 = xyz.length/12.
The (r,g,b) components of colors are packed into the specified array rgb. The number of colors equals the number of vertices.
Normal vectors may be computed for either vertices or quads. When computed for a vertex, a normal vector is the area-weighted average of the normal vectors for all quads with that vertex.
If no vertices have the same (x,y,z) coordinates, then vertex and quad normal vectors are the same vectors, but quad normal vectors are less costly to compute.
vn
- true, for vertex normals; false, for quad normals.xyz
- array[3*nv] of packed vertex coordinates.rgb
- array[3*nv] of packed color components.public QuadGroup(boolean vn, Sampling sx, Sampling sy, float[][] z)
vn
- true, for vertex normals; false, for quad normals.sx
- sampling of x coordinates; may be non-uniform.sy
- sampling of y coordinates; may be non-uniform.z
- array[nx][ny] of z coordinates z = f(x,y).public QuadGroup(boolean vn, Sampling sx, Sampling sy, float[][] z, float[][] r, float[][] g, float[][] b)
vn
- true, for vertex normals; false, for quad normals.sx
- sampling of x coordinates; may be non-uniform.sy
- sampling of y coordinates; may be non-uniform.z
- array[nx][ny] of z coordinates z = f(x,y).r
- array[nx][ny] of red color components.g
- array[nx][ny] of green color components.b
- array[nx][ny] of blue color components.public QuadGroup(int[] ijkl, float[] xyz)
Quads are specified by sets of four vertex indices (i,j,k,l), one set per quad, packed into the specified array of integers ijkl. The number of quads is nq = ijkl.length/4.
The (x,y,z) coordinates of vertices are packed into the specified array xyz. The number of vertices is nv = xyz.length/3.
For any vertex with index iv, this method computes a normal vector as an area-weighted average of the normal vectors for all quads specified with index iv.
ijkl
- array[4*nq] of packed vertex indices.xyz
- array[3*nv] of packed vertex coordinates.public QuadGroup(float[] xyz, float[] uvw)
The (x,y,z) coordinates of vertices are packed into the specified array xyz. The number of vertices is nv = xyz.length/3.
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.
xyz
- array[3*nv] of packed vertex coordinates.uvw
- array[3*nv] of packed normal vector components.public QuadGroup(int[] ijkl, float[] xyz, float[] uvw)
Quads are specified by sets of four vertex indices (i,j,k,l), one set per quad, packed into the specified array of integers ijkl. The number of quads is nq = ijkl.length/4.
The (x,y,z) coordinates of vertices are packed into the specified array xyz. The number of vertices is nv = xyz.length/3.
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.
ijkl
- array[4*nq] of packed vertex indices.xyz
- array[3*nv] of packed vertex coordinates.uvw
- array[3*nv] of packed normal vector components.public QuadGroup(float[] xyz, float[] uvw, float[] rgb)
The (x,y,z) coordinates of vertices are packed into the specified array xyz. The number of vertices is nv = xyz.length/3.
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.
The (r,g,b) components of colors are packed into the specified array rgb. The number of colors equals the number of vertices.
xyz
- array[3*nv] of packed vertex coordinates.uvw
- array[3*nv] of packed normal vector components.rgb
- array[3*nv] of packed color components.public QuadGroup(int[] ijkl, float[] xyz, float[] uvw, float[] rgb)
Quads are specified by sets of four vertex indices (i,j,k), one set per quad, packed into the specified array of integers ijkl. The number of quads is nq = ijkl.length/4.
The (x,y,z) coordinates of vertices are packed into the specified array xyz. The number of vertices is nv = xyz.length/3.
The (u,v,w) components of normal vectors are packed into the specified array uvw. If not null, the number of normal vectors equals the number of vertices.
The (r,g,b) components of colors are packed into the specified array rgb. If not null, the number of colors equals the number of vertices.
ijkl
- array[4*nq] of packed vertex indices.xyz
- array[3*nv] of packed vertex coordinates.uvw
- array[3*nv] of packed normal vector components.rgb
- array[3*nv] of packed color components.public static int[] indexVertices(boolean sequential, float[] xyz)
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 quads is nq = nv/4 = xyz.length/12.
For each quad, this method computes a set (i,j,k,l) of integer vertex indices. A vertex index is an integer in the range [0,nv-1]. The (x,y,z) coordinates of a vertex with index iv are xyz[3*iv+0], xyz[3*iv+1] and xyz[3*iv+2], respectively.
The simplest indexing is the sequence {0, 1, 2, ..., nv-1}. In this case, indices are assigned sequentially, so that every vertex of every quad has a different index.
In non-sequential indexing, vertices with the same (x,y,z) coordinates are assigned the same index. Again, index vertices will be in the range [0,nv-1], but some integers in this range may not be used. Whereas sequential indexing would assign integers ia and ib to two vertices that have the same (x,y,z) coordinates, non-sequential indexing will assign the smaller index min(ia,ib) to both vertices; the larger index max(ia,ib) will be unused.
Sets of four indices (i,j,k,l), one set per quad, are packed into the returned array of integers ijkl, which has length 4*nq.
sequential
- true, for sequential indexing; false, otherwise.xyz
- array[3*nv] of packed vertex coordinates.public void setColor(java.awt.Color color)
color
- the color.protected void selectedChanged()
Node
This implementation does nothing.
selectedChanged
in class Node