com.jme.scene
Class DistanceSwitchModel

java.lang.Object
  extended bycom.jme.scene.DistanceSwitchModel
All Implemented Interfaces:
SwitchModel

public class DistanceSwitchModel
extends java.lang.Object
implements SwitchModel

DistanceSwitchModel defines a SwitchModel for selecting a child node based on the current distance from the containing node to the camera. This can be used with the DiscreteLodNode subclass of SwitchNode to all the detail level to decrease as the camera travels futher away from the object. The number of children to switch between is provided and the distances are also set. So, each child would have a minimum distance and a maximum distance. The child selected is the one that the camera to model distance is between the a particular child's min and max. If no values are valid, SN_INVALID_CHILD is returned.

Version:
$Id: DistanceSwitchModel.java,v 1.2 2004/03/13 18:07:56 mojomonkey Exp $
Author:
Mark Powell

Constructor Summary
DistanceSwitchModel(int numChildren)
          Constructor instantiates a new DistanceSwitchModel object with the number of children to select from.
 
Method Summary
 int getSwitchChild()
          getSwitchChild returns the index of the child that should be switched on.
 void set(java.lang.Object value)
          set accepts Float and Vector3f objects to set the properties of the distance switch model.
 void setModelDistance(int index, float minDist, float maxDist)
          setModelDistance sets the minimum and maximum distance that a particular child should be used.
 void setModelMaxDistance(int index, float maxDist)
          setModelMaxDistance sets the maximum distance that a particular child should be used.
 void setModelMinDistance(int index, float minDist)
          setModelMinDistance sets the minimum distance that a particular child should be used.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DistanceSwitchModel

public DistanceSwitchModel(int numChildren)
Constructor instantiates a new DistanceSwitchModel object with the number of children to select from.

Parameters:
numChildren - the number of children this model selects from.
Method Detail

setModelMinDistance

public void setModelMinDistance(int index,
                                float minDist)
setModelMinDistance sets the minimum distance that a particular child should be used.

Parameters:
index - the index of the child.
minDist - the minimum of this child.

setModelMaxDistance

public void setModelMaxDistance(int index,
                                float maxDist)
setModelMaxDistance sets the maximum distance that a particular child should be used.

Parameters:
index - the index of the child.
maxDist - the maximum of this child.

setModelDistance

public void setModelDistance(int index,
                             float minDist,
                             float maxDist)
setModelDistance sets the minimum and maximum distance that a particular child should be used.

Parameters:
index - the index of the child.
minDist - the minimum of this child.
maxDist - the maximum of this child.

set

public void set(java.lang.Object value)
set accepts Float and Vector3f objects to set the properties of the distance switch model. If the value passed is a Float object, this value is used to determine the world scale (squared) value, which allows the adjustment of the min and max distances for switching. If the value passed is a Vector3f, that is used to set the difference of the switch node and a comparison point which is typically the camera location.

Specified by:
set in interface SwitchModel
Parameters:
value - either Float - the world scale squared value, or Vector3f - the difference between the switch node and a location.

getSwitchChild

public int getSwitchChild()
getSwitchChild returns the index of the child that should be switched on. The current distance between the parent switch node and a supplied point is used to determine the valid child.

Specified by:
getSwitchChild in interface SwitchModel
Returns:
the index of the valid child.