org.xith3d.terrain
Class GridTriangulator

java.lang.Object
  extended by org.xith3d.terrain.GridTriangulator

public class GridTriangulator
extends java.lang.Object

A GridTriangulator is used to create a set of triangles from a regular Grid.

See Also:
GridSampler

Nested Class Summary
static interface GridTriangulator.CoordinateCallback
           
static interface GridTriangulator.IndexCallback
           
 
Constructor Summary
GridTriangulator(GridSampler grid, int complexity)
           
GridTriangulator(GridSampler grid, int complexity, float yScale)
           
GridTriangulator(GridSampler grid, int complexity, float yScale, float x1, float z1, float x2, float z2)
           
GridTriangulator(GridSampler grid, int complexity, float yScale, float x1, float z1, float x2, float z2, float s1, float t1, float s2, float t2)
           
GridTriangulator(GridSampler grid, int complexity, float yScale, float x1, float z1, float x2, float z2, float s1, float t1, float s2, float t2, float baseTolerance)
           
 
Method Summary
 float getBaseTolerance()
           
 int getComplexity()
           
 org.openmali.vecmath2.Tuple3f[] getCoordinates()
           
 org.openmali.vecmath2.Tuple3f[] getCoordinates(boolean optimized)
          TODO (cylab 2007-MAR-06) implement the optimized flag
 GridSampler getGrid()
           
 int[] getIndex()
           
 int[] getIndex(float tolerance)
           
 int[] getIndex(float tolerance, org.openmali.vecmath2.Tuple3f eyePosition, float threshold)
           
 void getIndex(float tolerance, org.openmali.vecmath2.Tuple3f eyePosition, float threshold, GridTriangulator.IndexCallback callback)
           
 float getMaxY()
           
 float getMinY()
           
 org.openmali.vecmath2.Vector3f[] getNormals()
           
 float getS1()
           
 float getS2()
           
 int getSize()
           
 float getT1()
           
 float getT2()
           
 float getX1()
           
 float getX2()
           
 float getYScale()
           
 float getZ1()
           
 float getZ2()
           
 boolean isBackgroundOptimized()
           
 boolean isChanged()
           
 void refineMesh(java.util.List<java.lang.Integer> triangleStrip, int complexity)
           
 void refineSubMesh(java.util.List<java.lang.Integer> triangleStrip, int xi, int yi, int xj, int yj, int xk, int yk, int level)
           
 void setBackgroundOptimized(boolean backgroundOptimized)
           
 void setBaseTolerance(float baseTolerance)
           
 void setChanged(boolean changed)
           
 void setComplexity(int complexity)
           
 void setGrid(GridSampler grid)
           
 void setS1(float s1)
           
 void setS2(float s2)
           
 void setT1(float t1)
           
 void setT2(float t2)
           
 void setX1(float x1)
           
 void setX2(float x2)
           
 void setYScale(float yScale)
           
 void setZ1(float z1)
           
 void setZ2(float z2)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GridTriangulator

public GridTriangulator(GridSampler grid,
                        int complexity)

GridTriangulator

public GridTriangulator(GridSampler grid,
                        int complexity,
                        float yScale)

GridTriangulator

public GridTriangulator(GridSampler grid,
                        int complexity,
                        float yScale,
                        float x1,
                        float z1,
                        float x2,
                        float z2)

GridTriangulator

public GridTriangulator(GridSampler grid,
                        int complexity,
                        float yScale,
                        float x1,
                        float z1,
                        float x2,
                        float z2,
                        float s1,
                        float t1,
                        float s2,
                        float t2)

GridTriangulator

public GridTriangulator(GridSampler grid,
                        int complexity,
                        float yScale,
                        float x1,
                        float z1,
                        float x2,
                        float z2,
                        float s1,
                        float t1,
                        float s2,
                        float t2,
                        float baseTolerance)
Parameters:
grid - the gridsampler to read the values to triangulate from.
complexity - defines the amount of samples to be pow(2,complexity)+1 * pow(2,complexity)+1. A complexity of e.g. 3 results in a 9x9 triangle mesh.
yScale - the scale factor to scale the read grid values with.
x1 - the x position of the left furthermost corner of the resulting triangle mesh
z1 - the z position of the left furthermost corner of the resulting triangle mesh
x2 - the x position of the nearest right corner of the resulting triangle mesh
z2 - the z position of the nearest right corner of the resulting triangle mesh
s1 - the s coordinate of the top left corner of the grid to be sampled
t1 - the t coordinate of the top left corner of the grid to be sampled
s2 - the s coordinate of the lower right corner of the grid to be sampled
t2 - the t coordinate of the lower right corner of the grid to be sampled
baseTolerance - the tolerance used to reduce the triangle indexCount of the resulting mesh
Method Detail

isChanged

public boolean isChanged()

setChanged

public void setChanged(boolean changed)

isBackgroundOptimized

public boolean isBackgroundOptimized()

setBackgroundOptimized

public void setBackgroundOptimized(boolean backgroundOptimized)

getGrid

public GridSampler getGrid()

setGrid

public void setGrid(GridSampler grid)

getComplexity

public int getComplexity()

setComplexity

public void setComplexity(int complexity)

getSize

public int getSize()

getYScale

public float getYScale()

setYScale

public void setYScale(float yScale)

getX1

public float getX1()

setX1

public void setX1(float x1)

getZ1

public float getZ1()

setZ1

public void setZ1(float z1)

getX2

public float getX2()

setX2

public void setX2(float x2)

getZ2

public float getZ2()

setZ2

public void setZ2(float z2)

getS1

public float getS1()

setS1

public void setS1(float s1)

getS2

public float getS2()

setS2

public void setS2(float s2)

getT1

public float getT1()

setT1

public void setT1(float t1)

getT2

public float getT2()

setT2

public void setT2(float t2)

getMaxY

public float getMaxY()

getMinY

public float getMinY()

getBaseTolerance

public float getBaseTolerance()

setBaseTolerance

public void setBaseTolerance(float baseTolerance)

getNormals

public org.openmali.vecmath2.Vector3f[] getNormals()

getCoordinates

public org.openmali.vecmath2.Tuple3f[] getCoordinates()

getCoordinates

public org.openmali.vecmath2.Tuple3f[] getCoordinates(boolean optimized)
TODO (cylab 2007-MAR-06) implement the optimized flag

Parameters:
optimized -
Returns:
(something)

getIndex

public int[] getIndex()

getIndex

public int[] getIndex(float tolerance)

getIndex

public int[] getIndex(float tolerance,
                      org.openmali.vecmath2.Tuple3f eyePosition,
                      float threshold)

getIndex

public void getIndex(float tolerance,
                     org.openmali.vecmath2.Tuple3f eyePosition,
                     float threshold,
                     GridTriangulator.IndexCallback callback)

refineMesh

public void refineMesh(java.util.List<java.lang.Integer> triangleStrip,
                       int complexity)

refineSubMesh

public void refineSubMesh(java.util.List<java.lang.Integer> triangleStrip,
                          int xi,
                          int yi,
                          int xj,
                          int yj,
                          int xk,
                          int yk,
                          int level)