cz.cuni.jagrlib
Class CSGNode

java.lang.Object
  extended by cz.cuni.jagrlib.DefaultSceneNode
      extended by cz.cuni.jagrlib.CSGCommonNode
          extended by cz.cuni.jagrlib.CSGNode
All Implemented Interfaces:
IntersectionAttributes, SceneNode

public class CSGNode
extends CSGCommonNode

Inner node of CSG scene representation.

Since:
0.11
See Also:
CSGNode.java, CSGLeaf

Nested Class Summary
protected static class CSGNode.Child
           
 
Field Summary
protected  java.util.ArrayList<CSGNode.Child> ch
          Array of child-references.
 int op
          Set operation code.
 
Fields inherited from class cz.cuni.jagrlib.CSGCommonNode
attr, order, parent, root
 
Fields inherited from class cz.cuni.jagrlib.DefaultSceneNode
serial
 
Fields inherited from interface cz.cuni.jagrlib.SceneNode
ATTR_BSSRDF, ATTR_COLOR, ATTR_TEXTURE
 
Constructor Summary
CSGNode(int _op)
          Initializing constructor.
 
Method Summary
 SceneNode getChild(int i)
          Returns the given child node.
 TrMatrix getChildMatrix(int i)
          Returns transformation matrix for the given child node.
 TrMatrix getChildMatrixInv(int i)
          Returns inverse transformation matrix for the given child node.
 int children()
          Returns number of child nodes.
 int insertChild(SceneNode child, TrMatrix m, TrMatrix mInv)
          Inserts a new child node.
 java.util.List<MicroFacet> intersection(double[] P0, double[] P1)
          Computes all intersections of the given ray with sub-scene surface.
protected  java.util.List<MicroFacet> intersection(double[] P0, double[] P1, int i)
          Computes all intersections of the given ray with one child scene.
 int removeChild(int i)
          Removes the given child node.
 
Methods inherited from class cz.cuni.jagrlib.CSGCommonNode
assertAttributes, getAttribute, getAttributes, getOrder, getParent, isObjectRoot, selfAttribute, setAttribute, setObjectRoot, setOrder, setParent
 
Methods inherited from class cz.cuni.jagrlib.DefaultSceneNode
getSerial, setSerial
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

op

public int op
Set operation code.

See Also:
BinaryOperation

ch

protected java.util.ArrayList<CSGNode.Child> ch
Array of child-references.

Constructor Detail

CSGNode

public CSGNode(int _op)
Initializing constructor.

Method Detail

children

public final int children()
Returns number of child nodes.

Specified by:
children in interface SceneNode
Overrides:
children in class DefaultSceneNode
Returns:
Number of child nodes (0 for leaf node).
See Also:
getChild(int), getChildMatrix(int), getChildMatrixInv(int)

getChild

public SceneNode getChild(int i)
Returns the given child node.

Specified by:
getChild in interface SceneNode
Overrides:
getChild in class DefaultSceneNode
Parameters:
i - Order of the requested node (from 0 to children()-1).
Returns:
The requested node or null.
See Also:
children(), getChildMatrix(int), getChildMatrixInv(int)

getChildMatrix

public TrMatrix getChildMatrix(int i)
Returns transformation matrix for the given child node.

Specified by:
getChildMatrix in interface SceneNode
Overrides:
getChildMatrix in class DefaultSceneNode
Parameters:
i - Order of the child node.
Returns:
Transformation matrix from the child's coordinate system to this node's one. null stands for identity.
See Also:
children(), getChild(int), getChildMatrixInv(int)

getChildMatrixInv

public TrMatrix getChildMatrixInv(int i)
Returns inverse transformation matrix for the given child node.

Specified by:
getChildMatrixInv in interface SceneNode
Overrides:
getChildMatrixInv in class DefaultSceneNode
Parameters:
i - Order of the child node.
Returns:
Transformation matrix from this node's coordinate system to child's one. null stands for identity.
See Also:
children(), getChild(int), getChildMatrix(int)

insertChild

public int insertChild(SceneNode child,
                       TrMatrix m,
                       TrMatrix mInv)
Inserts a new child node.

Specified by:
insertChild in interface SceneNode
Overrides:
insertChild in class DefaultSceneNode
Parameters:
child - The new child node.
m - Transformation matrix for the new child node (transformation from child's coordinate system to this node's one). Can be null, even for non-trivial mInv.
mInv - Inverse transformation matrix for the new child node (transformation from this node's coordinate system to child's one). Can be null, even for non-trivial m.
Returns:
Order of the inserted child node (or -1 in case of failure).
See Also:
removeChild(int), children()

removeChild

public int removeChild(int i)
Removes the given child node.

Specified by:
removeChild in interface SceneNode
Overrides:
removeChild in class DefaultSceneNode
Parameters:
i - Order of the child node to be removed.
Returns:
Number of child nodes after the remove-operation.
See Also:
insertChild(cz.cuni.jagrlib.SceneNode, cz.cuni.jagrlib.TrMatrix, cz.cuni.jagrlib.TrMatrix), children()

intersection

protected java.util.List<MicroFacet> intersection(double[] P0,
                                                  double[] P1,
                                                  int i)
Computes all intersections of the given ray with one child scene. W/o any checks.

Parameters:
P0 - Ray origin (double[3]).
P1 - Direction vector of the ray (double[3]).
i - Order of the child node.
Returns:
List of all intersections with the given child-scene.

intersection

public java.util.List<MicroFacet> intersection(double[] P0,
                                               double[] P1)
Computes all intersections of the given ray with sub-scene surface.

Specified by:
intersection in interface SceneNode
Overrides:
intersection in class DefaultSceneNode
Parameters:
P0 - Ray origin (double[3] or double[4]).
P1 - Direction vector of the ray (double[3] or double[4]).
Returns:
List of all intersections with the sub-scene.