public class HeightFieldFactory extends QuadMeshFactory
IndexedFaceSet
which
are defined by a height field.
Use the QuadMeshFactory.setVertexCoordinates(double[][])
or some variation, to set the height field (with one entry per vector).
Then use setRegularDomain(Rectangle2D)
to specify the domain of
definition of the height field. The resulting height field will
have (x,y) values given by appropriately interpolated position in the
domain, and z-value the appropriate element of the z-array.
The following code snippet illustrates a typical usage:
Warning: Not all jReality backends can handle such height fields. JOGL and PORTAL can.
SceneGraphComponent theWorld = SceneGraphUtility.createFullSceneGraphComponent();
double[][] verts = new double[200][1];
for (int i =0; i<20; ++i) {
for (int j =0; j<10; ++j) {
verts[10*i+j][0] = 1.0 - (.25*(i-9.5)*(i-9.5)+(j-4.5)*(j-4.5))/50;
}
}
HeightFieldFactory hff = new HeightFieldFactory();
hff. setULineCount(10);
hff.setVLineCount(20);
hff.setClosedInUDirection(false);
hff.setClosedInVDirection(false);
hff.setVertexCoordinates(verts);
hff.setGenerateVertexNormals(true);
hff.setGenerateFaceNormals(true);
Rectangle2D.Double domain = new Rectangle2D.Double(-2, -2, 4, 4);
hff.setRegularDomain(domain);
hff.update();
IndexedFaceSet ifs = hff.getIndexedFaceSet();
theWorld.setGeometry( ifs);
Constructor and Description |
---|
HeightFieldFactory() |
Modifier and Type | Method and Description |
---|---|
static double[] |
getCoordinatesForUV(double[] store,
Rectangle2D d,
int u,
int v,
int uc,
int vc) |
Rectangle2D |
getRegularDomain() |
void |
setRegularDomain(Rectangle2D r)
Set the domain for this height field.
|
getQuadMesh, setFaceAttribute, setFaceAttribute, setFaceAttribute, setFaceAttributes, setFaceColors, setFaceColors, setFaceColors, setFaceLabels, setFaceNormals, setFaceNormals, setFaceNormals, setVertexAttribute, setVertexAttribute, setVertexAttribute, setVertexAttributes, setVertexColors, setVertexColors, setVertexColors, setVertexColors, setVertexColors, setVertexCoordinates, setVertexCoordinates, setVertexCoordinates, setVertexCoordinates, setVertexLabels, setVertexNormals, setVertexNormals, setVertexNormals, setVertexNormals, setVertexTextureCoordinates, setVertexTextureCoordinates, setVertexTextureCoordinates, setVertexTextureCoordinates
getULineCount, getUTextureScale, getUTextureShift, getVLineCount, getVTextureScale, getVTextureShift, isClosedInUDirection, isClosedInVDirection, isEdgeFromQuadMesh, isGenerateTextureCoordinates, setClosedInUDirection, setClosedInVDirection, setEdgeFromQuadMesh, setFaceCount, setGenerateTextureCoordinates, setULineCount, setUTextureScale, setUTextureShift, setVertexCount, setVLineCount, setVTextureScale, setVTextureShift
getIndexedFaceSet, isGenerateAABBTree, isGenerateEdgesFromFaces, isGenerateFaceLabels, isGenerateFaceNormals, isGenerateVertexNormals, setGenerateAABBTree, setGenerateEdgesFromFaces, setGenerateFaceLabels, setGenerateFaceNormals, setGenerateVertexNormals
getEdgeCount, getIndexedLineSet, getLineCount, isGenerateEdgeLabels, setGenerateEdgeLabels, setLineCount
getPointSet, getVertexCount, isGenerateVertexLabels, setGenerateVertexLabels
getGeometry, getMetric, setMetric, update
public void setRegularDomain(Rectangle2D r)
r
- public Rectangle2D getRegularDomain()
public static double[] getCoordinatesForUV(double[] store, Rectangle2D d, int u, int v, int uc, int vc)