Just use an instance of Group, but not BranchGroup. The BranchGroup is reserved to be the very root of a branch in the scenegraph. In general a loader loads 3D models, which're not to be placed into to scenegraph as root branch (BranchGroup). But some loaders (or a single load) actually load a whole level, so maybe an additional method in any loader would make sense, which loads a scene as BranchGroup or so. What do you think?
This code does not compile:
1 2 3 4 5 6
| final Group sceneBranchGroup = scene.getSceneGroup ( ); if ( sceneBranchGroup != null ) { locale.addBranchGraph ( ( BranchGroup ) sceneBranchGroup ); } |
scene.getSceneGroup() returns a Group.
locale.addBranchGraph() takes a BranchGroup as its argument.
BranchGroup is not a subclass of Group so I cannot do the cast.