Module rgg
Package de.grogra.rgg

Class LightModel

All Implemented Interfaces:
VolumeListener, Manageable, Shareable, Options
Direct Known Subclasses:
LightModelD

public class LightModel extends LightModelBase implements Options, VolumeListener
This light model generates light rays from the light sources in the current scene and calculates how much light is received by any object. This basically works like an inverse ray tracer.

The total light contribution of the light source to the scene determines how many rays are created for that light source. For instance if there were two light sources with a power of 100W and 10W and a total number of 11.000 rays, then the first light would create 10.000 rays and the second light 1.000 rays.
Author:
Reinhard Hemmerling
  • Field Details

    • processor

      protected transient RadiationModel processor
    • rayCount

      protected int rayCount
      The number of rays that is cast from light sources each time compute() is called.
    • depth

      protected int depth
      Maximum recursion depth
    • minPower

      protected double minPower
      Minimum power for a ray to continue recursion
    • seed

      protected long seed
      The seed for the pseudorandom generator.
    • threadCount

      protected int threadCount
    • spectrumFactory

      protected Spectrum spectrumFactory
      The spectrum factory. This defines the type of spectra on which the light model will perform its computations.
    • visibleLayers

      protected boolean[] visibleLayers
    • $TYPE

      public static final LightModel.Type $TYPE
    • rayCount$FIELD

      public static final SCOType.Field rayCount$FIELD
    • depth$FIELD

      public static final SCOType.Field depth$FIELD
    • minPower$FIELD

      public static final SCOType.Field minPower$FIELD
    • seed$FIELD

      public static final SCOType.Field seed$FIELD
    • threadCount$FIELD

      public static final SCOType.Field threadCount$FIELD
    • spectrumFactory$FIELD

      public static final SCOType.Field spectrumFactory$FIELD
    • visibleLayers$FIELD

      public static final SCOType.Field visibleLayers$FIELD
  • Constructor Details

    • LightModel

      public LightModel()
      Create a default light model with 30.000 rays per computation and a ray depth of 10.
    • LightModel

      public LightModel(int rayCount, int depth)
    • LightModel

      public LightModel(int rayCount, int depth, double minPower)
  • Method Details

    • compute

      public void compute()
      Description copied from class: LightModelBase
      (Re-)computes the light distribution in the current graph.
      Specified by:
      compute in class LightModelBase
    • compute

      public void compute(Spectrum spectrumFactory)
      Description copied from class: LightModelBase
      (Re-)computes the light distribution in the current graph.
      Specified by:
      compute in class LightModelBase
      Parameters:
      spectrumFactory - factrory for spectrum objects
    • compute

      public void compute(boolean force)
      Description copied from class: LightModelBase
      (Re-)computes the light distribution in the current graph.
      Specified by:
      compute in class LightModelBase
      Parameters:
      force - if true forces recomputation of the light distribution
    • compute

      public void compute(boolean force, boolean collectTracedRays)
    • compute

      public void compute(Spectrum spectrumFactory, boolean force)
      (Re-)computes the light distribution in the current graph. This method has to be invoked at first in order for LightModelBase.getRadiantPowerFor(de.grogra.graph.impl.Node) to return correct values.
      Specified by:
      compute in class LightModelBase
      Parameters:
      force - if true forces recomputation of the light distribution
      spectrumFactory - factrory for spectrum objects
    • compute

      public void compute(Spectrum spectrumFactory, boolean force, boolean collectTracedRays)
      (Re-)computes the light distribution in the current graph. This method has to be invoked at first in order for LightModelBase.getRadiantPowerFor(de.grogra.graph.impl.Node) to return correct values.
      Parameters:
      force - if true forces recomputation of the light distribution
      collectTracedRays - if true the traced rays are collected and can be obtained by {}. This can be used for debugging purposes.
    • setDepth

      public void setDepth(int depth)
    • setRayCount

      public void setRayCount(int rayCount)
    • setMinPower

      public void setMinPower(double minPower)
    • setLayerVisible

      public void setLayerVisible(int layer, boolean visible)
      Description copied from class: LightModelBase
      sets the visibility of a layer
      Specified by:
      setLayerVisible in class LightModelBase
    • hasResults

      public boolean hasResults()
    • print

      protected static void print(String msg)
    • checkVolumeId

      protected int checkVolumeId(Node node)
    • getHitCount

      public int getHitCount(Node node)
      Returns the number of rays which is hit the surface of the volume of the given node. If the node does not define a volume, the zero is returned.
      Parameters:
      node - a node of the graph
      Returns:
      the number of rays which is hit the node
    • getTransmittedPower

      public Spectrum getTransmittedPower(Node node)
      Returns the radiant power in Watts which is transmitted by the surface of the volume of the given node. If the node does not define a volume, the zero spectrum is returned.
      Parameters:
      node - a node of the graph
      Returns:
      the transmitted radiant power of the node
    • getReflectedPower

      public Spectrum getReflectedPower(Node node)
      Returns the radiant power in Watts which is reflected by the surface of the volume of the given node. If the node does not define a volume, the zero spectrum is returned.
      Parameters:
      node - a node of the graph
      Returns:
      the reflected radiant power of the node
    • getReceivedPower

      public Spectrum getReceivedPower(Node node)
      Returns the radiant power in Watts which is received by the surface of the volume of the given node. If the node does not define a volume, the zero spectrum is returned.
      Parameters:
      node - a node of the graph
      Returns:
      the received radiant power of the node
    • getAbsorbedPower

      public Spectrum getAbsorbedPower(Node node)
      Returns the radiant power in Watts which is absorbed by the surface of the volume of the given node. If the node does not define a volume, the zero spectrum is returned.
      Specified by:
      getAbsorbedPower in class LightModelBase
      Parameters:
      node - a node of the graph
      Returns:
      the absorbed radiant power of the node
    • getSensedIrradiance

      public Spectrum getSensedIrradiance(Node node)
      Returns the irradiance in Watts per square meter which is sensed by the sensor attached to the volume of the given node. If the node does not define a volume with a sensor, the zero spectrum is returned.
      Specified by:
      getSensedIrradiance in class LightModelBase
      Parameters:
      node - a node of the graph
      Returns:
      the sensed irradiance of the node
    • getSensedIrradianceCollector

      public Collector getSensedIrradianceCollector(Node node)
    • getAbsorbedPowerCollector

      public Collector getAbsorbedPowerCollector(Node node)
    • getTracedRays

      public ObjectList<ObjectList<RadiationModel.RayPoint>> getTracedRays()
    • get

      public Object get(String key, Object defaultValue)
      Description copied from interface: Options
      Returns the option value for the option identified by key. If no special value for the option is defined, defaultValue is returned.
      Specified by:
      get in interface Options
      Parameters:
      key - identifier for option
      defaultValue - default value of option
      Returns:
      value of option named key
    • volumeCreated

      public void volumeCreated(Object object, boolean asNode, Volume volume)
      Description copied from interface: VolumeListener
      This method is invoked by a SceneVisitor when a volume is created as representation of the geometry of object. By storing the information provided by the parameters, the link from graph objects (nodes and edges) to volumes can be established.
      Specified by:
      volumeCreated in interface VolumeListener
      Parameters:
      object - an object of the graph
      asNode - is object a node or an edge?
      volume - the volume which has been created as geometrical representation of object
    • beginGroup

      public void beginGroup(Object object, boolean asNode)
      Description copied from interface: VolumeListener
      This method is invoked by a SceneVisitor when subsequent volumes shall be grouped into a single compound object. The group extends until the corresponding invocation of VolumeListener.endGroup(). These invocations may be nested, i.e., there may be groups within groups.

      Each group starts at object in the graph. If object has a geometric representation itself, the corresponding invocation of VolumeListener.volumeCreated(java.lang.Object, boolean, de.grogra.vecmath.geom.Volume) may be either immediately before of after beginGroup.

      Specified by:
      beginGroup in interface VolumeListener
      Parameters:
      object - the object of the graph which represents the root of the group
      asNode - is object a node or an edge?
      See Also:
    • endGroup

      public void endGroup()
      Description copied from interface: VolumeListener
      This method is invoked by a SceneVisitor when the current group ends.
      Specified by:
      endGroup in interface VolumeListener
      See Also:
    • invalidateOctree

      public void invalidateOctree()
      This invalidates the octree of the SceneVisitor and forces a complete new computation. This method is useful if you want to recompute the LightModel without any changes of the scene.
    • getManageableType

      public ManageableType getManageableType()
      Specified by:
      getManageableType in interface Manageable
    • getRayCount

      public int getRayCount()
    • getDepth

      public int getDepth()
    • getThreadCount

      public int getThreadCount()
    • setThreadCount

      public void setThreadCount(int value)
    • getSeed

      public long getSeed()
    • setSeed

      public void setSeed(long value)
    • getMinPower

      public double getMinPower()
    • getSpectrumFactory

      public Spectrum getSpectrumFactory()
    • setSpectrumFactory

      public void setSpectrumFactory(Spectrum value)