de.grogra.imp3d.ray2
public class SceneVisitor extends DisplayVisitor implements Scene, ProgressMonitor, java.lang.Cloneable, Disposable
SceneVisitor is used to traverse a graph, collect
the geometry and lights of this graph and represent them as a
Scene.| Modifier and Type | Field and Description |
|---|---|
static int |
MIN_OBJ |
lastEntered, lastEnteredIsNodelayer, state, transformationDONE_PROGRESS, INDETERMINATE_PROGRESS| Constructor and Description |
|---|
SceneVisitor(Workbench wb,
Graph graph,
float epsilon,
Options opts,
ViewConfig3D view,
boolean[] visibleLayers,
VolumeListener mapping,
Spectrum spectrumFactory)
Constructs a new
SceneVisitor which traverses the given
graph to obtain the complete geometry and light
information and represent it as a Scene. |
| Modifier and Type | Method and Description |
|---|---|
void |
appendStatistics(java.lang.StringBuffer stats)
Appends some statistics information about the scene to
stats. |
boolean |
computeIntersections(Line ray,
int which,
IntersectionList list,
Intersection excludeStart,
Intersection excludeEnd)
Computes intersections between the boundary surface of the objects
of the scene and the specified
line. |
Spectrum |
createSpectrum()
This factory method creates a new spectrum which shall be used for
light computations within the context of this scene.
|
void |
dispose() |
Scene |
dup()
Returns a clone of this
Scene. |
BoundingBox |
getBoundingBox()
Returns a bounding box which contains all finite geometric
objects of the scene.
|
java.lang.Object |
getGraph()
Returns an object identifying the underlying scene graph.
|
Interior |
getInterior(Volume v)
Returns the interior which is associated with volume
v. |
Matrix4d |
getInverseLightTransformation(int light)
Returns the affine light transformation from
global world coordinates to local light coordinates
for the light having index
light in
Scene.getLights(). |
Matrix4d |
getInverseSensorTransformation(int sensor)
Returns the affine sensor transformation from
global world coordinates to local sensor coordinates
for the sensor having index
sensor in
Scene.getSensors(). |
int |
getLight(Volume v)
Returns the index in
Scene.getLights() of the light which is
associated with volume v, or -1
if no such light exists. |
Light[] |
getLights()
Returns an array of all lights in the scene.
|
Matrix4d |
getLightTransformation(int light)
Returns the affine light transformation from
local light coordinates to global world coordinates
for the light having index
light in
Scene.getLights(). |
OctreeUnion |
getOctree() |
int |
getSensor(Volume v)
Returns the index in
Scene.getSensors() of the sensor which is
associated with volume v, or -1
if no such sensor exists. |
Sensor[] |
getSensors()
Returns an array of all sensors in the scene.
|
Matrix4d |
getSensorTransformation(int sensor)
Returns the affine sensor transformation from
local sensor coordinates to global world coordinates
for the sensor having index
sensor in
Scene.getSensors(). |
Shader |
getShader(Volume v)
Returns the shader which is associated with volume
v. |
int |
getStamp()
Returns a modification stamp for the underlying scene graph.
|
java.lang.String |
getUniqueName()
Returns a unique name for the current scene, so that the test
whether two scenes are identical can be performed.
|
protected boolean |
isInVisibleLayer(java.lang.Object o,
boolean asNode) |
protected Shader |
resolveShader(Shader shader) |
void |
setProgress(java.lang.String text,
float progress)
This method is invoked by the renderer to monitor its progress.
|
void |
showMessage(java.lang.String message)
This method is invoked by the renderer to show a message, e.g.,
the statistics after rendering has completed.
|
void |
transform(Volume v,
Tuple3d global,
Tuple3d localOut)
Transforms a point in global world coordinates to local object
coordinates of the volume
v. |
protected void |
visitEnterImpl(java.lang.Object object,
boolean asNode,
Path path)
This method has to be implemented by subclasses.
|
protected void |
visitImpl(java.lang.Object object,
boolean asNode,
Shader s,
Path path) |
java.lang.Object |
visitInstanceEnter()
Informs this visitor about the beginning of an instantiation.
|
boolean |
visitInstanceLeave(java.lang.Object o)
Informs this visitor that an instantiation has been processed
completely.
|
protected void |
visitLeaveImpl(java.lang.Object object,
boolean asNode,
Path path)
This method has to be implemented by subclasses.
|
getCurrentShader, init, isInVisibleScalegetCurrentTransformation, getGraphState, init, visitEnter, visitEnter, visitLeavepublic SceneVisitor(Workbench wb, Graph graph, float epsilon, Options opts, ViewConfig3D view, boolean[] visibleLayers, VolumeListener mapping, Spectrum spectrumFactory)
SceneVisitor which traverses the given
graph to obtain the complete geometry and light
information and represent it as a Scene. Note that the traversal
is already part of the constructor, so no additional method invocation
is required to obtain the geometry.wb - the workbench to usegraph - xepsilon - only objects whose magnitude is larger than this value
are consideredopts - options for the construction of geometryview - if the scene is used to render a 3D view, this has to be
specified in this parameter.
Otherwise view is null, this is interpreted
such that a radiation model is to be computedvisibleLayers - layers which are visible for the scene visitor, or
null if view shall be used to determine the
visibilitymapping - if not null, mappings from graph objects to
volumes are reported to this parameterspectrumFactory - instance of spectrum to be used as factory
(i.e., new spectra are allocated using spectrumFactory.newInstance())public void appendStatistics(java.lang.StringBuffer stats)
Scenestats.appendStatistics in interface Scenestats - buffer for statistics informationpublic boolean computeIntersections(Line ray, int which, IntersectionList list, Intersection excludeStart, Intersection excludeEnd)
Sceneline. For the precise
behaviour and the meaning of the parameters, see
Volume.computeIntersections(de.grogra.vecmath.geom.Line, int, de.grogra.vecmath.geom.IntersectionList, de.grogra.vecmath.geom.Intersection, de.grogra.vecmath.geom.Intersection).computeIntersections in interface Sceneray - a linewhich - one of Intersection.ALL,
Intersection.CLOSEST, Intersection.ANY, this
determines which intersections have to be added to listlist - the intersections are added to this listexcludeStart - intersection at start point which shall be excluded, or nullexcludeEnd - intersection at end point which shall be excluded, or nulltrue iff the beginning of the line lies
within the volume (i.e., if the line starts within the volume or
enters the volume at the starting point); however note that the returned
value is valid only if which == Intersection.ALLVolume.computeIntersections(de.grogra.vecmath.geom.Line, int, de.grogra.vecmath.geom.IntersectionList, de.grogra.vecmath.geom.Intersection, de.grogra.vecmath.geom.Intersection)public Spectrum createSpectrum()
ScenecreateSpectrum in interface Scenepublic void dispose()
dispose in interface Disposablepublic Scene dup()
SceneScene.
All constant variables which are related to the structure
of the scene are copied shallowly, state variables
are newly created without copying.public BoundingBox getBoundingBox()
ScenegetBoundingBox in interface Scenepublic java.lang.Object getGraph()
Scenepublic Interior getInterior(Volume v)
Scenev.getInterior in interface Scenev - a volumepublic Matrix4d getInverseLightTransformation(int light)
Scenelight in
Scene.getLights().getInverseLightTransformation in interface Scenelight - index of light in Scene.getLights()lightScene.getLights()public Matrix4d getInverseSensorTransformation(int sensor)
Scenesensor in
Scene.getSensors().getInverseSensorTransformation in interface Scenesensor - index of sensor in Scene.getSensors()sensorScene.getSensors()public int getLight(Volume v)
SceneScene.getLights() of the light which is
associated with volume v, or -1
if no such light exists.getLight in interface Scenev - a volumeScene.getLights()public Light[] getLights()
SceneScene.getLightTransformation(int).public Matrix4d getLightTransformation(int light)
Scenelight in
Scene.getLights().getLightTransformation in interface Scenelight - index of light in Scene.getLights()lightScene.getLights()public OctreeUnion getOctree()
public int getSensor(Volume v)
SceneScene.getSensors() of the sensor which is
associated with volume v, or -1
if no such sensor exists.getSensor in interface Scenev - a volumeScene.getSensors()public Sensor[] getSensors()
SceneScene.getSensorTransformation(int).getSensors in interface Scenepublic Matrix4d getSensorTransformation(int sensor)
Scenesensor in
Scene.getSensors().getSensorTransformation in interface Scenesensor - index of sensor in Scene.getSensors()sensorScene.getSensors()public Shader getShader(Volume v)
Scenev.public int getStamp()
Scenepublic java.lang.String getUniqueName()
ScenegetUniqueName in interface Sceneprotected boolean isInVisibleLayer(java.lang.Object o,
boolean asNode)
isInVisibleLayer in class DisplayVisitorprotected Shader resolveShader(Shader shader)
resolveShader in class DisplayVisitorpublic void setProgress(java.lang.String text,
float progress)
ProgressMonitorsetProgress in interface ProgressMonitortext - short text to displayprogress - state of progress from 0 to 1, or one of the
constants ProgressMonitor.INDETERMINATE_PROGRESS, ProgressMonitor.DONE_PROGRESSpublic void showMessage(java.lang.String message)
ProgressMonitorshowMessage in interface ProgressMonitormessage - message to displaypublic void transform(Volume v, Tuple3d global, Tuple3d localOut)
Scenev.protected void visitEnterImpl(java.lang.Object object,
boolean asNode,
Path path)
Visitor3Dobject is entered.visitEnterImpl in class DisplayVisitorobject - the object being enteredasNode - is object a node or an edge?path - the path to object if object
is a node, the path to the node where object points to
if object is an edgeprotected void visitImpl(java.lang.Object object,
boolean asNode,
Shader s,
Path path)
visitImpl in class DisplayVisitorpublic java.lang.Object visitInstanceEnter()
VisitorvisitEnter/visitLeave of a node. Later on,
Visitor.visitInstanceLeave(Object) will be invoked with
the returned value of this invocation as argument. If this method returns
Visitor.STOP, the visitInstanceLeave-method
will be invoked immediately after this method, i.e., the visitor
does not dive into the instantiation. Otherwise, the instantiation
is performed, starting with an edge.visitInstanceEnter in interface VisitorvisitInstanceEnter in class Visitor3DvisitInstanceLeave, may be Visitor.STOPpublic boolean visitInstanceLeave(java.lang.Object o)
Visitoro is the return value
of the corresponding invocation of Visitor.visitInstanceEnter().
If this invocation returns false, no further
instantiations or edges of the current level of hierarchy will
be passed to this
visitor, i.e., the visitLeave method for the enclosing
node will be invoked immediately.visitInstanceLeave in interface VisitorvisitInstanceLeave in class Visitor3Do - returned value of visitInstanceEntertrue iff processing of current level shall be continuedprotected void visitLeaveImpl(java.lang.Object object,
boolean asNode,
Path path)
Visitor3Dobject is left.visitLeaveImpl in class DisplayVisitorobject - the object being leftasNode - is object a node or an edge?path - the path to object if object
is a node, the path to the node where object points to
if object is an edge