Class ElevationSegment

java.lang.Object
  |
  +--javax.media.j3d.SceneGraphObject
        |
        +--javax.media.j3d.Node
              |
              +--javax.media.j3d.Leaf
                    |
                    +--javax.media.j3d.Shape3D
                          |
                          +--ElevationSegment

public class ElevationSegment
extends javax.media.j3d.Shape3D

ElevationSegment is a specialization of Shape3d. It creates a 3D map of terrain data using an interleaved triangle strip array. Terrain data is passed into ElevationSegment as a two dimensional array of elevations. These are converted into a series of triangle strips to represent their geometry.

Author:
Mark Pendergast

Field Summary
private static int COLOR_OFFSET
           
private static int COORD_OFFSET
           
private  int dColumns
          number of columns of vertex data stored
private  float deltaX
          meters between columns of data
private  float deltaZ
          meters between rows of data
private  int dRows
          number of rows of vertex data stored
private static int FLOATSPERVERTEX
           
 GroundCoordinates groundCoordinates
          ground coordinates for the model, contains the lat/long of the four corners in arc seconds
private static javax.vecmath.Color3f matColor
           
private static int NORMAL_OFFSET
           
private  InterleavedTriangleStripArray tStrip
           
private  float[] vertexData
           
private  float xStart
          first column logical coordinate
private  float zStart
          first row logical coordinate
 
Fields inherited from class javax.media.j3d.Shape3D
ALLOW_APPEARANCE_OVERRIDE_READ, ALLOW_APPEARANCE_OVERRIDE_WRITE, ALLOW_APPEARANCE_READ, ALLOW_APPEARANCE_WRITE, ALLOW_COLLISION_BOUNDS_READ, ALLOW_COLLISION_BOUNDS_WRITE, ALLOW_GEOMETRY_READ, ALLOW_GEOMETRY_WRITE
 
Fields inherited from class javax.media.j3d.Node
ALLOW_AUTO_COMPUTE_BOUNDS_READ, ALLOW_AUTO_COMPUTE_BOUNDS_WRITE, ALLOW_BOUNDS_READ, ALLOW_BOUNDS_WRITE, ALLOW_COLLIDABLE_READ, ALLOW_COLLIDABLE_WRITE, ALLOW_LOCAL_TO_VWORLD_READ, ALLOW_PICKABLE_READ, ALLOW_PICKABLE_WRITE, ENABLE_COLLISION_REPORTING, ENABLE_PICK_REPORTING
 
Fields inherited from class javax.media.j3d.SceneGraphObject
 
Constructor Summary
ElevationSegment(int[][] elevations, int startRow, int startColumn, int stopRow, int stopColumn, int minEl, int maxEl, GroundCoordinates gc, float exageration, float lowX, float highX, float lowZ, float highZ, int resolution)
          Constructor is reponsible for setting up the appearance/material, computing the triangle strip values (colors, normals, coordinates) stored in vertexData, then creating the actual JAVA 3D geometry.
 
Method Summary
 float getElevationAt(float x, float z)
          Fetches the elevation at a particular location on the terrain map given the x,z coordinates.
 void setColor(int i, int elevation, int minElevation, int maxElevation)
          store color data into vertex data array, compute color based on the elevation's distance between min and max elevations
 void setCoordinate(int[][] elevations, int i, int row, int col, int startRow, int startColumn, float exageration)
          store coordinate data into vertex data array
private  void setupAppearance()
          setup the material properties and coloring attributes
 void stitchRight(ElevationSegment other)
          stitch right of this segment to left of other segment, stitching consists of averaging the normals on the common boundary vertices between segments.
 void stitchTop(ElevationSegment other)
          stitch top of this segment to bottom of other segment, stitching consists of averaging the normals on the common boundary vertices between segments.
 
Methods inherited from class javax.media.j3d.Shape3D
addGeometry, cloneNode, duplicateNode, getAllGeometries, getAppearance, getAppearanceOverrideEnable, getBounds, getCollisionBounds, getGeometry, getGeometry, insertGeometry, intersect, intersect, numGeometries, removeGeometry, setAppearance, setAppearanceOverrideEnable, setCollisionBounds, setGeometry, setGeometry
 
Methods inherited from class javax.media.j3d.Node
cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, getBoundsAutoCompute, getCollidable, getLocalToVworld, getLocalToVworld, getParent, getPickable, setBounds, setBoundsAutoCompute, setCollidable, setPickable
 
Methods inherited from class javax.media.j3d.SceneGraphObject
clearCapability, duplicateSceneGraphObject, getCapability, getUserData, isCompiled, isLive, setCapability, setUserData, updateNodeReferences
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

groundCoordinates

public GroundCoordinates groundCoordinates
ground coordinates for the model, contains the lat/long of the four corners in arc seconds


dRows

private int dRows
number of rows of vertex data stored


dColumns

private int dColumns
number of columns of vertex data stored


deltaX

private float deltaX
meters between columns of data


deltaZ

private float deltaZ
meters between rows of data


xStart

private float xStart
first column logical coordinate


zStart

private float zStart
first row logical coordinate


FLOATSPERVERTEX

private static final int FLOATSPERVERTEX
See Also:
Constant Field Values

COLOR_OFFSET

private static final int COLOR_OFFSET
See Also:
Constant Field Values

NORMAL_OFFSET

private static final int NORMAL_OFFSET
See Also:
Constant Field Values

COORD_OFFSET

private static final int COORD_OFFSET
See Also:
Constant Field Values

vertexData

private float[] vertexData

matColor

private static javax.vecmath.Color3f matColor

tStrip

private InterleavedTriangleStripArray tStrip
Constructor Detail

ElevationSegment

public ElevationSegment(int[][] elevations,
                        int startRow,
                        int startColumn,
                        int stopRow,
                        int stopColumn,
                        int minEl,
                        int maxEl,
                        GroundCoordinates gc,
                        float exageration,
                        float lowX,
                        float highX,
                        float lowZ,
                        float highZ,
                        int resolution)
Constructor is reponsible for setting up the appearance/material, computing the triangle strip values (colors, normals, coordinates) stored in vertexData, then creating the actual JAVA 3D geometry.

Parameters:
elevations - two dimensional array of terrain elevation data in meters
startRow - first row of data to use from elevations
startColumn - first column of data to use from elevations
stopRow - last row of data to use from elevations
stopColumn - last column of data to use from elevations
minEl - minimum elevation in elevations
maxEl - maximum elevation in elevations
gc - latitude, longitude of the corners of this segment
exageration - amount to exagerate(multiply) elevations by
lowX - starting x coordinate in meters
highX - stopping x coordinate in meters
lowZ - starting z coordinate in meters
highZ - stopping z coordinate in meters
resolution - number of rows/columns of elevation data to skip when mapping. A resolution of 1 implies mapping every elevation point, a resolution of 10 implies mapping every 10th point.
Method Detail

setupAppearance

private void setupAppearance()
setup the material properties and coloring attributes


setCoordinate

public void setCoordinate(int[][] elevations,
                          int i,
                          int row,
                          int col,
                          int startRow,
                          int startColumn,
                          float exageration)
store coordinate data into vertex data array

Parameters:
elevations - array of elevations
i - index into vertexData to store coordinate
row - elevation row
col - elevation column
startRow - first row used in elevations
exageration - elevation exageration factor

setColor

public void setColor(int i,
                     int elevation,
                     int minElevation,
                     int maxElevation)
store color data into vertex data array, compute color based on the elevation's distance between min and max elevations

Parameters:
i - index into vertexData to store coordinate
elevation - vertex elevation (no exageration)
minElevation - minimum elevation in model
maxElevation - maximum elevation in model

stitchRight

public void stitchRight(ElevationSegment other)
stitch right of this segment to left of other segment, stitching consists of averaging the normals on the common boundary vertices between segments. That is, since adjacent segments have the same vertices in common (the left side of one is the same as the right side of the other), then these normals should be the same as well to prevent visible seams.

Parameters:
other - reference to the segment to the right of this one

stitchTop

public void stitchTop(ElevationSegment other)
stitch top of this segment to bottom of other segment, stitching consists of averaging the normals on the common boundary vertices between segments. That is, since adjacent segments have the same vertices in common (the top of one is the same as the bottom of the other), then these normals should be the same as well to prevent visible seams.

Parameters:
other - reference to the segment to the right of this one

getElevationAt

public float getElevationAt(float x,
                            float z)
Fetches the elevation at a particular location on the terrain map given the x,z coordinates. X,Z coordinates represent the distance in meters from the center of the terrain image

Parameters:
x - x coordinate
z - z coordinate
Returns:
the elevation (y coordinate) in meters (adjusted for exageration)