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.- Author:
- Ole Kniemeyer
- See Also:
-
Field Summary
FieldsFields inherited from class de.grogra.imp3d.DisplayVisitor
lastEntered, lastEnteredIsNodeFields inherited from class de.grogra.imp3d.Visitor3D
layer, resolution, state, transformationFields 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 newSceneVisitorwhich traverses the givengraphto obtain the complete geometry and light information and represent it as aScene. -
Method Summary
Modifier and TypeMethodDescriptionvoidappendStatistics(StringBuffer stats) Appends some statistics information about the scene tostats.booleancomputeIntersections(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.voiddispose()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 indexlightinScene.getLights().getInverseSensorTransformation(int sensor) Returns the affine sensor transformation from global world coordinates to local sensor coordinates for the sensor having indexsensorinScene.getSensors().intReturns the index inScene.getLights()of the light which is associated with volumev, or-1if 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 indexlightinScene.getLights().intReturns the index inScene.getSensors()of the sensor which is associated with volumev, or-1if 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 indexsensorinScene.getSensors().Returns the shader which is associated with volumev.intgetStamp()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 booleanisInVisibleLayer(Object o, boolean asNode) protected ShaderresolveShader(Shader shader) voidsetProgress(String text, float progress) This method is invoked by the renderer to monitor its progress.voidshowMessage(String message) This method is invoked by the renderer to show a message, e.g., the statistics after rendering has completed.voidTransforms a point in global world coordinates to local object coordinates of the volumev.protected voidvisitEnterImpl(Object object, boolean asNode, Path path) This method has to be implemented by subclasses.protected voidInforms this visitor about the beginning of an instantiation.booleanInforms this visitor that an instantiation has been processed completely.protected voidvisitLeaveImpl(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, isInVisibleScaleMethods 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 newSceneVisitorwhich traverses the givengraphto 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. Otherwiseviewisnull, this is interpreted such that a radiation model is to be computedvisibleLayers- layers which are visible for the scene visitor, ornullifviewshall 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:SceneReturns 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:SceneReturns the shader which is associated with volumev. -
getInterior
Description copied from interface:SceneReturns the interior which is associated with volumev.- Specified by:
getInteriorin interfaceScene- Parameters:
v- a volume- Returns:
- corresponding interior
-
getLight
Description copied from interface:SceneReturns the index inScene.getLights()of the light which is associated with volumev, or-1if no such light exists.- Specified by:
getLightin interfaceScene- Parameters:
v- a volume- Returns:
- index of corresponding light in
Scene.getLights()
-
getSensor
Description copied from interface:SceneReturns the index inScene.getSensors()of the sensor which is associated with volumev, or-1if no such sensor exists.- Specified by:
getSensorin interfaceScene- Parameters:
v- a volume- Returns:
- index of corresponding sensor in
Scene.getSensors()
-
transform
Description copied from interface:SceneTransforms a point in global world coordinates to local object coordinates of the volumev. -
isInVisibleLayer
- Overrides:
isInVisibleLayerin classDisplayVisitor
-
resolveShader
- Overrides:
resolveShaderin classDisplayVisitor
-
visitImpl
- Specified by:
visitImplin classDisplayVisitor
-
visitInstanceEnter
Description copied from interface:VisitorInforms this visitor about the beginning of an instantiation. This method invokation is nested immediately withinvisitEnter/visitLeaveof 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:
visitInstanceEnterin interfaceVisitor- Overrides:
visitInstanceEnterin classVisitor3D- Returns:
- value to pass to
visitInstanceLeave, may beVisitor.STOP
-
visitInstanceLeave
Description copied from interface:VisitorInforms this visitor that an instantiation has been processed completely. The valueois 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., thevisitLeavemethod for the enclosing node will be invoked immediately.- Specified by:
visitInstanceLeavein interfaceVisitor- Overrides:
visitInstanceLeavein classVisitor3D- Parameters:
o- returned value ofvisitInstanceEnter- Returns:
trueiff processing of current level shall be continued
-
visitEnterImpl
Description copied from class:Visitor3DThis method has to be implemented by subclasses. It is invoked whenobjectis entered.- Overrides:
visitEnterImplin classDisplayVisitor- Parameters:
object- the object being enteredasNode- isobjecta node or an edge?path- the path toobjectifobjectis a node, the path to the node whereobjectpoints to ifobjectis an edge
-
visitLeaveImpl
Description copied from class:Visitor3DThis method has to be implemented by subclasses. It is invoked whenobjectis left.- Overrides:
visitLeaveImplin classDisplayVisitor- Parameters:
object- the object being leftasNode- isobjecta node or an edge?path- the path toobjectifobjectis a node, the path to the node whereobjectpoints to ifobjectis an edge
-
getLights
Description copied from interface:SceneReturns 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:SceneReturns 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:
getSensorsin interfaceScene- Returns:
- array of all sensors
-
getStamp
public int getStamp()Description copied from interface:SceneReturns 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:SceneReturns a unique name for the current scene, so that the test whether two scenes are identical can be performed.- Specified by:
getUniqueNamein interfaceScene
-
getGraph
Description copied from interface:SceneReturns an object identifying the underlying scene graph. -
getLightTransformation
Description copied from interface:SceneReturns the affine light transformation from local light coordinates to global world coordinates for the light having indexlightinScene.getLights().- Specified by:
getLightTransformationin interfaceScene- Parameters:
light- index of light inScene.getLights()- Returns:
- light transformation for
light - See Also:
-
getInverseLightTransformation
Description copied from interface:SceneReturns the affine light transformation from global world coordinates to local light coordinates for the light having indexlightinScene.getLights().- Specified by:
getInverseLightTransformationin interfaceScene- Parameters:
light- index of light inScene.getLights()- Returns:
- inverse light transformation for
light - See Also:
-
getSensorTransformation
Description copied from interface:SceneReturns the affine sensor transformation from local sensor coordinates to global world coordinates for the sensor having indexsensorinScene.getSensors().- Specified by:
getSensorTransformationin interfaceScene- Parameters:
sensor- index of sensor inScene.getSensors()- Returns:
- sensor transformation for
sensor - See Also:
-
getInverseSensorTransformation
Description copied from interface:SceneReturns the affine sensor transformation from global world coordinates to local sensor coordinates for the sensor having indexsensorinScene.getSensors().- Specified by:
getInverseSensorTransformationin 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:SceneComputes 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:
computeIntersectionsin interfaceScene- Parameters:
ray- a linewhich- one ofIntersection.ALL,Intersection.CLOSEST,Intersection.ANY, this determines which intersections have to be added tolistlist- the intersections are added to this listexcludeStart- intersection at start point which shall be excluded, ornullexcludeEnd- intersection at end point which shall be excluded, ornull- Returns:
trueiff 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:SceneReturns a bounding box which contains all finite geometric objects of the scene. The returned box must not be modified.- Specified by:
getBoundingBoxin interfaceScene- Returns:
- bounding box of finite geometry
-
appendStatistics
Description copied from interface:SceneAppends some statistics information about the scene tostats.- Specified by:
appendStatisticsin interfaceScene- Parameters:
stats- buffer for statistics information
-
dispose
public void dispose()- Specified by:
disposein interfaceDisposable
-
setProgress
Description copied from interface:ProgressMonitorThis method is invoked by the renderer to monitor its progress.- Specified by:
setProgressin 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:ProgressMonitorThis method is invoked by the renderer to show a message, e.g., the statistics after rendering has completed.- Specified by:
showMessagein interfaceProgressMonitor- Parameters:
message- message to display
-
createSpectrum
Description copied from interface:SceneThis factory method creates a new spectrum which shall be used for light computations within the context of this scene.- Specified by:
createSpectrumin interfaceScene- Returns:
- new spectrum instance for use in computations
-