cz.cuni.jagrlib
Class MicroFacet

java.lang.Object
  extended by cz.cuni.jagrlib.MicroFacet
All Implemented Interfaces:
java.lang.Comparable<MicroFacet>

public class MicroFacet
extends java.lang.Object
implements java.lang.Comparable<MicroFacet>

Micro-facet = microscopic piece of solid surface. This data container is used for ray-surface intersections.

Since:
0.11
See Also:
MicroFacet.java, Solid, BSSRDF

Field Summary
 BSSRDF bssrdf
          Optical model (BRDF).
 double[] color
          Surface color.
 double[] coord
          3D world coordinates of the intersection point.
 boolean enter
          true if the ray enters solid interior (transition from air to solid material).
 double epsilon
          Epsilon constant used in geometric-equality tests (local-space coordinates).
 double epsilon2
          epsilon squared.
 int face
          Id of intersected face (for Brep intersections).
 boolean front
          true if the ray enters solid geometry from outside.
 IntersectionAttributes geometry
          Surface which a ray has intersection with.
 java.lang.Object geometryTmp
          Temporary data used for additional geometric computation.
 double[] locCoord
          3D local coordinates of the intersection point.
 double[] normal
          Normal vector in the point of intersection (points outside the object = to the air).
 double[] objCoord
          3D object coordinates of the intersection point.
 IntersectionAttributes sceneNode
          Associated scene node (solid interior).
 double t
          Parameter of the intersection point (intermediate CSG results are of both signs, definitive results should be positive).
 double[] texCoord
          2D (texture) coordinates of the intersection point (relative to the surface).
 java.util.List<Texture> textures
          List of textures which can be applicated sequentially.
 TrMatrix toObject
          Transformation matrix from local coordinates to object (component) coordinates.
 TrMatrix toWorld
          Transformation matrix from local coordinates to world coordinates.
 double[] tu
          Surface tangent vector in direction of U.
 double[] tv
          Surface tangent vector in direction of V.
 int valid
          Bit-mask declaring validity of individual data items (VALID_* constants).
static int VALID_BSSRDF
          Is BRDF object (#brdf) valid?
static int VALID_COLOR
          Is surface color (color) valid?
static int VALID_COORD
          Are 3D world coordinates (coord) valid?
static int VALID_LOC_COORD
          Are 3D local coordinates (locCoord) valid?
static int VALID_NORMAL
          Is normal vector (normal) valid?
static int VALID_OBJ_COORD
          Are 3D object coordinates (objCoord) valid?
static int VALID_TANGENT
          Are surface tangent vectors (tu, tv) valid?
static int VALID_TEX_COORD
          Are 2D texture coordinates (texCoord) valid?
static int VALID_TEXTURES
          Is list of textures (textures) valid?
static int VALID_TO_OBJECT
          Is leaf -> object (component) transform (toObject) valid?
static int VALID_TO_WORLD
          Is leaf -> world transform (toWorld) valid?
 
Constructor Summary
MicroFacet()
           
 
Method Summary
 int assertAttributes(int attributes)
          Computes all requested micro-facet's parameters.
static java.util.List<MicroFacet> booleanOp(java.util.List<MicroFacet> a, java.util.List<MicroFacet> b, int op)
          Merge two lists of MicroFacets using the given set operation.
 int compareTo(MicroFacet mf)
          Natural ordering: ascending [ t ].
 boolean far(double t0, double dirLenSquare)
          Compares the given t0 against the stored intersection.
 boolean far(double t0, double[] dir)
          Compares the given t0 against the stored intersection.
 boolean near(double t0, double dirLenSquare)
          Compares the given t0 against the stored intersection.
 boolean near(double t0, double[] dir)
          Compares the given t0 against the stored intersection.
protected  void normalFromTangent()
          Computes normal vector from valid (and world-transformed) tangent vectors.
 void setEpsilon(double eps)
          Sets local epsilon used for close-priximity tests.
 void setEpsilon(double eps, double epsSquared)
          Sets local epsilons used for close-priximity tests.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VALID_COORD

public static final int VALID_COORD
Are 3D world coordinates (coord) valid?

See Also:
Constant Field Values

VALID_LOC_COORD

public static final int VALID_LOC_COORD
Are 3D local coordinates (locCoord) valid?

See Also:
Constant Field Values

VALID_OBJ_COORD

public static final int VALID_OBJ_COORD
Are 3D object coordinates (objCoord) valid?

See Also:
Constant Field Values

VALID_TEX_COORD

public static final int VALID_TEX_COORD
Are 2D texture coordinates (texCoord) valid?

See Also:
Constant Field Values

VALID_NORMAL

public static final int VALID_NORMAL
Is normal vector (normal) valid?

See Also:
Constant Field Values

VALID_TANGENT

public static final int VALID_TANGENT
Are surface tangent vectors (tu, tv) valid?

See Also:
Constant Field Values

VALID_TO_WORLD

public static final int VALID_TO_WORLD
Is leaf -> world transform (toWorld) valid?

See Also:
Constant Field Values

VALID_TO_OBJECT

public static final int VALID_TO_OBJECT
Is leaf -> object (component) transform (toObject) valid?

See Also:
Constant Field Values

VALID_COLOR

public static final int VALID_COLOR
Is surface color (color) valid?

See Also:
Constant Field Values

VALID_BSSRDF

public static final int VALID_BSSRDF
Is BRDF object (#brdf) valid?

See Also:
Constant Field Values

VALID_TEXTURES

public static final int VALID_TEXTURES
Is list of textures (textures) valid?

See Also:
Constant Field Values

valid

public int valid
Bit-mask declaring validity of individual data items (VALID_* constants).


t

public double t
Parameter of the intersection point (intermediate CSG results are of both signs, definitive results should be positive).


enter

public boolean enter
true if the ray enters solid interior (transition from air to solid material).


front

public boolean front
true if the ray enters solid geometry from outside.


coord

public double[] coord
3D world coordinates of the intersection point.


locCoord

public double[] locCoord
3D local coordinates of the intersection point.


objCoord

public double[] objCoord
3D object coordinates of the intersection point.


texCoord

public double[] texCoord
2D (texture) coordinates of the intersection point (relative to the surface).


normal

public double[] normal
Normal vector in the point of intersection (points outside the object = to the air).


tu

public double[] tu
Surface tangent vector in direction of U.


tv

public double[] tv
Surface tangent vector in direction of V.


face

public int face
Id of intersected face (for Brep intersections).


toWorld

public TrMatrix toWorld
Transformation matrix from local coordinates to world coordinates.


toObject

public TrMatrix toObject
Transformation matrix from local coordinates to object (component) coordinates.


color

public double[] color
Surface color. This array is copy of an original color and might be altered!


bssrdf

public BSSRDF bssrdf
Optical model (BRDF).

See Also:
#material

geometry

public IntersectionAttributes geometry
Surface which a ray has intersection with.


geometryTmp

public java.lang.Object geometryTmp
Temporary data used for additional geometric computation.


sceneNode

public IntersectionAttributes sceneNode
Associated scene node (solid interior).


textures

public java.util.List<Texture> textures
List of textures which can be applicated sequentially.


epsilon

public double epsilon
Epsilon constant used in geometric-equality tests (local-space coordinates).


epsilon2

public double epsilon2
epsilon squared.

Constructor Detail

MicroFacet

public MicroFacet()
Method Detail

setEpsilon

public void setEpsilon(double eps)
Sets local epsilon used for close-priximity tests. Can be solid-dependent.


setEpsilon

public void setEpsilon(double eps,
                       double epsSquared)
Sets local epsilons used for close-priximity tests. Can be solid-dependent.


normalFromTangent

protected void normalFromTangent()
Computes normal vector from valid (and world-transformed) tangent vectors.


assertAttributes

public int assertAttributes(int attributes)
Computes all requested micro-facet's parameters.

Parameters:
attributes - Bit-mask of the requested attributes (see VALID_* constants).
Returns:
Attributes which were not computed.
See Also:
Solid

booleanOp

public static java.util.List<MicroFacet> booleanOp(java.util.List<MicroFacet> a,
                                                   java.util.List<MicroFacet> b,
                                                   int op)
Merge two lists of MicroFacets using the given set operation.

Parameters:
a - Left operand.
b - Right operand.
op - Set operation code (BinaryOperation.BIN_*).
See Also:
BinaryOperation

near

public final boolean near(double t0,
                          double[] dir)
Compares the given t0 against the stored intersection. Uses local-space epsilon tolerance and provided direction vector.

Returns:
true if this intersection is nearer than t0.

near

public final boolean near(double t0,
                          double dirLenSquare)
Compares the given t0 against the stored intersection. Uses local-space epsilon tolerance and provided direction vector squared length.

Returns:
true if this intersection is nearer than t0.

far

public final boolean far(double t0,
                         double[] dir)
Compares the given t0 against the stored intersection. Uses local-space epsilon tolerance and provided direction vector.

Returns:
true if this intersection is far than t0.

far

public final boolean far(double t0,
                         double dirLenSquare)
Compares the given t0 against the stored intersection. Uses local-space epsilon tolerance and provided direction vector squared length.

Returns:
true if this intersection is far than t0.

compareTo

public int compareTo(MicroFacet mf)
Natural ordering: ascending [ t ].

Specified by:
compareTo in interface java.lang.Comparable<MicroFacet>