de.grogra.imp3d.objects
Class SensorNode

java.lang.Object
  extended by de.grogra.graph.impl.Edge
      extended by de.grogra.graph.impl.Node
          extended by de.grogra.imp3d.objects.Null
              extended by de.grogra.imp3d.objects.ColoredNull
                  extended by de.grogra.imp3d.objects.SensorNode
All Implemented Interfaces:
Transformation, Pickable, Renderable, Manageable, PersistenceCapable, Shareable, Emitter, Scattering, Sensor, UserFields, XObject, Map, java.io.Serializable

public class SensorNode
extends ColoredNull
implements Pickable, Renderable, Sensor

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class de.grogra.graph.impl.Node
Node.AccessorBridge, Node.FieldAttributeAccessor, Node.NType
 
Nested classes/interfaces inherited from interface de.grogra.util.Map
Map.Chain
 
Field Summary
static Node.NType $TYPE
           
protected  float exponent
           
static Node.NType.Field exponent$FIELD
           
protected  float radius
           
static Node.NType.Field radius$FIELD
           
protected  boolean twoSided
           
static Node.NType.Field twoSided$FIELD
           
 
Fields inherited from class de.grogra.imp3d.objects.ColoredNull
color, color$FIELD
 
Fields inherited from class de.grogra.imp3d.objects.Null
transform, transform$FIELD, TRANSFORMING_MASK, transforming$FIELD, USED_BITS
 
Fields inherited from class de.grogra.graph.impl.Node
ADDITIONAL_FIELDS, bits, DELETED, EXTENT_BIT, EXTENT_MASK, extentIndex$FIELD, extentTail$FIELD, HAS_OBSERVERS, IS_INTERPRETIVE, isInterpretive$FIELD, LAST_EXTENT_INDEX, layer$FIELD, MARK, mark$FIELD, MIME_TYPE, MIN_UNUSED_SPECIAL_OF_SOURCE, MIN_UNUSED_SPECIAL_OF_TARGET, name$FIELD
 
Fields inherited from interface de.grogra.ray.physics.Scattering
DELTA_FACTOR, IS_NON_OPAQUE, MIN_UNUSED_FLAG, NEEDS_NORMAL, NEEDS_POINT, NEEDS_TANGENTS, NEEDS_TRANSFORMATION, NEEDS_UV, RANDOM_RAYS_GENERATE_ORIGINS
 
Fields inherited from interface de.grogra.util.Map
DEFAULT_VALUE, EMPTY_MAP
 
Constructor Summary
SensorNode()
           
 
Method Summary
 double completeRay(Environment env, Point3d vertex, Ray out)
           
 float computeBSDF(Environment env, Vector3f in, Spectrum specIn, Vector3f out, boolean adjoint, Spectrum bsdf)
          Evaluates bidirectional scattering distribution function for given input.
 double computeExitance(Environment env, Spectrum exitance)
          Evaluates the exitance function for given input.
 void draw(java.lang.Object object, boolean asNode, RenderState rs)
           
 void generateRandomOrigins(Environment env, RayList out, java.util.Random rnd)
          Pseudorandomly generates, for the given input, a set of origins for this emitter.
 void generateRandomRays(Environment env, Vector3f out, Spectrum specOut, RayList rays, boolean adjoint, java.util.Random rnd)
          Pseudorandomly generates, for the given input, a set of scattered rays.
 int getAverageColor()
          Returns an average color for the scattering entity.
 float getExponent()
           
 int getFlags()
           
protected  Node.NType getNTypeImpl()
          This method returns the Node.NType which describes the managed fields of the class of this node.
 float getRadius()
           
 float[] getUVForVertex(Environment env, Point3d vertex)
           
 boolean isTwoSided()
           
protected  Node newInstance()
          This method returns a new instance of the class of this node.
 void pick(java.lang.Object object, boolean asNode, Point3d origin, Vector3d direction, Matrix4d t, PickList list)
          Computes intersections of a given ray with this shape.
 void setExponent(float value)
           
 void setRadius(float value)
           
 void setTwoSided(boolean value)
           
 
Methods inherited from class de.grogra.imp3d.objects.ColoredNull
getColor, setColor, setColor, setColor
 
Methods inherited from class de.grogra.imp3d.objects.Null
getLocalTransformation, getTransform, getTranslation, isTransforming, postTransform, preTransform, setRotation, setScale, setTransform, setTransform, setTransform, setTransform, setTransform, setTransform, setTransform, setTransform, setTransforming, setTranslation
 
Methods inherited from class de.grogra.graph.impl.Node
addEdgeBitsTo, addReference, appendBranchNode, appendBranchNode, appendReferencesTo, clone, clone, cloneGraph, dump, dumpTree, dup, dupUnmanagedFields, edgeChanged, fieldModified, findAdjacent, get, getAccessor, getAccessor, getAttributes, getAxisParent, getBoolean, getBranch, getBranchLength, getBranchNode, getBranchTail, getByte, getChar, getCommonAncestor, getCurrentGraphState, getDirectChildCount, getDouble, getEdgeAttributeAccessor, getEdgeAttributes, getEdgeBitsTo, getEdgeTo, getExtentIndex, getFirst, getFirstEdge, getFloat, getGraph, getId, getIndex, getInstantiator, getInt, getLayer, getLong, getManageableType, getName, getNeighbor, getNext, getNType, getObject, getOrCreateEdgeTo, getOrNull, getPersistenceManager, getPredecessor, getProvider, getShort, getSource, getStamp, getSuccessor, getSymbol, getSymbolColor, getTarget, getTransaction, getUserField, getUserFieldCount, getXClass, getXData, hasName, initProvider, initXClass, insertBranchNode, insertBranchNode, instantiateGraph, isAncestorOf, isDirection, isManagingInstance, isMarked, isRoot, isSource, isTarget, manageableReadResolve, manageableWriteReplace, paramString, removeAll, removeEdgeBitsTo, removeFromChain, removeFromChain, removeReference, setBranch, setBranch, setExtentIndex, setGraphForDeserialization, setLayer, setMark, setName, setSuccessor, setSuccessor, specialEdgeAdded, specialEdgeRefModified, specialEdgeRemoved, toString, writeReplace
 
Methods inherited from class de.grogra.graph.impl.Edge
addEdgeBits, getBitMark, getEdgeBits, getObjectMark, getSpecialEdgeDescriptor, parseEdgeKeys, remove, removeEdgeBits, setBitMark, setEdgeBits, setObjectMark, testEdgeBits
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface de.grogra.persistence.PersistenceCapable
getBitMark, getObjectMark, setBitMark, setObjectMark
 

Field Detail

$TYPE

public static final Node.NType $TYPE

exponent

protected float exponent

exponent$FIELD

public static final Node.NType.Field exponent$FIELD

radius

protected float radius

radius$FIELD

public static final Node.NType.Field radius$FIELD

twoSided

protected boolean twoSided

twoSided$FIELD

public static final Node.NType.Field twoSided$FIELD
Constructor Detail

SensorNode

public SensorNode()
Method Detail

completeRay

public double completeRay(Environment env,
                          Point3d vertex,
                          Ray out)
Specified by:
completeRay in interface Emitter

computeBSDF

public float computeBSDF(Environment env,
                         Vector3f in,
                         Spectrum specIn,
                         Vector3f out,
                         boolean adjoint,
                         Spectrum bsdf)
Description copied from interface: Scattering
Evaluates bidirectional scattering distribution function for given input.

The computed spectrum is an integral over the spectrum of the following product:

|cos θ| BSDF(ωi, νi; ωo, νo)
where BSDF is the bidirectional scattering distribution function (= BRDF + BTDF) at the point env.point, ωi the (negated) direction of the incoming light ray, νi the frequency where the incoming ray is sampled, ωo the direction of the outgoing light ray, νo the frequency where the outgoing ray is sampled, and θ the angle between the surface normal and out.

If adjoint is false, in and out describe true light rays from light sources to sensors. In this case, ωi = in, ωo = out, and the integral is

bsdf(ν) = |cos θ| ∫ BSDF(in, νi; out, ν) specIni) dνi
Otherwise, adjoint is true. in and out then describe importance rays (inverse light rays from sensors to light sources). In this case, ωi = out, ωo = in, and the integral is
bsdf(ν) = |cos θ| ∫ BSDF(out, ν; in, νo) specIno) dνo

If this Scattering instance is in fact a Light source, adjoint is false, and the BSDF is defined as BSDF(in, μ; ω, ν) = L1(ω, ν) δ(μ - ν), i.e., the directional distribution of the emitted radiance at env.point, see Emitter. In this case, in is not used.

If this Scattering instance is in fact a Sensor, adjoint is true, and the BSDF is defined as BSDF(ω, ν; in, μ) = W1(ω, ν) δ(μ - ν), i.e., the directional distribution of the emitted importance at env.point, see Emitter. In this case, in is not used.

The computation should be physically valid. This excludes, e.g., ambient or emissive light contributions.

The returned value is the value of the probability density pω that would be calculated by Scattering.generateRandomRays(de.grogra.ray.physics.Environment, javax.vecmath.Vector3f, de.grogra.ray.physics.Spectrum, de.grogra.ray.util.RayList, boolean, java.util.Random) if the ray happened to be one of the randomly generated rays.

Specified by:
computeBSDF in interface Scattering
Parameters:
env - the environment for scattering
in - the (negated) direction unit vector of the incoming ray (i.e., pointing away from the surface)
specIn - the spectrum of the incoming ray
out - the direction unit vector of the outgoing ray (i.e., pointing away from the surface)
adjoint - light ray or importance ray?
bsdf - the computed spectrum of the outgoing ray will be placed in here
Returns:
the value of the probability density for the ray direction

computeExitance

public double computeExitance(Environment env,
                              Spectrum exitance)
Description copied from interface: Emitter
Evaluates the exitance function for given input. The computed value is the spectrum of the radiant exitance (emitted power per area) L0j(x, ν) at the point env.point in case of light sources, or the corresponding function W0j(x, ν) in case of sensors.

The returned value is the value of the probability density px that would be calculated by Emitter.generateRandomOrigins(de.grogra.ray.physics.Environment, de.grogra.ray.util.RayList, java.util.Random) if env.point happened to be one of the randomly generated origins.

Specified by:
computeExitance in interface Emitter
Parameters:
env - the environment for scattering
exitance - the exitance values will be placed in here
Returns:
the value of the probability density for the ray origin

draw

public void draw(java.lang.Object object,
                 boolean asNode,
                 RenderState rs)
Specified by:
draw in interface Renderable

generateRandomOrigins

public void generateRandomOrigins(Environment env,
                                  RayList out,
                                  java.util.Random rnd)
Description copied from interface: Emitter
Pseudorandomly generates, for the given input, a set of origins for this emitter. They are generated such that they can be used for Monte Carlo-based photon tracing algorithms in the following way.

At first, we consider the case where the emitter is in fact a light source. Let L(x, ω, ν) be the emitted spectral radiance for the frequency ν at the light's surface point x in direction ω. The radiant exitance (emitted spectral power per area) at x is defined as

L0(x, ν) = ∫ cos θ L(x, ω, ν) dω
where θ is the angle between the surface normal and ω. Now the directional distribution of the emitted radiance at x can be described by the density
L1(x, ω, ν) = L(x, ω, ν) / L0(x, ν)
so that the radiance is split into
L(x, ω, ν) = L0(x, ν) L1(x, ω, ν)
Let oi and si denote the origins and spectra of the N generated rays (N = rays.size). Then for a function f(x, ν) which is to be integrated over the light surface, the sum
1 / N ∑i si(ν) f(oi, ν)
is an unbiased estimate for the integral
∫ L0(x, ν) f(x, ν) dA
The integral ranges over the whole surface A of the light source. As a consequence, the spectrum of a ray is to be considered as the ray's radiant spectral power.

Now if the emitter is a sensor, let W(x, ω, ν) be the emitted spectral importance for frequency ν at the sensors's surface point x in direction ω. The quantities W0(x, ν) and W1(x, ω, ν) are defined similarly to the case of light sources:

W0(x, ν) = ∫ cos θ W(x, ω, ν) dω
W(x, ω, ν) = W0(x) W1(x, ω, ν)
The formulas for light sources are valid for sensors if the L-quantites are replaced by the corresponding W-quantities.

Let px be the probability density used for the ray origin, then the field originDensity is set to px(oi) for each ray. For emitters which are concentrated at a single point (e.g., point lights) px is not a regular function, the value originDensity will be set to a multiple of Scattering.DELTA_FACTOR.

The ray properties which are not mentioned in the given formulas are neither used nor modified. These are the direction and its density.

Specified by:
generateRandomOrigins in interface Emitter
Parameters:
env - the environment
out - the outgoing rays to be generated
rnd - pseudorandom generator

generateRandomRays

public void generateRandomRays(Environment env,
                               Vector3f out,
                               Spectrum specOut,
                               RayList rays,
                               boolean adjoint,
                               java.util.Random rnd)
Description copied from interface: Scattering
Pseudorandomly generates, for the given input, a set of scattered rays. The scattered rays are generated such that they can be used for a Monte Carlo integration of a function f(ω;ν) over cos θ BSDF(ωi, νi; ωo, νo) in the following way: Let di and si denote the directions and spectra of the N generated rays (N = rays.size). Then, for every frequency ν the sum
1 / N ∑i si(ν) f(di; ν)
is an unbiased estimate for the integral
∫ cos θ f(ω; ν) g(ω, ν; out, μ) specOut(μ) dμ dω
θ is the angle between the surface normal and ω. The domain of integration is the whole sphere, since the bidirectional scattering distribution includes both reflection and transmission (BSDF = BRDF + BTDF).

If this Scattering instance is in fact a Light source, adjoint is true, and the BSDF is defined as BSDF(out, μ; ω, ν) = L1(ω, ν) δ(μ - ν), i.e., the directional distribution of the emitted radiance at env.point, see Emitter. In this case, out is not used.

If this Scattering instance is in fact a Sensor, adjoint is false, and the BSDF is defined as BSDF(ω, ν; out, μ) = W1(ω, ν) δ(μ - ν), i.e., the directional distribution of the emitted importance at env.point, see Emitter. In this case, out is not used.

Let pω be the probability density used for the ray direction (measured with respect to solid angle ω), then the field directionDensity of the ray i is set to pω(di). For ideal specular reflection or transmission, or for directional lights or sensors, pω is not a regular function, the value directionDensity will be set to a multiple of Scattering.DELTA_FACTOR.

The ray properties which are not mentioned in the given formulas are neither used nor modified. These are the origin and its density.

Specified by:
generateRandomRays in interface Scattering
Parameters:
env - the environment for scattering
out - the direction unit vector of the outgoing ray (i.e., pointing away from the surface)
specOut - the spectrum of the outgoing ray
rays - the rays to be generated
adjoint - represents out a light ray or an importance ray?
rnd - pseudorandom generator
See Also:
Scattering.computeBSDF(de.grogra.ray.physics.Environment, javax.vecmath.Vector3f, de.grogra.ray.physics.Spectrum, javax.vecmath.Vector3f, boolean, de.grogra.ray.physics.Spectrum)

getAverageColor

public int getAverageColor()
Description copied from interface: Scattering
Returns an average color for the scattering entity. This color is used for simplified graphical representations of the corresponding objects.

Specified by:
getAverageColor in interface Scattering
Returns:
an average color in Java's default sRGB color space, encoded as an int (0xAARRGGBB).

getExponent

public float getExponent()

getFlags

public int getFlags()
Specified by:
getFlags in interface Scattering

getNTypeImpl

protected Node.NType getNTypeImpl()
Description copied from class: Node
This method returns the Node.NType which describes the managed fields of the class of this node. This method has to be implemented in every concrete subclass.

Overrides:
getNTypeImpl in class Null
Returns:
type describing the managed fields of the class of this node

getRadius

public float getRadius()

getUVForVertex

public float[] getUVForVertex(Environment env,
                              Point3d vertex)
Specified by:
getUVForVertex in interface Sensor

isTwoSided

public boolean isTwoSided()

newInstance

protected Node newInstance()
Description copied from class: Node
This method returns a new instance of the class of this node. This method has to be implemented in every concrete subclass.

Overrides:
newInstance in class Null
Returns:
new instance of class of this node

pick

public void pick(java.lang.Object object,
                 boolean asNode,
                 Point3d origin,
                 Vector3d direction,
                 Matrix4d t,
                 PickList list)
Description copied from interface: Pickable
Computes intersections of a given ray with this shape.

Specified by:
pick in interface Pickable
Parameters:
object - the object of which this shape is an attribute
asNode - true iff object is a node
origin - the origin of the ray, in local coordinates
direction - the direction of the ray, in local coordinates
t - the transformation from local coordinates to world coordinates
list - the list to which intersections have to be added

setExponent

public void setExponent(float value)

setRadius

public void setRadius(float value)

setTwoSided

public void setTwoSided(boolean value)