de.jreality.geometry
Class HeightFieldFactory

java.lang.Object
  extended by de.jreality.geometry.AbstractGeometryFactory
      extended by de.jreality.geometry.QuadMeshFactory
          extended by 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

Constructor Summary
HeightFieldFactory()
           
 
Method Summary
static double[] getCoordinatesForUV(double[] store, Rectangle2D d, int u, int v, int uc, int vc)
           
 IndexedFaceSet getIndexedFaceSet()
           
 IndexedLineSet getIndexedLineSet()
           
 int getLineCount()
           
 PointSet getPointSet()
           
 Rectangle2D getRegularDomain()
           
 int getULineCount()
           
 double getUTextureScale()
           
 double getUTextureShift()
           
 int getVertexCount()
           
 int getVLineCount()
           
 double getVTextureScale()
           
 double getVTextureShift()
           
 boolean isClosedInUDirection()
           
 boolean isClosedInVDirection()
           
 boolean isEdgeFromQuadMesh()
           
 boolean isGenerateAABBTree()
           
 boolean isGenerateEdgeLabels()
           
 boolean isGenerateEdgesFromFaces()
           
 boolean isGenerateFaceLabels()
           
 boolean isGenerateFaceNormals()
           
 boolean isGenerateTextureCoordinates()
           
 boolean isGenerateVertexLabels()
           
 boolean isGenerateVertexNormals()
           
 void setClosedInUDirection(boolean close)
           
 void setClosedInVDirection(boolean close)
           
 void setEdgeFromQuadMesh(boolean b)
           
 void setFaceCount(int count)
           
 void setGenerateAABBTree(boolean generate)
           
 void setGenerateEdgeLabels(boolean generateEdgeLabels)
           
 void setGenerateEdgesFromFaces(boolean generateEdgesFromFaces)
           
 void setGenerateFaceLabels(boolean generateFaceLabels)
           
 void setGenerateFaceNormals(boolean generateFaceNormals)
           
 void setGenerateTextureCoordinates(boolean generateTextureCoordinates)
           
 void setGenerateVertexLabels(boolean generateVertexLabels)
           
 void setGenerateVertexNormals(boolean generateVertexNormals)
           
 void setRegularDomain(Rectangle2D r)
          Set the domain for this height field.
 void setULineCount(int newU)
           
 void setUTextureScale(double textureScale)
           
 void setUTextureShift(double textureShift)
           
 void setVertexCount(int count)
           
 void setVLineCount(int newV)
           
 void setVTextureScale(double textureScale)
           
 void setVTextureShift(double textureShift)
           
 
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
 
Methods inherited from class de.jreality.geometry.AbstractGeometryFactory
getGeometry, getSignature, setSignature, update
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HeightFieldFactory

public HeightFieldFactory()
Method Detail

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)