com.jme.scene
Class SwitchNode

java.lang.Object
  extended bycom.jme.scene.Spatial
      extended bycom.jme.scene.Node
          extended bycom.jme.scene.SwitchNode
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
DiscreteLodNode

public class SwitchNode
extends Node

SwitchNode defines a node that maintains a single active child at a time. This allows the instantanious switching of children depending on any number of factors. For example, multiple levels of detail models can be loaded into the switch node and the active model can be set depending on the distance from the camera.

Version:
$Id: SwitchNode.java,v 1.5 2005/03/11 23:27:35 Mojomonkey Exp $
Author:
Mark Powell
See Also:
Serialized Form

Field Summary
static int SN_INVALID_CHILD
          defines an inactive or invalid child.
 
Fields inherited from class com.jme.scene.Node
children
 
Fields inherited from class com.jme.scene.Spatial
currentStates, defaultStateList, forceCull, forceView, frustrumIntersects, geometricalControllers, lightCombineMode, localRotation, localScale, localTranslation, name, parent, queueDistance, renderQueueMode, renderStateList, textureCombineMode, worldBound, worldRotation, worldScale, worldTranslation, zOrder
 
Constructor Summary
SwitchNode(java.lang.String name)
          Constructor instantiates a new SwitchNode object.
 
Method Summary
 void disableAllChildren()
          Marks the node to render nothing on a draw.
 void draw(Renderer r)
          If a valid active child is set, that child is rendered and none others.
 int getActiveChild()
          Returns the index of the currently rendered child for this Node.
 void setActiveChild(int child)
          Sets the index of the child of this Node that will be rendered.
 
Methods inherited from class com.jme.scene.Node
applyRenderState, attachChild, detachAllChildren, detachChild, detachChildAt, detachChildNamed, drawBounds, findCollisions, findPick, getChild, getChild, getChildren, getQuantity, hasChild, hasCollision, putClone, setChild, setForceView, updateCollisionTree, updateWorldBound, updateWorldData
 
Methods inherited from class com.jme.scene.Spatial
addController, applyDefaultStates, calculateCollisions, calculatePick, clearCurrentState, clearCurrentStates, clearRenderState, getController, getControllers, getCurrentState, getLastFrustumIntersection, getLightCombineMode, getLocalRotation, getLocalScale, getLocalTranslation, getName, getParent, getRenderQueueMode, getRenderStateList, getTextureCombineMode, getWorldBound, getWorldRotation, getWorldScale, getWorldTranslation, getZOrder, isForceCulled, isForceView, onDraw, onDrawBounds, propagateBoundToRoot, propagateStatesFromRoot, removeController, removeFromParent, setForceCull, setLightCombineMode, setLocalRotation, setLocalRotation, setLocalScale, setLocalScale, setLocalTranslation, setName, setParent, setRenderQueueMode, setRenderState, setTextureCombineMode, setWorldBound, setZOrder, toString, updateGeometricState, updateRenderState, updateRenderState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SN_INVALID_CHILD

public static final int SN_INVALID_CHILD
defines an inactive or invalid child.

See Also:
Constant Field Values
Constructor Detail

SwitchNode

public SwitchNode(java.lang.String name)
Constructor instantiates a new SwitchNode object. The name of the node is provided during construction.

Parameters:
name - the name of the node.
Method Detail

getActiveChild

public int getActiveChild()
Returns the index of the currently rendered child for this Node.

Returns:
The currently active child.

setActiveChild

public void setActiveChild(int child)
Sets the index of the child of this Node that will be rendered. If the index is <0 or >getQuantity then nothing is rendered.

Parameters:
child - The child index of this node it should render.

disableAllChildren

public void disableAllChildren()
Marks the node to render nothing on a draw.


draw

public void draw(Renderer r)
If a valid active child is set, that child is rendered and none others. This function should be called internally only.

Overrides:
draw in class Node
Parameters:
r - The render system to draw the child.
See Also:
Spatial.draw(com.jme.renderer.Renderer)