org.xith3d.scenegraph
Class SceneGraph

java.lang.Object
  extended by org.xith3d.scenegraph.SceneGraph
Direct Known Subclasses:
Xith3DEnvironment

public class SceneGraph
extends java.lang.Object

A SceneGraph provides all methods to control adding and removing Nodes of all kinds and adding and removing of RenderPasses. It also provides getters for the Root objects of a Scenegraph.

See Also:
Xith3DEnvironment

Field Summary
protected static boolean CHECK_FOR_ILLEGAL_MODIFICATION
          If true, the renderer checks for illegal nodes modification
protected  java.util.ArrayList<HUD> huds
           
 ScenegraphModificationsListener modListener
           
 
Constructor Summary
SceneGraph(Renderer renderer)
           
 
Method Summary
 RenderPass addBranchGraph(BranchGroup branchGraph, RenderPassConfig renderPassConfig)
          Adds a new BranchGroup to the SceneGraph's Locale.
 RenderPass addHUD(HUD hud)
          Adds a HUD to the SceneGraph and sets all necessary properties.
 RenderPass addParallelBranch()
          Adds a parallel (projected) RenderPass and links it to a new BranchGroup, which is also been added to the Locale.
 RenderPass addParallelBranch(BranchGroup branchGraph)
          Adds a parallel (projected) RenderPass and links it to the given BranchGroup.
 RenderPass addPerspectiveBranch()
          Adds a perspective (projected) RenderPass and links it to a new BranchGroup, which also been added to the Locale.
 RenderPass addPerspectiveBranch(BranchGroup branchGraph)
          Adds a perspective (projected) RenderPass and links it to the given BranchGroup.
 BranchGroup addRenderPass(RenderPass renderPass)
          Adds a RenderPass to the SceneGraph's Renderer.
 BranchGroup addRenderPassFirst(RenderPass renderPass)
          Adds a RenderPass to the SceneGraph at first position.
 void addScenegraphModificationListener(ScenegraphModificationsListener modListener)
          Adds a new ScenegraphModificationListener to the List.
 void addView(View view)
          Adds a new View to the SceneGraph.
protected static void checkForIllegalModification(Node node)
          can be used by nodes to make sure that a change is not being attempted at runtime.
 BranchGroup getBranchGroup()
           
 BranchGroup getBranchGroup(int index)
           
 HUD getHUD()
          Returns the HUD (first) attached to the SceneGraph id any.
 int getNumberOfBranchGroups()
           
 int getNumberOfViews()
           
 Renderer getRenderer()
           
 long getTotalNumChildren()
           
 long getTotalNumShapes()
           
 View getView()
           
 View getView(int index)
           
 void removeAllBranchGraphs()
          Removes all children from the SceneGraph.
 void removeBranchGraph(BranchGroup branchGraph)
          Removes the given BranchGroup from the SceneGraph.
 void removeHUD(HUD hud)
          Removes a HUD from the SceneGraph.
 void removeRenderPass(RenderPass renderPass)
          Removes the given RenderPass from the SceneGraph's Renderer.
 void removeScenegraphModificationListener(ScenegraphModificationsListener modListener)
          Removes a ScenegraphModificationListener from the List.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHECK_FOR_ILLEGAL_MODIFICATION

protected static final boolean CHECK_FOR_ILLEGAL_MODIFICATION
If true, the renderer checks for illegal nodes modification

See Also:
checkForIllegalModification(Node), Constant Field Values

huds

protected final java.util.ArrayList<HUD> huds

modListener

public ScenegraphModificationsListener modListener
Constructor Detail

SceneGraph

public SceneGraph(Renderer renderer)
Method Detail

checkForIllegalModification

protected static final void checkForIllegalModification(Node node)
can be used by nodes to make sure that a change is not being attempted at runtime.


getRenderer

public final Renderer getRenderer()
Returns:
this SceneGraph's Renderer.

addScenegraphModificationListener

public final void addScenegraphModificationListener(ScenegraphModificationsListener modListener)
Adds a new ScenegraphModificationListener to the List. It will be notified of any scenegraph change at runtime.

Parameters:
modListener - the new ScenegraphModificationsListener to add

removeScenegraphModificationListener

public final void removeScenegraphModificationListener(ScenegraphModificationsListener modListener)
Removes a ScenegraphModificationListener from the List.

Parameters:
modListener - the ScenegraphModificationsListener to be removed

addView

public final void addView(View view)
Adds a new View to the SceneGraph.

Parameters:
view - the View to be added

getNumberOfViews

public final int getNumberOfViews()
Returns:
this SceneGraph's Views count.

getView

public final View getView()
Returns:
this SceneGraph's (first) View or null, if no View is present.

getView

public View getView(int index)
Parameters:
index - the desired View's index in the SceneGraph
Returns:
this SceneGraph's View with the specified index.

addBranchGraph

public final RenderPass addBranchGraph(BranchGroup branchGraph,
                                       RenderPassConfig renderPassConfig)
Adds a new BranchGroup to the SceneGraph's Locale.
The also created and added RenderPass is automatically linked with the BranchGroup.

There're convenience methods, with which you don't need to pass a RenderPassConfigProvider.

Parameters:
branchGraph - the new branch graph to add
renderPassConfig - the configuration for the new RenderPass to add
Returns:
the created RenderPass
See Also:
BranchGroup, RenderPassConfig, BaseRenderPassConfig, addParallelBranch( BranchGroup ), addPerspectiveBranch( BranchGroup )

addPerspectiveBranch

public final RenderPass addPerspectiveBranch(BranchGroup branchGraph)
Adds a perspective (projected) RenderPass and links it to the given BranchGroup.

This is a convenience method and is functionally equal to:
addBranchGraph( branchGraph, new RenderPassConfig( RenderPassConfigProvider.PERSPECTIVE_PROJECTION ) );

Parameters:
branchGraph - the BranchGroup used for the new RenderPass
Returns:
the created RenderPass
See Also:
BranchGroup, addParallelBranch( BranchGroup )

addPerspectiveBranch

public final RenderPass addPerspectiveBranch()
Adds a perspective (projected) RenderPass and links it to a new BranchGroup, which also been added to the Locale.

This is a convenience method and is functionally equal to:
addBranchGraph( new BranchGroup(), new RenderPassConfig( RenderPassConfigProvider.PERSPECTIVE_PROJECTION ) );
or
addPerspectiveBranch( new BranchGroup() );

Returns:
the created RenderPass
See Also:
addPerspectiveBranch( BranchGroup ), addParallelBranch( BranchGroup )

addParallelBranch

public final RenderPass addParallelBranch(BranchGroup branchGraph)
Adds a parallel (projected) RenderPass and links it to the given BranchGroup.

This is a convenience method and is functionally equal to:
addBranchGraph( branchGraph, new RenderPassConfig( RenderPassConfigProvider.PARALLEL_PROJECTION ) );

Parameters:
branchGraph - the BranchGroup used for the new RenderPass
Returns:
the created RenderPass
See Also:
BranchGroup, addPerspectiveBranch( BranchGroup )

addParallelBranch

public final RenderPass addParallelBranch()
Adds a parallel (projected) RenderPass and links it to a new BranchGroup, which is also been added to the Locale.

This is a convenience method and is functionally equal to:
addBranchGraph( branchGraph, new RenderPassConfig( RenderPassConfigProvider.PARALLEL_PROJECTION ) );
or
addParallelBranch( new BranchGroup() );

Returns:
the created RenderPass
See Also:
addParallelBranch( BranchGroup ), addPerspectiveBranch( BranchGroup )

removeBranchGraph

public final void removeBranchGraph(BranchGroup branchGraph)
Removes the given BranchGroup from the SceneGraph.
The assotiated RenderPass is also removed from the Renderer.

Parameters:
branchGraph - the BranchGroup to remove

getNumberOfBranchGroups

public final int getNumberOfBranchGroups()
Returns:
the number of BranchGroups in this SceneGraph.

getTotalNumChildren

public final long getTotalNumChildren()
Returns:
the total number of children in this group and its subgroups.

getTotalNumShapes

public final long getTotalNumShapes()
Returns:
the total number of shapes in this group and its subgroups.

getBranchGroup

public final BranchGroup getBranchGroup(int index)
Returns:
the n-th BranchGroup in this SceneGraph.

getBranchGroup

public final BranchGroup getBranchGroup()
Returns:
the first BranchGroup in this SceneGraph or null.

removeRenderPass

public final void removeRenderPass(RenderPass renderPass)
Removes the given RenderPass from the SceneGraph's Renderer.
The assotiated BranchGroup is also removed.

Parameters:
renderPass - the RenderPass to remove

addRenderPass

public final BranchGroup addRenderPass(RenderPass renderPass)
Adds a RenderPass to the SceneGraph's Renderer.
The BranchGroup assotiated to the RenderPass is also added to the SceneGraph.

Parameters:
renderPass - the new RenderPass to add
Returns:
the RenderPass'es BranchGroup to add further children to

addRenderPassFirst

public final BranchGroup addRenderPassFirst(RenderPass renderPass)
Adds a RenderPass to the SceneGraph at first position.
The BranchGroup assotiated to the RenderPass is also added to the SceneGraph.

Parameters:
renderPass - the new RenderPass to add
Returns:
the RenderPass'es BranchGroup to add further children to

removeAllBranchGraphs

public final void removeAllBranchGraphs()
Removes all children from the SceneGraph.


addHUD

public final RenderPass addHUD(HUD hud)
Adds a HUD to the SceneGraph and sets all necessary properties.

Parameters:
hud - the HUD to be added to the SceneGraph

getHUD

public final HUD getHUD()
Returns the HUD (first) attached to the SceneGraph id any.

Returns:
the (first) hud or null

removeHUD

public final void removeHUD(HUD hud)
Removes a HUD from the SceneGraph.

Parameters:
hud - the HUD to be removed from the SceneGraph
inputMgr - the InputManager to get input events from