j3d.org Code

org.j3d.terrain.roam
Class ROAMSplitMergeLandscape

java.lang.Object
  extended by org.j3d.terrain.Landscape
      extended by org.j3d.terrain.roam.ROAMSplitMergeLandscape
All Implemented Interfaces:
HeightDataSource, HeightMapGeometry

public abstract class ROAMSplitMergeLandscape
extends Landscape

ROAM implmentation of a landscape using the split-merge combination algorithm.

First patch is at 0,0 in x, z and then patches are laid out along the +ve x axis and the -ve z axis

Internationalisation Resource Names

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

Field Summary
protected  int patchSize
          The patch size to use for this landscape
 
Fields inherited from class org.j3d.terrain.Landscape
landscapeView, terrainData
 
Constructor Summary
ROAMSplitMergeLandscape(ViewFrustum view, TerrainData data)
          Creates new Landscape based on the view information and the terrain data.
ROAMSplitMergeLandscape(ViewFrustum view, TerrainData data, int patchSize)
          Creates new Landscape based on the view information and static terrain data, with a controlable patch size.
 
Method Summary
protected abstract  void addPatch(ROAMPatch patch)
          Add the newly created patch to the renderer specific structures.
protected abstract  ROAMPatch createPatch(int eastPosition, int northPosition, int xTile, int yTile)
          Create a new patch object instance that is located at the given position within the tile.
 void initialize(javax.vecmath.Tuple3f position, javax.vecmath.Vector3f direction)
          Initialise the landscape ready for viewing.
 void setView(javax.vecmath.Tuple3f position, javax.vecmath.Vector3f direction)
          Change the view of the landscape.
protected abstract  void updatePatch(ROAMPatch patch, int xTile, int yTile)
          Update the patch representation to be at the new tile location.
 
Methods inherited from class org.j3d.terrain.Landscape
getHeight
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

patchSize

protected final int patchSize
The patch size to use for this landscape

Constructor Detail

ROAMSplitMergeLandscape

public ROAMSplitMergeLandscape(ViewFrustum view,
                               TerrainData data)
Creates new Landscape based on the view information and the terrain data. If the terrain data is based on static data, the terrain is built using the default patch size.

Parameters:
view - The view frustum looking at this landscape
data - The raw data for the terrain
Throws:
java.lang.IllegalArgumentException - The static grid is not n^2 + 1 in size

ROAMSplitMergeLandscape

public ROAMSplitMergeLandscape(ViewFrustum view,
                               TerrainData data,
                               int patchSize)
Creates new Landscape based on the view information and static terrain data, with a controlable patch size. The patch size must be a power of two. If the terrain data object provides tiled terrain, the patchSize request is ignored. The patchSize must be a power of two, otherwise an exception will be thrown.

Parameters:
view - The view frustum looking at this landscape
data - The raw data for the terrain
patchSize - The number of grid points per patch side, power 2.
Throws:
java.lang.IllegalArgumentException - The patchSize was < 0 or not a power of two.
Method Detail

initialize

public void initialize(javax.vecmath.Tuple3f position,
                       javax.vecmath.Vector3f direction)
Initialise the landscape ready for viewing. This should be called before you add the parent branchgroup to the live scenegraph as the implementation code will need to construct the renderable scene graph. It also sets the initial position so that if the terrain is using tilable datasets it can determine where to start building from.

Specified by:
initialize in class Landscape
Parameters:
position - The position the user is in the virtual world
direction - The orientation of the user's gaze

setView

public void setView(javax.vecmath.Tuple3f position,
                    javax.vecmath.Vector3f direction)
Change the view of the landscape. The virtual camera is now located in this position and orientation, so adjust the visible terrain to accommodate the changes.

Specified by:
setView in class Landscape
Parameters:
position - The position of the camera
direction - The direction the camera is looking

createPatch

protected abstract ROAMPatch createPatch(int eastPosition,
                                         int northPosition,
                                         int xTile,
                                         int yTile)
Create a new patch object instance that is located at the given position within the tile.

Parameters:
eastPosition - The east coordinate of the patch
northPosition - The north coordinate of the patch
xTile - The tile coordinate of the patch along the X axis
yTile - The tile coordinate of the patch along the Y axis

updatePatch

protected abstract void updatePatch(ROAMPatch patch,
                                    int xTile,
                                    int yTile)
Update the patch representation to be at the new tile location. This will me replacing the existing texture with a new texture.

Parameters:
patch - The patch instance to update
xTile - The new tile coordinate of the patch along the X axis
yTile - The new tile coordinate of the patch along the Y axis

addPatch

protected abstract void addPatch(ROAMPatch patch)
Add the newly created patch to the renderer specific structures. All the ROAM-specific initialization is complete, so just handle the rendering items now.


j3d.org Code

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