org.xith3d.scenegraph
Class LODShape3D

java.lang.Object
  extended by org.xith3d.scenegraph.SceneGraphObject
      extended by org.xith3d.scenegraph.Node
          extended by org.xith3d.scenegraph.Leaf
              extended by org.xith3d.scenegraph.Shape3D
                  extended by org.xith3d.scenegraph.LODShape3D
All Implemented Interfaces:
org.jagatoo.datatypes.NamableObject, org.jagatoo.datatypes.NamedObject, org.openmali.spatial.SpatialNode

public abstract class LODShape3D
extends Shape3D

The LODShape3D is a Shape3D Node extension, that handles discrete LOD. Discrete LOD (level of detail) is a technique, that selects an item depending on its distance to the camera.

See Also:
LODSwitch

Field Summary
 
Fields inherited from class org.xith3d.scenegraph.Node
bounds, boundsAutoCompute, boundsDirty, globalIgnoreBounds, instanceBoundsTypeHint, parent, transformGroup, untransformedBounds
 
Fields inherited from class org.xith3d.scenegraph.SceneGraphObject
XITH3D_USERDATAKEY_OLDUSERDATA
 
Constructor Summary
LODShape3D()
          Constructs a new LODShape3D object with a null geometry component and a null appearance component.
LODShape3D(Geometry geometry)
          Constructs a new LODShape3D object with specified geometry component and a null appearance component.
LODShape3D(Geometry geometry, Appearance appearance)
          Constructs a new Shape3D object with specified geometry and appearance components.
 
Method Summary
 void addLOD(float minDist, float maxDist)
          Adds a new (unnamed) LOD (level of detail).
 void addLOD(java.lang.String name, float minDist, float maxDist)
          Adds a new LOD (level of detail).
 java.lang.String getLODName(int lod)
          Returns the name of the LOD with the given index.
 float getMaxDist(int index)
           
 float getMinDist(int index)
           
 int getNumLODs()
           
protected abstract  void onLODChanged(int oldLOD, int newLOD, java.lang.String name)
          This eveent is fired when the LOD has changed.
 LODShape3D sharedCopy()
          Creates a shared copy of this Node.
 LODShape3D sharedCopy(CopyListener listener)
          Creates a shared copy of this Node.
 void updateLOD(org.openmali.vecmath2.Point3f viewPosition)
          Called by the Renderer to make the LODSwitch select the right item for the given view position.
 
Methods inherited from class org.xith3d.scenegraph.Shape3D
absorbDetails, freeOpenGLResources, getAppearance, getAppearance, getGeometry, isBumpMappingEnabled, isShadowReceiver, isVisible, newAppearance, setAppearance, setBounds, setBumpMappingEnabled, setBumpMappingEnabled, setGeometry, setIsShadowReceiver, setLive, setModListener, setVisible, traverse, updateBounds, updateBoundsCheap, updateWorldTransform, verifyAppChange
 
Methods inherited from class org.xith3d.scenegraph.Leaf
dump, getPickHost, setPickHost
 
Methods inherited from class org.xith3d.scenegraph.Node
cloneNode, detach, duplicateNode, freeOpenGLResources, getBounds, getBoundsAutoCompute, getBoundsType, getBoundsTypeHint, getDefaultPickable, getIndentString, getInheritedNodeAttributes, getModListener, getOrderedChild, getOrderedState, getParent, getRoot, getShadowAttachment, getShowBounds, getTransformGroup, getTreeCell, getWorldBounds, getWorldTransform, getWorldTransform, isBillboard, isIgnoreBounds, isOccluder, isPickable, isRenderable, isUpdatableNode, mergeInheritedClipper, mergeInheritedNodes, mergeInheritedScissorRect, popGlobalIgnoreBounds, printBounds, pushGlobalIgnoreBounds, setBoundsAutoCompute, setBoundsDirty, setBoundsDirtyUpward, setBoundsTypeHint, setDefaultPickable, setGlobalIgnoreBounds, setIgnoreBounds, setIsOccluder, setOrderedChild, setParent, setPickable, setPickableRecursive, setPickableRecursive, setRenderable, setShadowAttachment, setShowBounds, setTransformGroup, setTreeCell, traverse, unmergeInheritedFog, unmergeInheritedLight, unmergeInheritedNodes, updateOrderedChild, updateTransformGroup
 
Methods inherited from class org.xith3d.scenegraph.SceneGraphObject
getName, getUserData, getUserData, getUserDataMap, isLive, setName, setUserData, setUserData, setUserDataRecursive, setUserDataRecursive, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LODShape3D

public LODShape3D(Geometry geometry,
                  Appearance appearance)
Constructs a new Shape3D object with specified geometry and appearance components.


LODShape3D

public LODShape3D(Geometry geometry)
Constructs a new LODShape3D object with specified geometry component and a null appearance component.


LODShape3D

public LODShape3D()
Constructs a new LODShape3D object with a null geometry component and a null appearance component.

Method Detail

getMinDist

public final float getMinDist(int index)
Parameters:
index - the index of the LOD item of interest
Returns:
the minimal distance of the LOD item

getMaxDist

public final float getMaxDist(int index)
Parameters:
index - the index of the LOD item of interest
Returns:
the maximal distance of the LOD item

getLODName

public final java.lang.String getLODName(int lod)
Returns the name of the LOD with the given index.

Parameters:
lod - the LOD, for which the name is requested
Returns:
the name of the given LOD

getNumLODs

public final int getNumLODs()
Returns:
the number of LODs

onLODChanged

protected abstract void onLODChanged(int oldLOD,
                                     int newLOD,
                                     java.lang.String name)
This eveent is fired when the LOD has changed.
This is always done by the redner thread.

Parameters:
oldLOD - the old LOD
newLOD - the new LOD
name - the name of the new LOD

updateLOD

public void updateLOD(org.openmali.vecmath2.Point3f viewPosition)
Called by the Renderer to make the LODSwitch select the right item for the given view position.


addLOD

public void addLOD(java.lang.String name,
                   float minDist,
                   float maxDist)
Adds a new LOD (level of detail).

Parameters:
name - the name of the new LOD
minDist - the minimum distance
maxDist - the maximum distance

addLOD

public void addLOD(float minDist,
                   float maxDist)
Adds a new (unnamed) LOD (level of detail).

Parameters:
minDist - the minimum distance
maxDist - the maximum distance

sharedCopy

public LODShape3D sharedCopy(CopyListener listener)
Creates a shared copy of this Node. A shared copy is one where the geometry and appearance is shared, but everything else is copied. This is a replacement for shared groups because of performance considerations. If you are loading the same model many times then this can save on memory and load times. The only allowable within the subtree are groups and shapes. This also copies a shapes bounds and turns autocomute off so that it is fast to insert the model into the scene.

Overrides:
sharedCopy in class Shape3D
Returns:
a shared copy of this Node
See Also:
Node.absorbDetails(Node)

sharedCopy

public LODShape3D sharedCopy()
Creates a shared copy of this Node. A shared copy is one where the geometry and appearance is shared, but everything else is copied. This is a replacement for shared groups because of performance considerations. If you are loading the same model many times then this can save on memory and load times. The only allowable within the subtree are groups and shapes. This also copies a shapes bounds and turns autocomute off so that it is fast to insert the model into the scene.

Overrides:
sharedCopy in class Shape3D
Returns:
a shared copy of this Node
See Also:
Node.absorbDetails(Node)