j3d.org Code

org.j3d.renderer.java3d.terrain.roam
Class J3DSplitMergeLandscape

java.lang.Object
  extended byorg.j3d.terrain.Landscape
      extended byorg.j3d.terrain.roam.ROAMSplitMergeLandscape
          extended byorg.j3d.renderer.java3d.terrain.roam.J3DSplitMergeLandscape
All Implemented Interfaces:
HeightDataSource, HeightMapGeometry, J3DLandscape

public class J3DSplitMergeLandscape
extends ROAMSplitMergeLandscape
implements J3DLandscape

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

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

Field Summary
 
Fields inherited from class org.j3d.terrain.roam.ROAMSplitMergeLandscape
patchSize
 
Fields inherited from class org.j3d.terrain.Landscape
landscapeView, terrainData
 
Constructor Summary
J3DSplitMergeLandscape(ViewFrustum view, TerrainData data)
          Creates new Landscape based on the view information and the terrain data.
J3DSplitMergeLandscape(ViewFrustum view, TerrainData data, AppearanceGenerator gen)
          Provide a landscape with a specific appearance generator set.
J3DSplitMergeLandscape(ViewFrustum view, TerrainData data, int patchSize)
          Creates new Landscape based on the view information and static terrain data, with a controlable patch size.
J3DSplitMergeLandscape(ViewFrustum view, TerrainData data, int patchSize, AppearanceGenerator gen)
          Provide a landscape with a specific appearance generator set.
 
Method Summary
protected  void addPatch(ROAMPatch patch)
          Add the newly created patch to the renderer specific structures.
protected  ROAMPatch createPatch(int x, int y, int xTile, int yTile)
          Create a new patch object instance that is located at the given position within the tile.
 AppearanceGenerator getAppearanceGenerator()
          Get the currently set appearance generator.
 javax.media.j3d.BranchGroup getSceneGraphObject()
          Get the geometry group that this terrain is being rendered to.
 void setAppearanceGenerator(AppearanceGenerator gen)
          Set the appearance generator to create new appearanace items.
 void setView(javax.media.j3d.Transform3D t3d)
          Set the current view location information based on a transform matrix.
 void transitionEnded(javax.media.j3d.Transform3D t3d)
          The transition from one point to another is completed.
protected  void updatePatch(ROAMPatch patch, int xTile, int yTile)
          Update the patch representation to be at the new tile location.
 void viewerPositionUpdated(javax.media.j3d.Transform3D t3d)
          The frame has just been updated with the latest view information.
 
Methods inherited from class org.j3d.terrain.roam.ROAMSplitMergeLandscape
initialize, setView
 
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
 

Constructor Detail

J3DSplitMergeLandscape

public J3DSplitMergeLandscape(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

J3DSplitMergeLandscape

public J3DSplitMergeLandscape(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.

J3DSplitMergeLandscape

public J3DSplitMergeLandscape(ViewFrustum view,
                              TerrainData data,
                              AppearanceGenerator gen)
Provide a landscape with a specific appearance generator set. If the generator argument is null, then the default is used.

Parameters:
view - The viewing frustum to see the data with
data - The raw data to view
gen - The generator instance to use
Throws:
java.lang.IllegalArgumentException - either parameter is null
java.lang.IllegalArgumentException - The patchSize was < 0 or not a power of two.

J3DSplitMergeLandscape

public J3DSplitMergeLandscape(ViewFrustum view,
                              TerrainData data,
                              int patchSize,
                              AppearanceGenerator gen)
Provide a landscape with a specific appearance generator set. If the generator argument is null, then the default is used.

Parameters:
view - The viewing frustum to see the data with
data - The raw data to view
gen - The generator instance to use
patchSize - The number of grid points per patch side, power 2.
Throws:
java.lang.IllegalArgumentException - either parameter is null
java.lang.IllegalArgumentException - The patchSize was < 0 or not a power of two.
Method Detail

transitionEnded

public void transitionEnded(javax.media.j3d.Transform3D t3d)
The transition from one point to another is completed. Use this to update the transformation.

Parameters:
t3d - The position of the final viewpoint

viewerPositionUpdated

public void viewerPositionUpdated(javax.media.j3d.Transform3D t3d)
The frame has just been updated with the latest view information. Update the landscape rendered values now.

Parameters:
t3d - The position of the viewpoint now

setView

public void setView(javax.media.j3d.Transform3D t3d)
Set the current view location information based on a transform matrix. Only the position and orientation information are extracted from this matrix. Any shear or scale is ignored. Effectively, this transform should be the view transform (particularly if you are using navigation code from this codebase in the org.j3d.ui.navigation package.

Specified by:
setView in interface J3DLandscape
Parameters:
t3d - The transform to use as the view position

setAppearanceGenerator

public void setAppearanceGenerator(AppearanceGenerator gen)
Set the appearance generator to create new appearanace items. If null is passed, it clears the current appearance settings

Specified by:
setAppearanceGenerator in interface J3DLandscape
Parameters:
gen - The new generator instance to use

getAppearanceGenerator

public AppearanceGenerator getAppearanceGenerator()
Get the currently set appearance generator. If not set, returns null.

Specified by:
getAppearanceGenerator in interface J3DLandscape
Returns:
The current generator instance

getSceneGraphObject

public javax.media.j3d.BranchGroup getSceneGraphObject()
Get the geometry group that this terrain is being rendered to.

Specified by:
getSceneGraphObject in interface J3DLandscape
Returns:
The parent group for all the terrain

createPatch

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

Specified by:
createPatch in class ROAMSplitMergeLandscape
Parameters:
x - The east coordinate of the patch
y - 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 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.

Specified by:
updatePatch in class ROAMSplitMergeLandscape
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 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.

Specified by:
addPatch in class ROAMSplitMergeLandscape

j3d.org Code

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