de.jreality.geometry
Class HeightFieldFactory
java.lang.Object
de.jreality.geometry.AbstractGeometryFactory
de.jreality.geometry.QuadMeshFactory
de.jreality.geometry.HeightFieldFactory
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
Methods inherited from class de.jreality.geometry.QuadMeshFactory |
getQuadMesh, setFaceAttribute, setFaceAttributes, setFaceColors, setFaceColors, setFaceColors, setFaceLabels, setFaceNormals, setFaceNormals, setFaceNormals, setVertexAttribute, setVertexAttributes, setVertexColors, setVertexColors, setVertexColors, setVertexColors, setVertexCoordinates, setVertexCoordinates, setVertexCoordinates, setVertexCoordinates, setVertexLabels, setVertexNormals, setVertexNormals, setVertexNormals, setVertexNormals, setVertexTextureCoordinates, setVertexTextureCoordinates, setVertexTextureCoordinates, setVertexTextureCoordinates |
HeightFieldFactory
public HeightFieldFactory()
setRegularDomain
public void setRegularDomain(Rectangle2D r)
- Set the domain for this height field. Default: (xmin, ymin, width, height) = (-1, -1, 2, 2).
- Parameters:
r
-
getRegularDomain
public Rectangle2D getRegularDomain()
getCoordinatesForUV
public static double[] getCoordinatesForUV(double[] store,
Rectangle2D d,
int u,
int v,
int uc,
int vc)
setVertexCount
public void setVertexCount(int count)
setFaceCount
public void setFaceCount(int count)
getULineCount
public int getULineCount()
getVLineCount
public int getVLineCount()
setULineCount
public void setULineCount(int newU)
setVLineCount
public void setVLineCount(int newV)
isClosedInUDirection
public boolean isClosedInUDirection()
isClosedInVDirection
public boolean isClosedInVDirection()
setClosedInUDirection
public void setClosedInUDirection(boolean close)
setClosedInVDirection
public void setClosedInVDirection(boolean close)
isGenerateTextureCoordinates
public boolean isGenerateTextureCoordinates()
setGenerateTextureCoordinates
public void setGenerateTextureCoordinates(boolean generateTextureCoordinates)
getUTextureScale
public double getUTextureScale()
setUTextureScale
public void setUTextureScale(double textureScale)
getVTextureScale
public double getVTextureScale()
setVTextureScale
public void setVTextureScale(double textureScale)
getUTextureShift
public double getUTextureShift()
setUTextureShift
public void setUTextureShift(double textureShift)
getVTextureShift
public double getVTextureShift()
setVTextureShift
public void setVTextureShift(double textureShift)
isEdgeFromQuadMesh
public boolean isEdgeFromQuadMesh()
setEdgeFromQuadMesh
public void setEdgeFromQuadMesh(boolean b)
getIndexedFaceSet
public IndexedFaceSet getIndexedFaceSet()
isGenerateEdgesFromFaces
public boolean isGenerateEdgesFromFaces()
setGenerateEdgesFromFaces
public void setGenerateEdgesFromFaces(boolean generateEdgesFromFaces)
isGenerateVertexNormals
public boolean isGenerateVertexNormals()
setGenerateVertexNormals
public void setGenerateVertexNormals(boolean generateVertexNormals)
isGenerateFaceNormals
public boolean isGenerateFaceNormals()
setGenerateFaceNormals
public void setGenerateFaceNormals(boolean generateFaceNormals)
isGenerateFaceLabels
public boolean isGenerateFaceLabels()
setGenerateFaceLabels
public void setGenerateFaceLabels(boolean generateFaceLabels)
isGenerateAABBTree
public boolean isGenerateAABBTree()
setGenerateAABBTree
public void setGenerateAABBTree(boolean generate)
getLineCount
public int getLineCount()
getIndexedLineSet
public IndexedLineSet getIndexedLineSet()
isGenerateEdgeLabels
public boolean isGenerateEdgeLabels()
setGenerateEdgeLabels
public void setGenerateEdgeLabels(boolean generateEdgeLabels)
getVertexCount
public int getVertexCount()
getPointSet
public PointSet getPointSet()
isGenerateVertexLabels
public boolean isGenerateVertexLabels()
setGenerateVertexLabels
public void setGenerateVertexLabels(boolean generateVertexLabels)