j3d.org Code

org.j3d.terrain
Class Landscape

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

public abstract class Landscape
extends java.lang.Object
implements HeightMapGeometry

Representation of a piece of rendered terrain data.

The landscape is used to control what it rendered on screen as the user moves about the virtual environment. This instance does not need to maintain all the polygons on the screen at any one time, but may control them as needed.

This object is independent of the culling algorithm. It represents something that can be placed in a scenegraph and have view information passed to it without the need to know the specific algorithm in use. To implement a specific algorithm (eg ROAM) you would extend this class and implement the setView(Tuple3f, Vector3f) method. Every time that the scene changes, you will be notified by this method. That means you should perform any culling/LOD and update the scene graph at this point. This will be called at most once per frame.

If you are going to use this class with the navigation code, then you should also make the internal geometry not pickable, and make this item pickable. In this way, the navigation code will find this top-level terrain definition and use it directly to make the code much faster. None of these capabilities are set within this implementation, so it is up to the third-party code to make it so via calls to the appropriate methods.

The landscape provides an appearance generator for letting the end user application control appearance settings. If this is not set then particular implementation is free to do what it likes.

Internationalisation Resource Names

Version:
$Revision: 1.11 $
Author:
Justin Couch, based on original ideas from Paul Byrne

Field Summary
protected  ViewFrustum landscapeView
          The current viewing frustum that is seeing the landscape
protected  TerrainData terrainData
          Raw terrain information to be rendered
 
Constructor Summary
Landscape(ViewFrustum view, TerrainData data)
          Create a new Landscape with the set view and data.
 
Method Summary
 float getHeight(float x, float z)
          Get the height at the given X,Z coordinate in the local coordinate system.
abstract  void initialize(javax.vecmath.Tuple3f position, javax.vecmath.Vector3f direction)
          Initialise the landscape ready for viewing.
abstract  void setView(javax.vecmath.Tuple3f position, javax.vecmath.Vector3f direction)
          Set the current viewing direction for the user.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

landscapeView

protected ViewFrustum landscapeView
The current viewing frustum that is seeing the landscape


terrainData

protected TerrainData terrainData
Raw terrain information to be rendered

Constructor Detail

Landscape

public Landscape(ViewFrustum view,
                 TerrainData data)
Create a new Landscape with the set view and data. If either are not provided, an exception is thrown. Uses the default appearance generator.

Parameters:
view - The viewing frustum to see the data with
data - The raw data to view
Throws:
java.lang.IllegalArgumentException - either parameter is null
Method Detail

getHeight

public float getHeight(float x,
                       float z)
Get the height at the given X,Z coordinate in the local coordinate system. This implementation delegates to the underlying terrain data to do the real resolution.

Specified by:
getHeight in interface HeightDataSource
Parameters:
x - The x coordinate for the height sampling
z - The z coordinate for the height sampling
Returns:
The height at the current point or NaN

initialize

public abstract 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.

Parameters:
position - The position the user is in the virtual world
direction - The orientation of the user's gaze

setView

public abstract void setView(javax.vecmath.Tuple3f position,
                             javax.vecmath.Vector3f direction)
Set the current viewing direction for the user. The user is located at the given point and looking in the given direction. All information is assumed to be in world coordinates.

Parameters:
position - The position the user is in the virtual world
direction - The orientation of the user's gaze

j3d.org Code

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