de.grogra.rgg
Class LightModel

java.lang.Object
  extended by de.grogra.persistence.ShareableBase
      extended by de.grogra.rgg.LightModelBase
          extended by de.grogra.rgg.LightModel
All Implemented Interfaces:
VolumeListener, Manageable, Shareable, Options

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

Nested Class Summary
static class LightModel.Type
           
 
Field Summary
static LightModel.Type $TYPE
           
static SCOType.Field depth$FIELD
           
static SCOType.Field minPower$FIELD
           
static SCOType.Field rayCount$FIELD
           
static SCOType.Field seed$FIELD
           
static SCOType.Field spectrumFactory$FIELD
           
static SCOType.Field threadCount$FIELD
           
static SCOType.Field visibleLayers$FIELD
           
 
Constructor Summary
LightModel()
          Create a default light model with 30.000 rays per computation and a ray depth of 10.
LightModel(int rayCount, int depth)
           
LightModel(int rayCount, int depth, double minPower)
           
 
Method Summary
 void beginGroup(java.lang.Object object, boolean asNode)
          This method is invoked by a SceneVisitor when subsequent volumes shall be grouped into a single compound object.
 void compute()
          (Re-)computes the light distribution in the current graph.
 void compute(boolean force)
          (Re-)computes the light distribution in the current graph.
 void compute(Spectrum spectrumFactory)
          (Re-)computes the light distribution in the current graph.
 void compute(Spectrum spectrumFactory, boolean force)
          (Re-)computes the light distribution in the current graph.
 void endGroup()
          This method is invoked by a SceneVisitor when the current group ends.
 java.lang.Object get(java.lang.String key, java.lang.Object defaultValue)
          Returns the option value for the option identified by key.
 Spectrum getAbsorbedPower(Node node)
          Returns the radiant power in Watts which is absorbed by the surface of the volume of the given node.
 Collector getAbsorbedPowerCollector(Node node)
           
 int getDepth()
           
 ManageableType getManageableType()
           
 double getMinPower()
           
 int getRayCount()
           
 long getSeed()
           
 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.
 Collector getSensedIrradianceCollector(Node node)
           
 Spectrum getSpectrumFactory()
           
 int getThreadCount()
           
 void invalidateOctree()
          This invalidates the octree of the SceneVisitor and forces a complete new computation.
 void setDepth(int depth)
           
 void setLayerVisible(int layer, boolean visible)
          sets the visibility of a layer
 void setMinPower(double minPower)
           
 void setRayCount(int rayCount)
           
 void setSeed(long value)
           
 void setSpectrumFactory(Spectrum value)
           
 void setThreadCount(int value)
           
 void volumeCreated(java.lang.Object object, boolean asNode, Volume volume)
          This method is invoked by a SceneVisitor when a volume is created as representation of the geometry of object.
 
Methods inherited from class de.grogra.rgg.LightModelBase
getAbsorbedPower3d, getRadiantPower3dFor, getRadiantPowerFor, getSensedIrradiance3d
 
Methods inherited from class de.grogra.persistence.ShareableBase
addReference, appendReferencesTo, fieldModified, getProvider, getStamp, initProvider, manageableReadResolve, manageableWriteReplace, removeReference
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

$TYPE

public static final LightModel.Type $TYPE

depth$FIELD

public static final SCOType.Field depth$FIELD

minPower$FIELD

public static final SCOType.Field minPower$FIELD

rayCount$FIELD

public static final SCOType.Field rayCount$FIELD

seed$FIELD

public static final SCOType.Field seed$FIELD

spectrumFactory$FIELD

public static final SCOType.Field spectrumFactory$FIELD

threadCount$FIELD

public static final SCOType.Field threadCount$FIELD

visibleLayers$FIELD

public static final SCOType.Field visibleLayers$FIELD
Constructor Detail

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 Detail

beginGroup

public void beginGroup(java.lang.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:
VolumeListener.endGroup()

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(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(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(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

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:
VolumeListener.beginGroup(java.lang.Object, boolean)

get

public java.lang.Object get(java.lang.String key,
                            java.lang.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

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

getAbsorbedPowerCollector

public Collector getAbsorbedPowerCollector(Node node)

getDepth

public int getDepth()

getManageableType

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

getMinPower

public double getMinPower()

getRayCount

public int getRayCount()

getSeed

public long getSeed()

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)

getSpectrumFactory

public Spectrum getSpectrumFactory()

getThreadCount

public int getThreadCount()

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.


setDepth

public void setDepth(int depth)

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

setMinPower

public void setMinPower(double minPower)

setRayCount

public void setRayCount(int rayCount)

setSeed

public void setSeed(long value)

setSpectrumFactory

public void setSpectrumFactory(Spectrum value)

setThreadCount

public void setThreadCount(int value)

volumeCreated

public void volumeCreated(java.lang.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