org.xith3d.scenegraph
Class AbstractLODShape3D

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.AbstractLODShape3D
All Implemented Interfaces:
org.jagatoo.datatypes.NamableObject, org.jagatoo.datatypes.NamedObject, org.openmali.spatial.SpatialNode
Direct Known Subclasses:
LODShape3D

public abstract class AbstractLODShape3D
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, transformGroup, untransformedBounds
 
Fields inherited from class org.xith3d.scenegraph.SceneGraphObject
XITH3D_USERDATAKEY_OLDUSERDATA
 
Constructor Summary
AbstractLODShape3D()
          Constructs a new LODShape3D object with a null geometry component and a null appearance component.
AbstractLODShape3D(Geometry geometry)
          Constructs a new LODShape3D object with specified geometry component and a null appearance component.
AbstractLODShape3D(Geometry geometry, Appearance appearance)
          Constructs a new Shape3D object with specified geometry and appearance components.
 
Method Summary
protected  int addLOD(float minDist, float maxDist)
          Adds a new (unnamed) LOD (level of detail).
protected  int addLOD(java.lang.String name, float minDist, float maxDist)
          Adds a new LOD (level of detail).
protected  void copy(Shape3D dst)
          
 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  AbstractLODShape3D newInstance()
          
protected abstract  void onLODChanged(int oldLOD, int newLOD, java.lang.String name)
          This eveent is fired when the LOD has changed.
 AbstractLODShape3D sharedCopy()
          Creates a shared copy of this Node.
 AbstractLODShape3D 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, getCustomComparable, getGeometry, isBumpMappingEnabled, isShadowReceiver, isVisible, newAppearance, setAppearance, setBounds, setBumpMappingEnabled, setBumpMappingEnabled, setCustomComparable, setGeometry, setIsShadowReceiver, 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, setLive, 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

AbstractLODShape3D

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


AbstractLODShape3D

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


AbstractLODShape3D

public AbstractLODShape3D()
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

protected int 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

protected final int addLOD(float minDist,
                           float maxDist)
Adds a new (unnamed) LOD (level of detail).

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

newInstance

protected abstract AbstractLODShape3D newInstance()

Overrides:
newInstance in class Shape3D
Returns:
a new instance of this class. This is invoked by the sharedCopy() method.
See Also:
Shape3D.sharedCopy(CopyListener)

copy

protected void copy(Shape3D dst)

Overrides:
copy in class Shape3D

sharedCopy

public AbstractLODShape3D 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 AbstractLODShape3D 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)