Skip to main content

set capabilities on a loaded universe

1 reply [Last post]
alxcer
Offline
Joined: 2010-04-22

Hi all,

I'm loading an Universe using the SceneGraphStreamReader from a file.
The code looks like this :

URL url=new URL(getCodeBase().toString()+j3d_File);
InputStream input_stream = url.openStream();
SceneGraphStreamReader reader = new SceneGraphStreamReader(input_stream);
univ=reader.readUniverse(canvas3D);

It works fine. The problem is that I want to change the capabilities of some BranchGroups before they are made live. I want to add new components to those groups.
Is there a way to load the universe, change capabilities, add new things and then set it to the canvas3D? So I can see it modified

Thanks!

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
robroche
Offline
Joined: 2010-05-19

Hey,
Reading the JavaDocs for the SceneGraphStreamReader Class here:
download.java.net/media/java3d/javadoc/1.3.2/com/sun/j3d/utils/scenegraph/io/SceneGraphStreamReader.html#readUniverse%28%29

It seems as though when the Universe file is read in, it will automatically add the BranchGroups and everything else to the Universe BEFORE returning.
My suggestion to you then would be either:
Create your own SceneGraphStreamReader where you only return the root of the SceneGraph with out adding it to anything
or
You simply save the universe with the capabilities set to ALLOW_CHILDREN_EXTEND, and anything else you need(maybe ALLOW_TRANSFORM_WRITE). Then the next time you read it in, you can make the changes without Java3D complaining.

Hope this helps,
-- Rob