Module imp3d

Class 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 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 new 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.
      Parameters:
      wb - the workbench to use
      graph - x
      epsilon - only objects whose magnitude is larger than this value are considered
      opts - options for the construction of geometry
      view - 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 computed
      visibleLayers - layers which are visible for the scene visitor, or null if view shall be used to determine the visibility
      mapping - if not null, mappings from graph objects to volumes are reported to this parameter
      spectrumFactory - instance of spectrum to be used as factory (i.e., new spectra are allocated using spectrumFactory.newInstance())
  • Method Details

    • getOctree

      public OctreeUnion getOctree()
      Specified by:
      getOctree in interface Scene
    • dup

      public Scene dup()
      Description copied from interface: Scene
      Returns a clone of this Scene. All constant variables which are related to the structure of the scene are copied shallowly, state variables are newly created without copying.
      Specified by:
      dup in interface Scene
      Returns:
      clone of this scene
    • getShader

      public Shader getShader(Volume v)
      Description copied from interface: Scene
      Returns the shader which is associated with volume v.
      Specified by:
      getShader in interface Scene
      Parameters:
      v - a volume
      Returns:
      corresponding shader
    • getInterior

      public Interior getInterior(Volume v)
      Description copied from interface: Scene
      Returns the interior which is associated with volume v.
      Specified by:
      getInterior in interface Scene
      Parameters:
      v - a volume
      Returns:
      corresponding interior
    • getLight

      public int getLight(Volume v)
      Description copied from interface: Scene
      Returns the index in Scene.getLights() of the light which is associated with volume v, or -1 if no such light exists.
      Specified by:
      getLight in interface Scene
      Parameters:
      v - a volume
      Returns:
      index of corresponding light in Scene.getLights()
    • getSensor

      public int getSensor(Volume v)
      Description copied from interface: Scene
      Returns the index in Scene.getSensors() of the sensor which is associated with volume v, or -1 if no such sensor exists.
      Specified by:
      getSensor in interface Scene
      Parameters:
      v - a volume
      Returns:
      index of corresponding sensor in Scene.getSensors()
    • transform

      public void transform(Volume v, Tuple3d global, Tuple3d localOut)
      Description copied from interface: Scene
      Transforms a point in global world coordinates to local object coordinates of the volume v.
      Specified by:
      transform in interface Scene
      Parameters:
      v - volume which defines the local object coordinates
      global - input point in global world coordinates
      localOut - output point in local object coordinates
    • isInVisibleLayer

      protected boolean isInVisibleLayer(Object o, boolean asNode)
      Overrides:
      isInVisibleLayer in class DisplayVisitor
    • resolveShader

      protected Shader resolveShader(Shader shader)
      Overrides:
      resolveShader in class DisplayVisitor
    • visitImpl

      protected void visitImpl(Object object, boolean asNode, Shader s, Path path)
      Specified by:
      visitImpl in class DisplayVisitor
    • visitInstanceEnter

      public Object visitInstanceEnter()
      Description copied from interface: Visitor
      Informs this visitor about the beginning of an instantiation. This method invokation is nested immediately within visitEnter/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.
      Specified by:
      visitInstanceEnter in interface Visitor
      Overrides:
      visitInstanceEnter in class Visitor3D
      Returns:
      value to pass to visitInstanceLeave, may be Visitor.STOP
    • visitInstanceLeave

      public boolean visitInstanceLeave(Object o)
      Description copied from interface: Visitor
      Informs this visitor that an instantiation has been processed completely. The value o 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.
      Specified by:
      visitInstanceLeave in interface Visitor
      Overrides:
      visitInstanceLeave in class Visitor3D
      Parameters:
      o - returned value of visitInstanceEnter
      Returns:
      true iff processing of current level shall be continued
    • visitEnterImpl

      protected void visitEnterImpl(Object object, boolean asNode, Path path)
      Description copied from class: Visitor3D
      This method has to be implemented by subclasses. It is invoked when object is entered.
      Overrides:
      visitEnterImpl in class DisplayVisitor
      Parameters:
      object - the object being entered
      asNode - 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
    • visitLeaveImpl

      protected void visitLeaveImpl(Object object, boolean asNode, Path path)
      Description copied from class: Visitor3D
      This method has to be implemented by subclasses. It is invoked when object is left.
      Overrides:
      visitLeaveImpl in class DisplayVisitor
      Parameters:
      object - the object being left
      asNode - 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
    • getLights

      public Light[] 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 by Scene.getLightTransformation(int).
      Specified by:
      getLights in interface Scene
      Returns:
      array of all lights
    • getSensors

      public Sensor[] 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 by Scene.getSensorTransformation(int).
      Specified by:
      getSensors in interface Scene
      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.
      Specified by:
      getStamp in interface Scene
      Returns:
      a stamp for the whole graph
    • getUniqueName

      public String 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 interface Scene
    • getGraph

      public Object getGraph()
      Description copied from interface: Scene
      Returns an object identifying the underlying scene graph.
      Specified by:
      getGraph in interface Scene
      Returns:
      scene graph
    • getLightTransformation

      public Matrix4d getLightTransformation(int light)
      Description copied from interface: Scene
      Returns the affine light transformation from local light coordinates to global world coordinates for the light having index light in Scene.getLights().
      Specified by:
      getLightTransformation in interface Scene
      Parameters:
      light - index of light in Scene.getLights()
      Returns:
      light transformation for light
      See Also:
    • getInverseLightTransformation

      public Matrix4d getInverseLightTransformation(int light)
      Description copied from interface: Scene
      Returns the affine light transformation from global world coordinates to local light coordinates for the light having index light in Scene.getLights().
      Specified by:
      getInverseLightTransformation in interface Scene
      Parameters:
      light - index of light in Scene.getLights()
      Returns:
      inverse light transformation for light
      See Also:
    • getSensorTransformation

      public Matrix4d getSensorTransformation(int sensor)
      Description copied from interface: Scene
      Returns the affine sensor transformation from local sensor coordinates to global world coordinates for the sensor having index sensor in Scene.getSensors().
      Specified by:
      getSensorTransformation in interface Scene
      Parameters:
      sensor - index of sensor in Scene.getSensors()
      Returns:
      sensor transformation for sensor
      See Also:
    • getInverseSensorTransformation

      public Matrix4d getInverseSensorTransformation(int sensor)
      Description copied from interface: Scene
      Returns the affine sensor transformation from global world coordinates to local sensor coordinates for the sensor having index sensor in Scene.getSensors().
      Specified by:
      getInverseSensorTransformation in interface Scene
      Parameters:
      sensor - index of sensor in Scene.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 specified line. 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).
      Specified by:
      computeIntersections in interface Scene
      Parameters:
      ray - a line
      which - one of Intersection.ALL, Intersection.CLOSEST, Intersection.ANY, this determines which intersections have to be added to list
      list - the intersections are added to this list
      excludeStart - intersection at start point which shall be excluded, or null
      excludeEnd - intersection at end point which shall be excluded, or null
      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 if which == Intersection.ALL
      See Also:
    • getBoundingBox

      public BoundingBox 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 interface Scene
      Returns:
      bounding box of finite geometry
    • appendStatistics

      public void appendStatistics(StringBuffer stats)
      Description copied from interface: Scene
      Appends some statistics information about the scene to stats.
      Specified by:
      appendStatistics in interface Scene
      Parameters:
      stats - buffer for statistics information
    • dispose

      public void dispose()
      Specified by:
      dispose in interface Disposable
    • setProgress

      public void setProgress(String text, float progress)
      Description copied from interface: ProgressMonitor
      This method is invoked by the renderer to monitor its progress.
      Specified by:
      setProgress in interface ProgressMonitor
      Parameters:
      text - short text to display
      progress - state of progress from 0 to 1, or one of the constants ProgressMonitor.INDETERMINATE_PROGRESS, ProgressMonitor.DONE_PROGRESS
    • showMessage

      public void showMessage(String message)
      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 interface ProgressMonitor
      Parameters:
      message - message to display
    • createSpectrum

      public Spectrum 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 interface Scene
      Returns:
      new spectrum instance for use in computations