kwc,
 
I think you might be experiencing a bug/compatability problem with the VRML loader. Perhaps Doug can suggest a fix?
 
Sincerely,
 
Daniel Selman
 
This is what Doug G. wrote on the subject about 2 months ago:

This problem comes from a difficult problem in the implementation of VRML on Java3D. VRML allows any Node to be DEF'd and then USE'd anywhere else. Java3D has more restrictive sharing policies: the only scene graph elements which can appear multiple times in a scene graph are NodeComponents and SharedGroups.

Further, ShareGroups can't have any of the following node types: Background, Behavior (include Billboards and LODs), Clip, Fog, Soundscape, ViewPlatform. The reason these node types are not allowed in SharedGroups is that they lead to difficult semantic or implementation issues (for example, if a ViewPlatform where in a SharedGroup and that SG appeared multiple times, what does it mean to associate a View with the SG's ViewPlatform?).

The VRML loader handles this difference in policies when the "USE" happens. For VRML nodes which are implemented using NodeComponents (such as Geometry) the USE simply makes a new reference to the NodeComponent. For VRML nodes which map to Java3D Nodes, such as a Group, the loader may return different values. If this is the first usage of the node, a reference to the node is returned. The second time the node is used, the loader looks at the J3D scene graph under the Node to tell if it can be put into a SharedGroup. If the graph does not contain any of the prohibited nodes, then the subgraph is put into a SharedGraph (the previous reference is updated to use a Link/SharedGroup) and a Link to the SharedGroup is returned for the second instance to use. If the graph contains a prohibited node, then the subgraph is cloned, and a clone of the subgraph is returned to the second instance.

Whew! As you can tell, this is a tricky piece of code.

What is happening for your VRML file is that the subgraph being DEF/USE'd contains a Leaf Node which can't appear in a SharedGraph, but the loader is not detecting the case properly, leading to a IllegalSharingException.

The loader needs to be fixed, but the better solution for your application may be to try to find the DEF/USE which is causing the problem and then eliminate the Node which is causing the illegal sharing. For most of the illegal nodes, the the problem with sharing is wierd semantics (this is for the Background,

Clip, Fog, Soundscape and ViewPlatform nodes). There simply isn't a good way of interpreting what these multiple appearances mean, so these nodes shouldn't appear multiple times. If the problem is from a Behavior such as a LOD or Billboard, then the correct solution is for the loader to clone the tree, and we need to fix that bug.

Send me your VRML (if possible) and we'll see what we can find.

Doug Gehringer

Sun Microsystems

-----Original Message-----
From: Discussion list for Java 3D API [mailto:[EMAIL PROTECTED]]On Behalf Of kwc
Sent: 04 January 2000 22:40
To: [EMAIL PROTECTED]
Subject: [JAVA3D] GetNamed

hi,
 
I'm trying to use the getNamedObjects call thats been noted in the mail archive as usable to get references to nodes in a scene.  The particular case is using the vrml97 jar and a HANIM vrml file.   I'm working with a modified version of the Simple example from the VRML examples.  It seems to work fine with a simple vrml file ( a cube for instance) but the HANIM file causes the exception given below.
 
Can anyone comment/hazard a guess at a cause?
 
Thanks.
 
kwc
____________________________
before scene.getNamedObjects
java.lang.NullPointerException
    at javax.media.j3d.LinkRetained.setSharedGroup(LinkRetained.java:46)
    at javax.media.j3d.LinkRetained.clone(LinkRetained.java:216)
    at javax.media.j3d.Link.duplicateNode(Link.java:185)
    at javax.media.j3d.Link.cloneNode(Link.java:109)
    at javax.media.j3d.Leaf.cloneTree(Leaf.java:58)
    at javax.media.j3d.Group.cloneTree(Group.java:361)
    at javax.media.j3d.Group.cloneTree(Group.java:361)
    at javax.media.j3d.Group.cloneTree(Group.java:361)
    at javax.media.j3d.Group.cloneTree(Group.java:361)
    at javax.media.j3d.Group.cloneTree(Group.java:361)
    at javax.media.j3d.Group.cloneTree(Group.java:361)
    at javax.media.j3d.Group.cloneTree(Group.java:361)
    at javax.media.j3d.Group.cloneTree(Group.java:361)
    at javax.media.j3d.Node.cloneTree(Node.java:378)
    at com.sun.j3d.loaders.vrml97.impl.NonSharedNode.getImplNode(NonSharedNode.java:126)
    at com.sun.j3d.loaders.vrml97.impl.ProtoInstance.getImplNode(ProtoInstance.java:145)
    at vrml.BaseNode.getImplNode(BaseNode.java:52)
    at com.sun.j3d.loaders.vrml97.VrmlScene.getNamedObjects(VrmlScene.java:173)
    at SimpleVrml97Viewer.gotoLocation(SimpleVrml97Viewer.java:166)
    at SimpleVrml97Viewer.<init>(SimpleVrml97Viewer.java:121)
    at SimpleVrml97Viewer.main(SimpleVrml97Viewer.java:321)
    at symantec.tools.debug.Agent.runMain(Native Method)
    at symantec.tools.debug.MainThread.run(Agent.java:48)

Reply via email to