public class SceneGraphUtility extends Object
Constructor and Description |
---|
SceneGraphUtility() |
Modifier and Type | Method and Description |
---|---|
static void |
addChildNode(SceneGraphComponent parent,
SceneGraphNode node)
method to add a child of arbitrary type
|
static List<SceneGraphPath> |
collectClippingPlanes(SceneGraphComponent rootNode)
Return list of paths from rootNode to an instance of
ClippingPlane , |
static List<SceneGraphPath> |
collectLights(SceneGraphComponent rootNode)
Return list of paths from rootNode to an instance of
Light . |
static <T extends SceneGraphNode> |
copy(T template)
Return a copy of the scene graph node template.
|
static SceneGraphComponent |
createFullSceneGraphComponent() |
static SceneGraphComponent |
createFullSceneGraphComponent(String name)
Allocate and return an instance of
SceneGraphComponent fitted out with an instance
of Transformation and Appearance . |
static Appearance |
findDeepestAppearance(SceneGraphPath theSelection)
A convenience method to find the deepest occurrence of an
Appearance in an
instance of SceneGraphPath. |
static SceneGraphComponent |
flatten(SceneGraphComponent sgc) |
static SceneGraphComponent |
flatten(SceneGraphComponent sgc,
boolean rejectInvis)
Apply transformations recursively to all instances of
PointSet and
produce a flat scene graph with no transformations. |
static SceneGraphComponent |
flatten(SceneGraphComponent sgc,
boolean rejectInvis,
boolean removeTform) |
static Geometry |
getFirstGeometry(SceneGraphComponent sgc) |
static int |
getIndexOfChild(SceneGraphComponent parent,
SceneGraphComponent child)
Linear search for the index of child in childlist of parent.
|
static int |
getMetric(SceneGraphPath sgp)
Return the metric metric at the end of the path sgp by evaluating
effective appearance for the attribute
CommonAttributes.METRIC . |
static List<SceneGraphPath> |
getPathsBetween(SceneGraphComponent begin,
SceneGraphNode end) |
static List<SceneGraphPath> |
getPathsToNamedNodes(SceneGraphComponent root,
String name)
Find and return all paths fomr root to node with name name.
|
static void |
removeChildNode(SceneGraphComponent parent,
SceneGraphNode node)
Remove a child of arbitrary type.
|
static void |
removeChildren(SceneGraphComponent c)
Remove all children (i.e., instances of
SceneGraphComponent from this node. |
static void |
removeLights(Viewer viewer) |
static void |
replaceChild(SceneGraphComponent c,
SceneGraphComponent ch)
Replace the first child with the given component.
|
static void |
setMetric(SceneGraphComponent r,
int metric)
Set the metric of this sub-graph by setting the appearance attribute
CommonAttributes.METRIC . |
public static SceneGraphComponent createFullSceneGraphComponent()
public static SceneGraphComponent createFullSceneGraphComponent(String name)
SceneGraphComponent
fitted out with an instance
of Transformation
and Appearance
.name
- public static void replaceChild(SceneGraphComponent c, SceneGraphComponent ch)
c
- ch
- public static void removeChildren(SceneGraphComponent c)
SceneGraphComponent
from this node.component
- TODO: this should be called removeChildComponents!public static void setMetric(SceneGraphComponent r, int metric)
CommonAttributes.METRIC
.r
- metric
- public static int getMetric(SceneGraphPath sgp)
CommonAttributes.METRIC
.sgp
- public static List<SceneGraphPath> collectLights(SceneGraphComponent rootNode)
Light
.rootNode
- public static List<SceneGraphPath> collectClippingPlanes(SceneGraphComponent rootNode)
ClippingPlane
,rootNode
- public static List<SceneGraphPath> getPathsBetween(SceneGraphComponent begin, SceneGraphNode end)
public static List<SceneGraphPath> getPathsToNamedNodes(SceneGraphComponent root, String name)
root
- name
- public static void removeChildNode(SceneGraphComponent parent, SceneGraphNode node)
node
- the child to removeIllegalArgumentException
- if node is no childpublic static void addChildNode(SceneGraphComponent parent, SceneGraphNode node)
node
- the child to addpublic static int getIndexOfChild(SceneGraphComponent parent, SceneGraphComponent child)
parent
- child
- public static <T extends SceneGraphNode> T copy(T template)
template
- CopyVisitor
public static Geometry getFirstGeometry(SceneGraphComponent sgc)
public static SceneGraphComponent flatten(SceneGraphComponent sgc)
public static SceneGraphComponent flatten(SceneGraphComponent sgc, boolean rejectInvis)
PointSet
and
produce a flat scene graph with no transformations.
It collects these instances, and transforms them into world coordinates.
All these instances are put into one parent, and this parent is returned.
Geometry that is not PointSet is simply ignored. Attributes are copied as much
as possible, normals are also transformed. The code is not robust.sgc
- rejectInvis
- if true, non-visible scene graph components are skipped (default: false)public static SceneGraphComponent flatten(SceneGraphComponent sgc, boolean rejectInvis, boolean removeTform)
public static Appearance findDeepestAppearance(SceneGraphPath theSelection)
Appearance
in an
instance of SceneGraphPath.theSelection
- public static void removeLights(Viewer viewer)