Package javax.media.j3d
Class Switch
java.lang.Object
javax.media.j3d.SceneGraphObject
javax.media.j3d.Node
javax.media.j3d.Group
javax.media.j3d.Switch
The Switch node controls which of its children will be rendered.
It defines a child selection value (a switch value) that can either
select a single child, or it can select 0 or more children using a
mask to indicate which children are selected for rendering.
The Switch node contains an ordered list of children, but the
index order of the children in the list is only used for selecting
the appropriate child or children and does not specify rendering
order.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Specifies that this node allows reading its child selection and mask values and its current child.static final int
Specifies that this node allows writing its child selection and mask values.static final int
Specifies that all children are rendered.static final int
Specifies that the childMask BitSet is used to select which children are rendered.static final int
Specifies that no children are rendered.Fields inherited from class javax.media.j3d.Group
ALLOW_CHILDREN_EXTEND, ALLOW_CHILDREN_READ, ALLOW_CHILDREN_WRITE, ALLOW_COLLISION_BOUNDS_READ, ALLOW_COLLISION_BOUNDS_WRITE
Fields inherited from class javax.media.j3d.Node
ALLOW_AUTO_COMPUTE_BOUNDS_READ, ALLOW_AUTO_COMPUTE_BOUNDS_WRITE, ALLOW_BOUNDS_READ, ALLOW_BOUNDS_WRITE, ALLOW_COLLIDABLE_READ, ALLOW_COLLIDABLE_WRITE, ALLOW_LOCAL_TO_VWORLD_READ, ALLOW_LOCALE_READ, ALLOW_PARENT_READ, ALLOW_PICKABLE_READ, ALLOW_PICKABLE_WRITE, ENABLE_COLLISION_REPORTING, ENABLE_PICK_REPORTING
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncloneNode
(boolean forceDuplicate) Used to create a new instance of the node.Retrieves the currently selected child.Retrieves the current child selection mask.int
Retrieves the current child selection index that specifies which child is rendered.void
setChildMask
(BitSet childMask) Sets the child selection mask.void
setWhichChild
(int child) Sets the child selection index that specifies which child is rendered.Methods inherited from class javax.media.j3d.Group
addChild, getAllChildren, getAlternateCollisionTarget, getChild, getCollisionBounds, indexOfChild, insertChild, moveTo, numChildren, removeAllChildren, removeChild, removeChild, setAlternateCollisionTarget, setChild, setCollisionBounds
Methods inherited from class javax.media.j3d.Node
cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, duplicateNode, getBounds, getBoundsAutoCompute, getCollidable, getLocale, getLocalToVworld, getLocalToVworld, getParent, getPickable, setBounds, setBoundsAutoCompute, setCollidable, setPickable
Methods inherited from class javax.media.j3d.SceneGraphObject
clearCapability, clearCapabilityIsFrequent, duplicateSceneGraphObject, getCapability, getCapabilityIsFrequent, getName, getUserData, isCompiled, isLive, setCapability, setCapabilityIsFrequent, setName, setUserData, toString, updateNodeReferences
-
Field Details
-
ALLOW_SWITCH_READ
public static final int ALLOW_SWITCH_READSpecifies that this node allows reading its child selection and mask values and its current child.- See Also:
-
ALLOW_SWITCH_WRITE
public static final int ALLOW_SWITCH_WRITESpecifies that this node allows writing its child selection and mask values.- See Also:
-
CHILD_NONE
public static final int CHILD_NONESpecifies that no children are rendered. This value may be used in place of a non-negative child selection index.- See Also:
-
CHILD_ALL
public static final int CHILD_ALLSpecifies that all children are rendered. This setting causes the switch node to function as an ordinary group node. This value may be used in place of a non-negative child selection index.- See Also:
-
CHILD_MASK
public static final int CHILD_MASKSpecifies that the childMask BitSet is used to select which children are rendered. This value may be used in place of a non-negative child selection index.- See Also:
-
-
Constructor Details
-
Switch
public Switch()Constructs a Switch node with default parameters. The default values are as follows:-
child selection index : CHILD_NONE
child selection mask : false (for all children)
-
Switch
public Switch(int whichChild) Constructs and initializes a Switch node using the specified child selection index.- Parameters:
whichChild
- the initial child selection index
-
Switch
Constructs and initializes a Switch node using the specified child selection index and mask.- Parameters:
whichChild
- the initial child selection indexchildMask
- the initial child selection mask
-
-
Method Details
-
setWhichChild
public void setWhichChild(int child) Sets the child selection index that specifies which child is rendered. If the value is out of range, then no children are drawn.- Parameters:
child
- a non-negative integer index value, indicating a specific child, or one of the following constants: CHILD_NONE, CHILD_ALL, or CHILD_MASK.- Throws:
CapabilityNotSetException
- if appropriate capability is not set and this object is part of live or compiled scene graph- See Also:
-
getWhichChild
public int getWhichChild()Retrieves the current child selection index that specifies which child is rendered.- Returns:
- a non-negative integer index value, indicating a specific child, or one of the following constants: CHILD_NONE, CHILD_ALL, or CHILD_MASK
- Throws:
CapabilityNotSetException
- if appropriate capability is not set and this object is part of live or compiled scene graph- See Also:
-
setChildMask
Sets the child selection mask. This mask is used when the child selection index is set to CHILD_MASK.- Parameters:
childMask
- a BitSet that specifies which children are rendered- Throws:
CapabilityNotSetException
- if appropriate capability is not set and this object is part of live or compiled scene graph
-
getChildMask
Retrieves the current child selection mask. This mask is used when the child selection index is set to CHILD_MASK.- Returns:
- the child selection mask
- Throws:
CapabilityNotSetException
- if appropriate capability is not set and this object is part of live or compiled scene graph
-
currentChild
Retrieves the currently selected child. If the child selection index is out of range or is set to CHILD_NONE, CHILD_ALL, or CHILD_MASK, then this method returns null.- Returns:
- a reference to the current child chosen for rendering
- Throws:
CapabilityNotSetException
- if appropriate capability is not set and this object is part of live or compiled scene graph
-
cloneNode
Used to create a new instance of the node. This routine is called bycloneTree
to duplicate the current node.
-