j3d.org Code

org.j3d.renderer.java3d.terrain
Class J3DAbstractLandscape

java.lang.Object
  extended byorg.j3d.terrain.Landscape
      extended byorg.j3d.renderer.java3d.terrain.J3DAbstractLandscape
All Implemented Interfaces:
FrameUpdateListener, HeightDataSource, HeightMapGeometry, J3DLandscape

public abstract class J3DAbstractLandscape
extends Landscape
implements FrameUpdateListener, J3DLandscape

Representation of a Java3D-specific additional interfaces to the basic Landscape interface.

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 Landscape.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.

For convenience, this class also implements FrameUpdateListener from the org.j3d.ui.navigation package so that you can have fast, quick navigation implementation in your code. If you wish to use your own custom user input code, then there is no penalty for doing so. Simply call one of the setView() methods directly with the transformation information.

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.

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

Field Summary
protected  AppearanceGenerator appearanceGenerator
          Generator for appearance information.
protected  javax.media.j3d.BranchGroup rootGroup
          Geometry used to represent this terrain at the J3D level
 
Fields inherited from class org.j3d.terrain.Landscape
landscapeView, terrainData
 
Constructor Summary
J3DAbstractLandscape(ViewFrustum view, TerrainData data)
          Create a new Landscape with the set view and data.
J3DAbstractLandscape(ViewFrustum view, TerrainData data, AppearanceGenerator gen)
          Provide a landscape with a specific appearance generator set.
 
Method Summary
 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.
 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.Landscape
getHeight, initialize, setView
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

appearanceGenerator

protected AppearanceGenerator appearanceGenerator
Generator for appearance information. May be null


rootGroup

protected javax.media.j3d.BranchGroup rootGroup
Geometry used to represent this terrain at the J3D level

Constructor Detail

J3DAbstractLandscape

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

J3DAbstractLandscape

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

Specified by:
transitionEnded in interface FrameUpdateListener
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.

Specified by:
viewerPositionUpdated in interface FrameUpdateListener
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

j3d.org Code

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