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
, Camera
, and AudioSource
.
It also has a list of Tool
instances, which may be empty.
To traverse the resulting scene graph, use subclasses of
SceneGraphVisitor
.
Constructor and Description |
---|
SceneGraphComponent() |
SceneGraphComponent(String name) |
Modifier and Type | Method and Description |
---|---|
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)
Add a tool to this component.
|
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) |
void |
childrenWriteAccept(SceneGraphVisitor v,
boolean writeTransformation,
boolean writeAppearance,
boolean writeCamera,
boolean writeLight,
boolean writeGeometry,
boolean writeChildren,
boolean writeAudio) |
Appearance |
getAppearance()
Returns the appearance node.
|
AudioSource |
getAudioSource() |
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<SceneGraphNode> |
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 |
isPickable() |
boolean |
isVisible() |
void |
removeAllChildren() |
boolean |
removeChild(SceneGraphComponent sgc) |
void |
removeChildren(SceneGraphComponent... sgcList)
Use varargs in Java 5 to add multiple children at once
|
void |
removeSceneGraphComponentListener(SceneGraphComponentListener listener) |
boolean |
removeTool(Tool tool) |
void |
removeToolListener(ToolListener listener) |
void |
setAppearance(Appearance newApp) |
void |
setAudioSource(AudioSource a) |
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 |
setPickable(boolean newPickableState)
Sets the pickability of this SceneGraphComponent and its children.
|
void |
setTransformation(Transformation newTrans) |
void |
setVisible(boolean newVisibleState)
Sets the visibility of this SceneGraphComponent and its children.
|
getName, getOwner, getThreadSafe, isReadOnly, setName, setOwner, setReadOnly, setThreadSafe, toString
public SceneGraphComponent(String name)
public SceneGraphComponent()
public List<SceneGraphNode> getChildNodes()
public void addChild(SceneGraphComponent sgc)
public void addChildren(SceneGraphComponent... sgcList)
sgcList
- public SceneGraphComponent getChildComponent(int index)
public List<SceneGraphComponent> getChildComponents()
public int getChildComponentCount()
public boolean removeChild(SceneGraphComponent sgc)
public void removeChildren(SceneGraphComponent... sgcList)
sgcList
- public void removeAllChildren()
public void setAppearance(Appearance newApp)
public Appearance getAppearance()
public Camera getCamera()
public void setCamera(Camera newCamera)
camera
- The camera to setpublic Geometry getGeometry()
public void setGeometry(Geometry g)
public AudioSource getAudioSource()
public void setAudioSource(AudioSource a)
public Light getLight()
public void setLight(Light newLight)
light
- The light to setpublic Transformation getTransformation()
public void setTransformation(Transformation newTrans)
public boolean isDirectAncestor(SceneGraphNode child)
public void accept(SceneGraphVisitor v)
SceneGraphNode
accept
in class SceneGraphNode
public void childrenAccept(SceneGraphVisitor v)
childrenAccept(this)
in its visit implementations.public void childrenWriteAccept(SceneGraphVisitor v, boolean writeTransformation, boolean writeAppearance, boolean writeCamera, boolean writeLight, boolean writeGeometry, boolean writeChildren)
public void childrenWriteAccept(SceneGraphVisitor v, boolean writeTransformation, boolean writeAppearance, boolean writeCamera, boolean writeLight, boolean writeGeometry, boolean writeChildren, boolean writeAudio)
public void addTool(Tool tool)
tool
- The tool to add.public boolean removeTool(Tool tool)
public void addToolListener(ToolListener listener)
public void removeToolListener(ToolListener listener)
public boolean isVisible()
public void setVisible(boolean newVisibleState)
visible
- sets wether this barnch of the scene graph should be rendered
or not.public boolean isPickable()
public void setPickable(boolean newPickableState)
pickable
- sets wether this barnch of the scene graph should be pickable or notpublic void addSceneGraphComponentListener(SceneGraphComponentListener listener)
public void removeSceneGraphComponentListener(SceneGraphComponentListener listener)