de.jreality.geometry
Class HeightFieldFactory
java.lang.Object
de.jreality.geometry.AbstractGeometryFactory
de.jreality.geometry.AbstractPointSetFactory
de.jreality.geometry.AbstractIndexedLineSetFactory
de.jreality.geometry.AbstractIndexedFaceSetFactory
de.jreality.geometry.AbstractQuadMeshFactory
de.jreality.geometry.QuadMeshFactory
de.jreality.geometry.HeightFieldFactory
- All Implemented Interfaces:
- GeometryFactory
public class HeightFieldFactory
- extends QuadMeshFactory
A factory for generating instances of 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:
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);
Warning: Not all jReality backends can handle such height fields. JOGL and PORTAL can.
- Author:
- Charles Gunn
Method Summary |
static double[] |
getCoordinatesForUV(double[] store,
java.awt.geom.Rectangle2D d,
int u,
int v,
int uc,
int vc)
|
java.awt.geom.Rectangle2D |
getRegularDomain()
|
void |
setRegularDomain(java.awt.geom.Rectangle2D r)
Set the domain for this height field. |
Methods inherited from class de.jreality.geometry.QuadMeshFactory |
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 |
Methods inherited from class de.jreality.geometry.AbstractQuadMeshFactory |
getULineCount, getUTextureScale, getUTextureShift, getVLineCount, getVTextureScale, getVTextureShift, isClosedInUDirection, isClosedInVDirection, isEdgeFromQuadMesh, isGenerateTextureCoordinates, setClosedInUDirection, setClosedInVDirection, setEdgeFromQuadMesh, setFaceCount, setGenerateTextureCoordinates, setULineCount, setUTextureScale, setUTextureShift, setVertexCount, setVLineCount, setVTextureScale, setVTextureShift |
Methods inherited from class de.jreality.geometry.AbstractIndexedFaceSetFactory |
getIndexedFaceSet, isGenerateAABBTree, isGenerateEdgesFromFaces, isGenerateFaceLabels, isGenerateFaceNormals, isGenerateVertexNormals, setGenerateAABBTree, setGenerateEdgesFromFaces, setGenerateFaceLabels, setGenerateFaceNormals, setGenerateVertexNormals |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
HeightFieldFactory
public HeightFieldFactory()
setRegularDomain
public void setRegularDomain(java.awt.geom.Rectangle2D r)
- Set the domain for this height field. Default: (xmin, ymin, width, height) = (-1, -1, 2, 2).
- Parameters:
r
-
getRegularDomain
public java.awt.geom.Rectangle2D getRegularDomain()
getCoordinatesForUV
public static double[] getCoordinatesForUV(double[] store,
java.awt.geom.Rectangle2D d,
int u,
int v,
int uc,
int vc)