de.jreality.scene
Class SceneGraphComponent

java.lang.Object
  extended by de.jreality.scene.SceneGraphNode
      extended by de.jreality.scene.SceneGraphComponent

public class SceneGraphComponent
extends SceneGraphNode

This basic building block of the jReality scene graph. It's the only node that can have another SceneGraphComponent instance as a child (see {addChild(SceneGraphComponent)).

A SceneGraphComponent can contain other instances of SceneGraphNode. To be exact, it can have one each of the following: Appearance, Transformation, Geometry, Light, or Camera. It also has a list of Tool instances, which may be empty.

To traverse the resulting scene graph, use subclasses of SceneGraphVisitor.

Author:
Unknown

Constructor Summary
SceneGraphComponent()
           
SceneGraphComponent(String name)
           
 
Method Summary
 void accept(SceneGraphVisitor v)
          The accept method for a SceneGraphVisitor.
 void addChild(SceneGraphComponent sgc)
           
 void addChildren(SceneGraphComponent... sgcList)
          Use varargs in Java 5 to add multiple children at once
 void addSceneGraphComponentListener(SceneGraphComponentListener listener)
           
 void addTool(Tool tool)
           
 void addToolListener(ToolListener listener)
           
 void childrenAccept(SceneGraphVisitor v)
          This method calls the accept method on all childMembers in the following order transformation appearance camera light geometry all child SceneGraphComponents The default use would be a rendering system, that implements the SceneGraphVisitor interface and calls childrenAccept(this) in its visit implementations.
 void childrenWriteAccept(SceneGraphVisitor v, boolean writeTransformation, boolean writeAppearance, boolean writeCamera, boolean writeLight, boolean writeGeometry, boolean writeChildren)
           
 Appearance getAppearance()
          Returns the appearance node.
 Camera getCamera()
          Returns the camera child if any.
 SceneGraphComponent getChildComponent(int index)
          Returns a child component node.
 int getChildComponentCount()
          Returns the number of child component nodes.
 List<SceneGraphComponent> getChildComponents()
          returns a read-only list of the child component nodes.
 List getChildNodes()
           
 Geometry getGeometry()
           
 Light getLight()
          Returns the light child if any.
 List<Tool> getTools()
          use from inside Scene.executeReader(..)
 Transformation getTransformation()
          Returns the transformation node.
 boolean isDirectAncestor(SceneGraphNode child)
           
 boolean isVisible()
           
 void removeChild(SceneGraphComponent sgc)
           
 void removeSceneGraphComponentListener(SceneGraphComponentListener listener)
           
 void removeTool(Tool tool)
           
 void removeToolListener(ToolListener listener)
           
 void setAppearance(Appearance newApp)
           
 void setCamera(Camera newCamera)
          Adds a camera, replacing any previously added camera.
 void setGeometry(Geometry g)
           
 void setLight(Light newLight)
          Adds a light, replacing any previously added light.
 void setTransformation(Transformation newTrans)
           
 void setVisible(boolean newVisibleState)
          Sets the visibility of this SceneGraphComponent and its children.
 
Methods inherited from class de.jreality.scene.SceneGraphNode
getName, getOwner, getThreadSafe, isReadOnly, setName, setOwner, setReadOnly, setThreadSafe, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SceneGraphComponent

public SceneGraphComponent(String name)

SceneGraphComponent

public SceneGraphComponent()
Method Detail

getChildNodes

public List getChildNodes()

addChild

public void addChild(SceneGraphComponent sgc)

addChildren

public void addChildren(SceneGraphComponent... sgcList)
Use varargs in Java 5 to add multiple children at once

Parameters:
sgcList -

getChildComponent

public SceneGraphComponent getChildComponent(int index)
Returns a child component node.

Returns:
SceneGraphComponent

getChildComponents

public List<SceneGraphComponent> getChildComponents()
returns a read-only list of the child component nodes.

Returns:
a List containing the child component nodes

getChildComponentCount

public int getChildComponentCount()
Returns the number of child component nodes.

Returns:
int

removeChild

public void removeChild(SceneGraphComponent sgc)

setAppearance

public void setAppearance(Appearance newApp)

getAppearance

public Appearance getAppearance()
Returns the appearance node.

Returns:
Appearance

getCamera

public Camera getCamera()
Returns the camera child if any.

Returns:
Camera

setCamera

public void setCamera(Camera newCamera)
Adds a camera, replacing any previously added camera.

Parameters:
camera - The camera to set

getGeometry

public Geometry getGeometry()

setGeometry

public void setGeometry(Geometry g)

getLight

public Light getLight()
Returns the light child if any.

Returns:
Light

setLight

public void setLight(Light newLight)
Adds a light, replacing any previously added light.

Parameters:
light - The light to set

getTransformation

public Transformation getTransformation()
Returns the transformation node.

Returns:
Transformation

setTransformation

public void setTransformation(Transformation newTrans)

isDirectAncestor

public boolean isDirectAncestor(SceneGraphNode child)

accept

public void accept(SceneGraphVisitor v)
Description copied from class: SceneGraphNode
The accept method for a SceneGraphVisitor.

Overrides:
accept in class SceneGraphNode

childrenAccept

public void childrenAccept(SceneGraphVisitor v)
This method calls the accept method on all childMembers in the following order The default use would be a rendering system, that implements the SceneGraphVisitor interface and calls childrenAccept(this) in its visit implementations.


childrenWriteAccept

public void childrenWriteAccept(SceneGraphVisitor v,
                                boolean writeTransformation,
                                boolean writeAppearance,
                                boolean writeCamera,
                                boolean writeLight,
                                boolean writeGeometry,
                                boolean writeChildren)

addTool

public void addTool(Tool tool)

removeTool

public void removeTool(Tool tool)

getTools

public List<Tool> getTools()
use from inside Scene.executeReader(..)

Returns:

addToolListener

public void addToolListener(ToolListener listener)

removeToolListener

public void removeToolListener(ToolListener listener)

isVisible

public boolean isVisible()
Returns:
a boolean that indicates wether this SceneGraphNode and its children get their geometry rendered or not.

setVisible

public void setVisible(boolean newVisibleState)
Sets the visibility of this SceneGraphComponent and its children. This flag affects rendering and bounding box calculations only (i.e. lights and cameras at or below this node are unaffected).

Parameters:
visible - sets wether this barnch of the scene graph should be rendered or not.

addSceneGraphComponentListener

public void addSceneGraphComponentListener(SceneGraphComponentListener listener)

removeSceneGraphComponentListener

public void removeSceneGraphComponentListener(SceneGraphComponentListener listener)