Aviatrix3D
2.1.0

org.j3d.renderer.aviatrix3d.geom.volume
Class OctTree

java.lang.Object
  extended by org.j3d.aviatrix3d.SceneGraphObject
      extended by org.j3d.aviatrix3d.Node
          extended by org.j3d.aviatrix3d.BaseNode
              extended by org.j3d.renderer.aviatrix3d.geom.volume.OctTree
All Implemented Interfaces:
Cullable, CustomCullable, TransformHierarchy

public class OctTree
extends BaseNode
implements CustomCullable, TransformHierarchy

Node that implements a simple OctTree-style data structure useful for volume rendering of large datasets.

The core implementation is a fairly simplistic distance-based algorithm to determine when the level sets should be changed over. The class uses a single Node object for the low-detail model, and allows the provision of a set of nodes for the next detail level, allowing for nesting of the tree objects if required.

For describing the high-detail geometry, there is no specific geometric representation implied by this node. There are just up to 8 children that can be supplied, and that the user should make sure to place them in the correct octant location using transformations as required.

For bounds calculation, the bounds of the low-res model are used.

Version:
$Revision: 1.7 $
Author:
Justin Couch

Field Summary
 
Fields inherited from class org.j3d.aviatrix3d.Node
bounds, implicitBounds, INVALID_BOUNDS, parent
 
Fields inherited from class org.j3d.aviatrix3d.SceneGraphObject
alive, LISTENER_SET_TIMING_ERR_PROP, updateHandler
 
Constructor Summary
OctTree()
          Create a new empty instance of the oct tree.
 
Method Summary
protected  void checkForCyclicChild(SceneGraphObject parent)
          Check to see if this node is the same reference as the passed node that is a parent of this node.
 void cullChildren(CullInstructions output, javax.vecmath.Matrix4f vworldTx, javax.vecmath.Matrix4f viewTransform, javax.vecmath.Vector4f[] frustumPlanes, float angularRes)
          Check this node for children to traverse.
 void getHighDetail(Node[] geom)
          Get the currently set low-detail geometry structure.
 Node getLowDetail()
          Get the currently set low-detail geometry structure.
 float getRange()
          Get the currently set range at which the high detail model will be shown.
 int numHighDetailGeom()
          Get the number of valid high-detail children in use by this node.
protected  void recomputeBounds()
          Internal method to recalculate the implicit bounds of this Node.
 void requestBoundsUpdate()
          Request a recomputation of the bounds of this object.
 void setHighDetail(Node[] geom, int numValid)
          Set the low-detail geometry instance to use.
protected  void setLive(boolean state)
          Notification that this object is live now.
 void setLowDetail(Node geom)
          Set the low-detail geometry instance to use.
 void setRange(float distance)
          Set the range at which this geometry should change from low-detail to high-detail models.
protected  void setUpdateHandler(NodeUpdateHandler handler)
          Set the scenegraph update handler for this node.
 
Methods inherited from class org.j3d.aviatrix3d.BaseNode
checkForCyclicChild, checkForCyclicParent, clearUpdateHandler, removeParent, setLive, setParent, setUpdateHandler
 
Methods inherited from class org.j3d.aviatrix3d.Node
boundsChanged, checkForCyclicParent, getBounds, getParent, markBoundsDirty, removeParent, setBounds, setParent, updateBounds, updateParentBounds
 
Methods inherited from class org.j3d.aviatrix3d.SceneGraphObject
dataChanged, getAppUpdateWriteTimingMessage, getBoundsWriteTimingMessage, getDataWriteTimingMessage, getUserData, isLive, setUserData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OctTree

public OctTree()
Create a new empty instance of the oct tree. The range is set to zero, meaning it will always display the low res data, unless the user changes the range.

Method Detail

cullChildren

public void cullChildren(CullInstructions output,
                         javax.vecmath.Matrix4f vworldTx,
                         javax.vecmath.Matrix4f viewTransform,
                         javax.vecmath.Vector4f[] frustumPlanes,
                         float angularRes)
Check this node for children to traverse. The angular resolution is defined as Field Of View (in radians) / viewport width in pixels.

Specified by:
cullChildren in interface CustomCullable
Parameters:
output - Fill in the child information here
vworldTx - The transformation from the root of the scene to this node according to the current traversal path
viewTransform - The transformation from the root of the scene graph to the active viewpoint
frustumPlanes - Listing of frustum planes in the order: right, left, bottom, top, far, near
angularRes - Angular resolution of the screen, or 0 if not calculable from the available data.

recomputeBounds

protected void recomputeBounds()
Internal method to recalculate the implicit bounds of this Node. By default the bounds are a point sphere, so derived classes should override this method with something better.

Overrides:
recomputeBounds in class Node

requestBoundsUpdate

public void requestBoundsUpdate()
Request a recomputation of the bounds of this object. If this object is not currently live, you can request a recompute of the bounds to get the most current values. If this node is currently live, then the request is ignored.

This will recurse down the children asking all of them to recompute the bounds. If a child is found to be during this process, that branch will not update, and thus the value used will be the last updated (ie from the previous frame it was processed).

Overrides:
requestBoundsUpdate in class Node

checkForCyclicChild

protected void checkForCyclicChild(SceneGraphObject parent)
                            throws CyclicSceneGraphStructureException
Check to see if this node is the same reference as the passed node that is a parent of this node. This is the downwards check to ensure that there is no cyclic scene graph structures at the point where someone adds a node to the scenegraph. When the reference and this are the same, an exception is generated. Since each class may have different lists of child node setups, this should be overriden by any class that can take children, and have the call passed along to the children.

Overrides:
checkForCyclicChild in class SceneGraphObject
Parameters:
parent - The reference to check against this class
Throws:
CyclicSceneGraphStructureException - Equal parent and child

setUpdateHandler

protected void setUpdateHandler(NodeUpdateHandler handler)
Set the scenegraph update handler for this node. It will notify all its children of the value. A null value will clear the current handler.

Overrides:
setUpdateHandler in class SceneGraphObject
Parameters:
handler - The instance to use as a handler

setLive

protected void setLive(boolean state)
Notification that this object is live now.

Overrides:
setLive in class SceneGraphObject
Parameters:
state - true if this should be marked as live now

setRange

public void setRange(float distance)
              throws java.lang.IllegalArgumentException,
                     InvalidWriteTimingException
Set the range at which this geometry should change from low-detail to high-detail models. The range should be a non-negative value. A range value of zero will imply that the low detail geometry will always be shown. Range is treated as a spherical distance from the center of the local coordinate system of this geometry.

Parameters:
distance - The range at which the geometry should swap
Throws:
java.lang.IllegalArgumentException - The range value was negative
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener bounds changed callback method

getRange

public float getRange()
Get the currently set range at which the high detail model will be shown.

Returns:
A non-negative range value

setLowDetail

public void setLowDetail(Node geom)
                  throws InvalidWriteTimingException
Set the low-detail geometry instance to use. Setting a null value will clear the currently set geometry. The low detail can be any form of scene graph desired.

Parameters:
geom - The sub scene graph to use for the low-detail geometry
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener bounds changed callback method

getLowDetail

public Node getLowDetail()
Get the currently set low-detail geometry structure. If none is set, null is returned.

Returns:
The current geometry structure or null

setHighDetail

public void setHighDetail(Node[] geom,
                          int numValid)
                   throws InvalidWriteTimingException
Set the low-detail geometry instance to use. Setting a null value will clear the currently set geometry. The low detail can be any form of scene graph desired.

Parameters:
geom - The sub scene graph list to use for the high-detail geometry
numValid - The number of valid bits of geometry to use from the array
Throws:
java.lang.IllegalArgumentException - numValid was outside [0, 8]
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener bounds changed callback method

numHighDetailGeom

public int numHighDetailGeom()
Get the number of valid high-detail children in use by this node.

Returns:
A number between 0 and 8

getHighDetail

public void getHighDetail(Node[] geom)
Get the currently set low-detail geometry structure. If none is set, null is returned.

Parameters:
geom - An array to copy the values into

Aviatrix3D
2.1.0

Latest Info from http://aviatrix3d.j3d.org/
Copyright © 2003 - 2009 j3d.org