j3d.org Code

org.j3d.terrain.roam
Class ROAMPatch

java.lang.Object
  extended by org.j3d.terrain.roam.ROAMPatch

public abstract class ROAMPatch
extends java.lang.Object

A patch represents a single piece of terrain geometry that can be rendered as a standalone block within ROAM.

A patch represents a single block of geometry within the overall scheme of the terrain data. Apart from a fixed size nothing else is fixed in this patch. The patch consists of a single TriangleArray that uses a geometry updater (geometry by reference is used) to update the geometry each frame as necessary. It will, when instructed, dynamically recalculate what vertices need to be shown and set those into the geometry array.

This is an abstract representation that renderer-specific items should be extending with their own geometry handling.

Version:
$Revision: 1.3 $
Author:
Justin Couch, Paul Byrne

Field Summary
protected  float maxY
          The maximum Y for this patch
protected  float minY
          The minimumY for this patch
protected  TreeNode NWTree
          The values of the nodes in the NW triangle of this patch
protected  int PATCH_SIZE
          The final size in number of grid points for this patch
protected  boolean resetRequested
          Flag to indicate if a clear has been requested
protected  TreeNode SETree
          The values of the nodes in the NW triangle of this patch
protected  TerrainData terrainData
          Source terrain data
protected  java.awt.Point tileOrigin
          The origin of the patch in tile coordinates
protected  VertexData vertexData
          Raw vertex collection information
protected  ViewFrustum viewFrustum
          The view frustum used for this terrain
 
Constructor Summary
protected ROAMPatch(TerrainData terrain, int patchSize, ViewFrustum frustum, int patchX, int patchY)
          Create a new patch based on the terrain and appearance information.
 
Method Summary
 void clear()
          Instruct this patch that it is about to be removed from active duty.
protected  void createGeometry()
          Create the geometry needed for this patch.
protected  void setOrigin(int xOrig, int yOrig)
          Setup this patch with new data from the terrain.
 java.lang.String toString2()
          Create a string representation of this patch.
abstract  void updateGeometry()
          Request an update to the geometry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PATCH_SIZE

protected final int PATCH_SIZE
The final size in number of grid points for this patch


NWTree

protected TreeNode NWTree
The values of the nodes in the NW triangle of this patch


SETree

protected TreeNode SETree
The values of the nodes in the NW triangle of this patch


tileOrigin

protected java.awt.Point tileOrigin
The origin of the patch in tile coordinates


terrainData

protected TerrainData terrainData
Source terrain data


viewFrustum

protected ViewFrustum viewFrustum
The view frustum used for this terrain


vertexData

protected VertexData vertexData
Raw vertex collection information


maxY

protected float maxY
The maximum Y for this patch


minY

protected float minY
The minimumY for this patch


resetRequested

protected boolean resetRequested
Flag to indicate if a clear has been requested

Constructor Detail

ROAMPatch

protected ROAMPatch(TerrainData terrain,
                    int patchSize,
                    ViewFrustum frustum,
                    int patchX,
                    int patchY)
Create a new patch based on the terrain and appearance information.

Parameters:
terrain - The raw height map info to use for this terrain
patchSize - The number of grid points to use in the patch on a side
frustum - The view frustum container used
Method Detail

updateGeometry

public abstract void updateGeometry()
Request an update to the geometry. If the geometry is visible then tell J3D that we would like to update the geometry. It does not directly do the update because we are using GeomByRef and so need to wait for the renderer to tell us when it is OK to do the updates.


clear

public void clear()
Instruct this patch that it is about to be removed from active duty. That means it should set all the geometry to be non-renderable, and clear all references to neightbours. It may be re-activated at some later stage.


setOrigin

protected void setOrigin(int xOrig,
                         int yOrig)
Setup this patch with new data from the terrain. The patch now exists in a different part of the world. After construction, this can be called at any time to set up the node for runtime use.

Parameters:
xOrig - The tileOrigin of the X grid coord for this patch in the global set of grid coordinates
yOrig - The tileOrigin of the Y grid coord for this patch in the global set of grid coordinates

createGeometry

protected void createGeometry()
Create the geometry needed for this patch. Just sets how many vertices are to be used based on the triangles of the two halves of the tree.


toString2

public java.lang.String toString2()
Create a string representation of this patch.

Returns:
A string representation of the patch

j3d.org Code

Latest Info from http://code.j3d.org/
Copyright © 2001 - j3d.org