cz.cuni.jagrlib
Interface SceneNode

All Superinterfaces:
IntersectionAttributes
All Known Implementing Classes:
CSGCommonNode, CSGLeaf, CSGNode, DefaultSceneNode

public interface SceneNode
extends IntersectionAttributes

Abstract node of (hierarchical) 3D scene representation.

Since:
0.11
See Also:
SceneNode.java, CSGNode, CSGLeaf

Field Summary
static java.lang.String ATTR_BSSRDF
          Key for light-model attribute (BSSRDF).
static java.lang.String ATTR_COLOR
          Key for color attribute (double[]).
static java.lang.String ATTR_TEXTURE
          Key for texture attribute (Texture or List<Texture>).
 
Method Summary
 java.lang.Object getAttribute(java.lang.String key)
          Returns the given attribute (defined in this SceneNode or inherited from some parent node).
 java.util.List<java.lang.Object> getAttributes(java.lang.String key)
          Returns the whole inherence-sequence for the given attribute.
 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 getOrder()
          Returns order of this SceneNode in its parent.
 SceneNode getParent()
          Returns the parent of this SceneNode.
 int getSerial()
          Sets serial number of the current test.
 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 this sub-scene.
 boolean isObjectRoot()
          Returns true if this node is root of object (component) hierarchy.
 int removeChild(int i)
          Removes the given child node.
 boolean selfAttribute(java.lang.String key)
          Is the given attribute defined in the SceneNode itself or is it inherited?
 java.lang.Object setAttribute(java.lang.String key, java.lang.Object value)
          Defines the given attribute (key-value pair) in the SceneNode.
 void setObjectRoot(boolean root)
          Sets this node as root for the object (component).
 void setOrder(int ord)
          Sets order of this SceneNode in its parent.
 void setParent(SceneNode par)
          Sets handle to the parent node.
 void setSerial(int serial)
          Returns serial number assigned to the node.
 
Methods inherited from interface cz.cuni.jagrlib.IntersectionAttributes
assertAttributes
 

Field Detail

ATTR_COLOR

static final java.lang.String ATTR_COLOR
Key for color attribute (double[]).

See Also:
Constant Field Values

ATTR_TEXTURE

static final java.lang.String ATTR_TEXTURE
Key for texture attribute (Texture or List<Texture>).

See Also:
Constant Field Values

ATTR_BSSRDF

static final java.lang.String ATTR_BSSRDF
Key for light-model attribute (BSSRDF).

See Also:
Constant Field Values
Method Detail

getAttribute

java.lang.Object getAttribute(java.lang.String key)
Returns the given attribute (defined in this SceneNode or inherited from some parent node).

Returned object can be an original data object and must not be altered outside this SceneNode instance.

Parameters:
key - Key-string.
Returns:
Attribute object or null. Must not be altered!
See Also:
getAttributes(java.lang.String), setAttribute(java.lang.String, java.lang.Object), selfAttribute(java.lang.String)

selfAttribute

boolean selfAttribute(java.lang.String key)
Is the given attribute defined in the SceneNode itself or is it inherited?

Parameters:
key - Key-string.
Returns:
true if the node defines the given attribute.
See Also:
getAttribute(java.lang.String), setAttribute(java.lang.String, java.lang.Object), getAttributes(java.lang.String)

setAttribute

java.lang.Object setAttribute(java.lang.String key,
                              java.lang.Object value)
Defines the given attribute (key-value pair) in the SceneNode.

Parameters:
key - Key-string.
value - Attribute value (arbitrary type).
Returns:
The old attribute value (defined in the SceneNode itself!) or null.
See Also:
getAttribute(java.lang.String), selfAttribute(java.lang.String), getAttributes(java.lang.String)

getAttributes

java.util.List<java.lang.Object> getAttributes(java.lang.String key)
Returns the whole inherence-sequence for the given attribute.

Parameters:
key - Key-string.
Returns:
List of attribute values: result[0] .. definition in the node itself, result[1] .. definition in parent node, result[2] .. definition in "grand-parent" node, etc.
See Also:
getAttribute(java.lang.String), setAttribute(java.lang.String, java.lang.Object), selfAttribute(java.lang.String)

children

int children()
Returns number of child nodes.

Returns:
Number of child nodes (0 for leaf SceneNode).
See Also:
getChild(int), getChildMatrix(int)

getChild

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

Parameters:
i - Order of the requested node (from 0 to children()-1).
Returns:
The requested SceneNode or null.
See Also:
children(), getChildMatrix(int), getChildMatrixInv(int)

getChildMatrix

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

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

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

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

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

Parameters:
child - The new child SceneNode.
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

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

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

getParent

SceneNode getParent()
Returns the parent of this SceneNode.

Returns:
The parend node or null for scene-root.
See Also:
setParent(cz.cuni.jagrlib.SceneNode), getOrder(), children(), getChild(int)

setParent

void setParent(SceneNode par)
Sets handle to the parent node.

Parameters:
par - Parent node (or null).
See Also:
getParent()

getOrder

int getOrder()
Returns order of this SceneNode in its parent.

Returns:
Order of this node as a child (or -1 for scene-root).
See Also:
setOrder(int), getParent()

setOrder

void setOrder(int ord)
Sets order of this SceneNode in its parent.

Parameters:
ord - The new order.
See Also:
getOrder()

isObjectRoot

boolean isObjectRoot()
Returns true if this node is root of object (component) hierarchy.

See Also:
setObjectRoot(boolean)

setObjectRoot

void setObjectRoot(boolean root)
Sets this node as root for the object (component).

Parameters:
root - Should this node be treated as root?
See Also:
isObjectRoot()

getSerial

int getSerial()
Sets serial number of the current test. Used in intersection testing.


setSerial

void setSerial(int serial)
Returns serial number assigned to the node.


intersection

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

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.