Class ProtoCopier
- All Implemented Interfaces:
SceneGraphTraversalSimpleObserver
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, although 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 default 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.
Note: Under the current implementation, EXTERNPROTOs are not yet catered for.
- Version:
- $Revision: 1.24 $
- Author:
- Justin Couch
-
Constructor Summary
ConstructorsConstructorDescriptionProtoCopier
(VRMLNodeFactory fac, String worldURL) Create a new copier that uses the given world URL and node factory. -
Method Summary
Modifier and TypeMethodDescriptionvoid
observedNode
(VRMLNodeType parent, VRMLNodeType child, int field, boolean used) Notification of a child node.void
protoNode
(VRMLNodeType parent, CRProtoInstance proto) Notification of a completed proto instance that needs to be registered with its parent node.void
setErrorReporter
(org.j3d.util.ErrorReporter reporter) Register an error reporter with the engine so that any errors generated by the script code can be reported in a nice, pretty fashion.void
Set the frame state manager to use for the builder after this point.
-
Constructor Details
-
ProtoCopier
Create a new copier that uses the given world URL and node factory.- Parameters:
fac
- The factory to use (Must generate VRMLNodeType instances)worldURL
-
-
-
Method Details
-
setFrameStateManager
Set the frame state manager to use for the builder after this point. Set a value of null it will clear the currently set items.- Parameters:
fsm
- The state manager to use
-
setErrorReporter
public void setErrorReporter(org.j3d.util.ErrorReporter reporter) Register an error reporter with the engine so that any errors generated by the script code can be reported in a nice, pretty fashion. Setting a value of null will clear the currently set reporter. If one is already set, the new value replaces the old.- Parameters:
reporter
- The instance to use or null
-
observedNode
Notification of a child node.- Specified by:
observedNode
in interfaceSceneGraphTraversalSimpleObserver
- Parameters:
parent
- The parent node of this nodechild
- The child node that is being observedfield
- The index of the child field in its parent nodeused
- true if the node reference is actually a USE
-
protoNode
Notification of a completed proto instance that needs to be registered with its parent node.- Parameters:
parent
- The parent node of this nodeproto
- The proto node that has been found
-