Class LODSegment

java.lang.Object
  |
  +--javax.media.j3d.SceneGraphObject
        |
        +--javax.media.j3d.Node
              |
              +--javax.media.j3d.Group
                    |
                    +--javax.media.j3d.BranchGroup
                          |
                          +--LODSegment

public class LODSegment
extends javax.media.j3d.BranchGroup

LOD segment is based on a TransformGroup. Each LODSegment is actually comprised of three ElevationSegments, each created with a different resolution. Switch and DistanceLOD objects are used to determine which of the three to render (based on how far away it is from the viewing platform). This speeds up rendering and allows real-time fly throughs of the scene.

Author:
Mark Pendergast

Field Summary
private  float[] distances
          distance array used to determine which ElevationSegment to display.
private  javax.media.j3d.DistanceLOD dLOD
          DistanceLOD node to tell Switch which one to display
 GroundCoordinates groundCoordinates
          Ground coordinates, lat, long, of the segment
private  int[] resolutions
          resolutions of Elevation segments, 1 implies every point, 10 implies every 10th point
private  ElevationSegment[] segments
          ElevationSegments, one for each resolution
private  javax.media.j3d.Switch switchNode
          Switch node to control ElevationSegments
 
Fields inherited from class javax.media.j3d.BranchGroup
ALLOW_DETACH
 
Fields inherited from class javax.media.j3d.Group
ALLOW_CHILDREN_EXTEND, ALLOW_CHILDREN_READ, ALLOW_CHILDREN_WRITE, ALLOW_COLLISION_BOUNDS_READ, ALLOW_COLLISION_BOUNDS_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
LODSegment(int[][] elevations, int startRow, int startColumn, int stopRow, int stopColumn, int minEl, int maxEl, GroundCoordinates gc, float exageration, float minX, float maxX, float minZ, float maxZ)
          Constructor is for creating the series of objects that allow level of detail based on distance displays.
 
Method Summary
 float getElevationAt(float x, float z)
          Fetches the elevation at a particular location on the terrain map given the x,z coordinates.
 ElevationSegment getSegment(int i)
          retrieves an elevation segment object
 void stitchRight(LODSegment 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(LODSegment 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.BranchGroup
cloneNode, compile, detach, pickAll, pickAllSorted, pickAny, pickClosest
 
Methods inherited from class javax.media.j3d.Group
addChild, getAllChildren, getAlternateCollisionTarget, getChild, getCollisionBounds, insertChild, moveTo, numChildren, removeChild, setAlternateCollisionTarget, setChild, setCollisionBounds
 
Methods inherited from class javax.media.j3d.Node
cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, duplicateNode, getBounds, 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, lat, long, of the segment


resolutions

private int[] resolutions
resolutions of Elevation segments, 1 implies every point, 10 implies every 10th point


distances

private float[] distances
distance array used to determine which ElevationSegment to display. Computed based on model


segments

private ElevationSegment[] segments
ElevationSegments, one for each resolution


switchNode

private javax.media.j3d.Switch switchNode
Switch node to control ElevationSegments


dLOD

private javax.media.j3d.DistanceLOD dLOD
DistanceLOD node to tell Switch which one to display

Constructor Detail

LODSegment

public LODSegment(int[][] elevations,
                  int startRow,
                  int startColumn,
                  int stopRow,
                  int stopColumn,
                  int minEl,
                  int maxEl,
                  GroundCoordinates gc,
                  float exageration,
                  float minX,
                  float maxX,
                  float minZ,
                  float maxZ)
Constructor is for creating the series of objects that allow level of detail based on distance displays.

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
minX - starting x coordinate in meters
maxX - stopping x coordinate in meters
minZ - starting z coordinate in meters
maxZ - stopping z coordinate in meters
Method Detail

getSegment

public ElevationSegment getSegment(int i)
retrieves an elevation segment object

Parameters:
i - index of the segment desired
Returns:
reference to the ith ElevationSegment object

stitchRight

public void stitchRight(LODSegment 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(LODSegment 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)