Xj3D 2.0 VRML/X3D Code API

org.web3d.vrml.renderer
Class NodeCopier

java.lang.Object
  extended by org.web3d.vrml.renderer.NodeCopier
All Implemented Interfaces:
SceneGraphTraversalSimpleObserver

public class NodeCopier
extends java.lang.Object
implements SceneGraphTraversalSimpleObserver

A class that is used to create real instances of protos from their definitions.

The creator strips the definition apart and builds a runtime node based on the details and the node factory provided. The creator can handle one instance at a time, athough it will correctly parse and build nested proto declarations without extra effort.

We have a small conundrum to deal with - if the proto definition contains SF/MFNode fields, we don't know whether the values should be also generated as real runtime nodes too. Maybe the usage of this node will provide values that are dealt with after this class has finished. Other times, these defaul values must be used. For this implementation, we have gone with the safety-first approach: Always parse the definition of any SF or MFNode field and turn those into runtime instances. Although this may create extra garbage, there seems to be no nice way of dealing with this issue without a completely different architecture for the library.

If, during the traversal processing we discover that the traversed node is an instance of a J3D implementation node, we do not process it any further. The basic assumption here is that the node is a USE of a j3D structure.

Note: Under the current implementation, EXTERNPROTOs are not yet catered for.

Version:
$Revision: 1.17 $
Author:
Justin Couch

Method Summary
 void observedNode(VRMLNodeType parent, VRMLNodeType child, int field, boolean used)
          Notification of a child node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

observedNode

public void observedNode(VRMLNodeType parent,
                         VRMLNodeType child,
                         int field,
                         boolean used)
Notification of a child node.

Specified by:
observedNode in interface SceneGraphTraversalSimpleObserver
Parameters:
parent - The parent node of this node
child - The child node that is being observed
field - The index of the child field in its parent node
used - true if the node reference is actually a USE

Xj3D 2.0 VRML/X3D Code API

Copyright © 2001 - 2006 Web3D Consortium