> From: Olivier fillon <[EMAIL PROTECTED]>
> Subject: [JAVA3D] IllegalSharingException: SharedGroup: Illegal leaf nodes ??

> When adding a getSceneGroup() obtained from a vrml loader, I get the
> following exception:
>
> 11/2/99 12:10 PM, error: javax.media.j3d.IllegalSharingException:
> SharedGroup: Illegal leaf nodes
> ...

This is a bug in the VRML loader, but the best solution may be to modify your
VRML.  If you send me the VRML file, I can try to figure out where it is going
wrong.

Here are the gory details:

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

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to