java.lang.Object
de.grogra.imp3d.Visitor3D
de.grogra.imp3d.DisplayVisitor
de.grogra.imp3d.ray2.SceneVisitor
- All Implemented Interfaces:
Visitor
,Scene
,Disposable
,ProgressMonitor
,Cloneable
public class SceneVisitor
extends DisplayVisitor
implements Scene, ProgressMonitor, Cloneable, Disposable
A
SceneVisitor
is used to traverse a graph, collect
the geometry and lights of this graph and represent them as a
Scene
.-
Field Summary
FieldsFields inherited from class de.grogra.imp3d.DisplayVisitor
lastEntered, lastEnteredIsNode
Fields inherited from class de.grogra.imp3d.Visitor3D
layer, resolution, state, transformation
Fields inherited from interface de.grogra.util.ProgressMonitor
ALL, DONE_PROGRESS, I18N, INDETERMINATE_PROGRESS, INTERMEDIATE, LEVEL, NONE
-
Constructor Summary
ConstructorsConstructorDescriptionSceneVisitor
(Workbench wb, Graph graph, float epsilon, Options opts, ViewConfig3D view, boolean[] visibleLayers, VolumeListener mapping, Spectrum spectrumFactory) Constructs a newSceneVisitor
which traverses the givengraph
to obtain the complete geometry and light information and represent it as aScene
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
appendStatistics
(StringBuffer stats) Appends some statistics information about the scene tostats
.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 specifiedline
.This factory method creates a new spectrum which shall be used for light computations within the context of this scene.void
dispose()
dup()
Returns a clone of thisScene
.Returns a bounding box which contains all finite geometric objects of the scene.getGraph()
Returns an object identifying the underlying scene graph.Returns the interior which is associated with volumev
.getInverseLightTransformation
(int light) Returns the affine light transformation from global world coordinates to local light coordinates for the light having indexlight
inScene.getLights()
.getInverseSensorTransformation
(int sensor) Returns the affine sensor transformation from global world coordinates to local sensor coordinates for the sensor having indexsensor
inScene.getSensors()
.int
Returns the index inScene.getLights()
of the light which is associated with volumev
, or-1
if no such light exists.Light[]
Returns an array of all lights in the scene.getLightTransformation
(int light) Returns the affine light transformation from local light coordinates to global world coordinates for the light having indexlight
inScene.getLights()
.int
Returns the index inScene.getSensors()
of the sensor which is associated with volumev
, or-1
if no such sensor exists.Sensor[]
Returns an array of all sensors in the scene.getSensorTransformation
(int sensor) Returns the affine sensor transformation from local sensor coordinates to global world coordinates for the sensor having indexsensor
inScene.getSensors()
.Returns the shader which is associated with volumev
.int
getStamp()
Returns a modification stamp for the underlying scene graph.Returns a unique name for the current scene, so that the test whether two scenes are identical can be performed.protected boolean
isInVisibleLayer
(Object o, boolean asNode) protected Shader
resolveShader
(Shader shader) void
setProgress
(String text, float progress) This method is invoked by the renderer to monitor its progress.void
showMessage
(String message) This method is invoked by the renderer to show a message, e.g., the statistics after rendering has completed.void
Transforms a point in global world coordinates to local object coordinates of the volumev
.protected void
visitEnterImpl
(Object object, boolean asNode, Path path) This method has to be implemented by subclasses.protected void
Informs this visitor about the beginning of an instantiation.boolean
Informs this visitor that an instantiation has been processed completely.protected void
visitLeaveImpl
(Object object, boolean asNode, Path path) This method has to be implemented by subclasses.Methods inherited from class de.grogra.imp3d.DisplayVisitor
getCurrentShader, init, init, isInVisibleScale
Methods inherited from class de.grogra.imp3d.Visitor3D
getCurrentTransformation, getGraphState, init, setResolution, visitEnter, visitEnter, visitLeave
-
Field Details
-
monitorLevel
protected transient int monitorLevel -
MIN_OBJ
public static int MIN_OBJ
-
-
Constructor Details
-
SceneVisitor
public SceneVisitor(Workbench wb, Graph graph, float epsilon, Options opts, ViewConfig3D view, boolean[] visibleLayers, VolumeListener mapping, Spectrum spectrumFactory) Constructs a newSceneVisitor
which traverses the givengraph
to obtain the complete geometry and light information and represent it as aScene
. Note that the traversal is already part of the constructor, so no additional method invocation is required to obtain the geometry.- Parameters:
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. Otherwiseview
isnull
, this is interpreted such that a radiation model is to be computedvisibleLayers
- layers which are visible for the scene visitor, ornull
ifview
shall be used to determine the visibilitymapping
- if notnull
, 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 usingspectrumFactory.newInstance()
)
-
-
Method Details
-
getOctree
-
dup
Description copied from interface:Scene
Returns a clone of thisScene
. All constant variables which are related to the structure of the scene are copied shallowly, state variables are newly created without copying. -
getShader
Description copied from interface:Scene
Returns the shader which is associated with volumev
. -
getInterior
Description copied from interface:Scene
Returns the interior which is associated with volumev
.- Specified by:
getInterior
in interfaceScene
- Parameters:
v
- a volume- Returns:
- corresponding interior
-
getLight
Description copied from interface:Scene
Returns the index inScene.getLights()
of the light which is associated with volumev
, or-1
if no such light exists.- Specified by:
getLight
in interfaceScene
- Parameters:
v
- a volume- Returns:
- index of corresponding light in
Scene.getLights()
-
getSensor
Description copied from interface:Scene
Returns the index inScene.getSensors()
of the sensor which is associated with volumev
, or-1
if no such sensor exists.- Specified by:
getSensor
in interfaceScene
- Parameters:
v
- a volume- Returns:
- index of corresponding sensor in
Scene.getSensors()
-
transform
Description copied from interface:Scene
Transforms a point in global world coordinates to local object coordinates of the volumev
. -
isInVisibleLayer
- Overrides:
isInVisibleLayer
in classDisplayVisitor
-
resolveShader
- Overrides:
resolveShader
in classDisplayVisitor
-
visitImpl
- Specified by:
visitImpl
in classDisplayVisitor
-
visitInstanceEnter
Description copied from interface:Visitor
Informs this visitor about the beginning of an instantiation. This method invokation is nested immediately withinvisitEnter
/visitLeave
of a node. Later on,Visitor.visitInstanceLeave(Object)
will be invoked with the returned value of this invocation as argument. If this method returnsVisitor.STOP
, thevisitInstanceLeave
-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.- Specified by:
visitInstanceEnter
in interfaceVisitor
- Overrides:
visitInstanceEnter
in classVisitor3D
- Returns:
- value to pass to
visitInstanceLeave
, may beVisitor.STOP
-
visitInstanceLeave
Description copied from interface:Visitor
Informs this visitor that an instantiation has been processed completely. The valueo
is the return value of the corresponding invocation ofVisitor.visitInstanceEnter()
. If this invocation returnsfalse
, no further instantiations or edges of the current level of hierarchy will be passed to this visitor, i.e., thevisitLeave
method for the enclosing node will be invoked immediately.- Specified by:
visitInstanceLeave
in interfaceVisitor
- Overrides:
visitInstanceLeave
in classVisitor3D
- Parameters:
o
- returned value ofvisitInstanceEnter
- Returns:
true
iff processing of current level shall be continued
-
visitEnterImpl
Description copied from class:Visitor3D
This method has to be implemented by subclasses. It is invoked whenobject
is entered.- Overrides:
visitEnterImpl
in classDisplayVisitor
- Parameters:
object
- the object being enteredasNode
- isobject
a node or an edge?path
- the path toobject
ifobject
is a node, the path to the node whereobject
points to ifobject
is an edge
-
visitLeaveImpl
Description copied from class:Visitor3D
This method has to be implemented by subclasses. It is invoked whenobject
is left.- Overrides:
visitLeaveImpl
in classDisplayVisitor
- Parameters:
object
- the object being leftasNode
- isobject
a node or an edge?path
- the path toobject
ifobject
is a node, the path to the node whereobject
points to ifobject
is an edge
-
getLights
Description copied from interface:Scene
Returns an array of all lights in the scene. The returned array must not be modified. The corresponding coordinate transformations are obtained byScene.getLightTransformation(int)
. -
getSensors
Description copied from interface:Scene
Returns an array of all sensors in the scene. The returned array must not be modified. The corresponding coordinate transformations are obtained byScene.getSensorTransformation(int)
.- Specified by:
getSensors
in interfaceScene
- Returns:
- array of all sensors
-
getStamp
public int getStamp()Description copied from interface:Scene
Returns a modification stamp for the underlying scene graph. Each modification increments the value, so that the test whether some modification occured can be simply performed on values of the stamp. -
getUniqueName
Description copied from interface:Scene
Returns a unique name for the current scene, so that the test whether two scenes are identical can be performed.- Specified by:
getUniqueName
in interfaceScene
-
getGraph
Description copied from interface:Scene
Returns an object identifying the underlying scene graph. -
getLightTransformation
Description copied from interface:Scene
Returns the affine light transformation from local light coordinates to global world coordinates for the light having indexlight
inScene.getLights()
.- Specified by:
getLightTransformation
in interfaceScene
- Parameters:
light
- index of light inScene.getLights()
- Returns:
- light transformation for
light
- See Also:
-
getInverseLightTransformation
Description copied from interface:Scene
Returns the affine light transformation from global world coordinates to local light coordinates for the light having indexlight
inScene.getLights()
.- Specified by:
getInverseLightTransformation
in interfaceScene
- Parameters:
light
- index of light inScene.getLights()
- Returns:
- inverse light transformation for
light
- See Also:
-
getSensorTransformation
Description copied from interface:Scene
Returns the affine sensor transformation from local sensor coordinates to global world coordinates for the sensor having indexsensor
inScene.getSensors()
.- Specified by:
getSensorTransformation
in interfaceScene
- Parameters:
sensor
- index of sensor inScene.getSensors()
- Returns:
- sensor transformation for
sensor
- See Also:
-
getInverseSensorTransformation
Description copied from interface:Scene
Returns the affine sensor transformation from global world coordinates to local sensor coordinates for the sensor having indexsensor
inScene.getSensors()
.- Specified by:
getInverseSensorTransformation
in interfaceScene
- Parameters:
sensor
- index of sensor inScene.getSensors()
- Returns:
- inverse sensor transformation for
sensor
- See Also:
-
computeIntersections
public boolean computeIntersections(Line ray, int which, IntersectionList list, Intersection excludeStart, Intersection excludeEnd) Description copied from interface:Scene
Computes intersections between the boundary surface of the objects of the scene and the specifiedline
. For the precise behaviour and the meaning of the parameters, seeVolume.computeIntersections(de.grogra.vecmath.geom.Line, int, de.grogra.vecmath.geom.IntersectionList, de.grogra.vecmath.geom.Intersection, de.grogra.vecmath.geom.Intersection)
.- Specified by:
computeIntersections
in interfaceScene
- Parameters:
ray
- a linewhich
- one ofIntersection.ALL
,Intersection.CLOSEST
,Intersection.ANY
, this determines which intersections have to be added tolist
list
- the intersections are added to this listexcludeStart
- intersection at start point which shall be excluded, ornull
excludeEnd
- intersection at end point which shall be excluded, ornull
- Returns:
true
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 ifwhich == Intersection.ALL
- See Also:
-
getBoundingBox
Description copied from interface:Scene
Returns a bounding box which contains all finite geometric objects of the scene. The returned box must not be modified.- Specified by:
getBoundingBox
in interfaceScene
- Returns:
- bounding box of finite geometry
-
appendStatistics
Description copied from interface:Scene
Appends some statistics information about the scene tostats
.- Specified by:
appendStatistics
in interfaceScene
- Parameters:
stats
- buffer for statistics information
-
dispose
public void dispose()- Specified by:
dispose
in interfaceDisposable
-
setProgress
Description copied from interface:ProgressMonitor
This method is invoked by the renderer to monitor its progress.- Specified by:
setProgress
in interfaceProgressMonitor
- Parameters:
text
- short text to displayprogress
- state of progress from 0 to 1, or one of the constantsProgressMonitor.INDETERMINATE_PROGRESS
,ProgressMonitor.DONE_PROGRESS
-
showMessage
Description copied from interface:ProgressMonitor
This method is invoked by the renderer to show a message, e.g., the statistics after rendering has completed.- Specified by:
showMessage
in interfaceProgressMonitor
- Parameters:
message
- message to display
-
createSpectrum
Description copied from interface:Scene
This factory method creates a new spectrum which shall be used for light computations within the context of this scene.- Specified by:
createSpectrum
in interfaceScene
- Returns:
- new spectrum instance for use in computations
-