Skip to main content

SceneGraphIO Simple Use, Complicated Error

1 reply [Last post]
vengeil
Offline
Joined: 2011-07-14

Hey everyone,

I'm having a problem with SceneGraphIO. Basically, I need to be able to save one BranchGroup into a file and load it later. I write the BranchGroup with SceneGraphFileWriter with no problem. However, when I try to read it back in with SceneGraphFileReader, I get the following error:

java.io.IOException: Error Loading State Class com.sun.j3d.utils.scenegraph.io.state.com.sun.j3d.utils.geometry.SphereState com.sun.j3d.utils.scenegraph.io.state.com.sun.j3d.utils.geometry.SphereState
at com.sun.j3d.utils.scenegraph.io.retained.Controller.readObject(Controller.java:349)
at com.sun.j3d.utils.scenegraph.io.state.javax.media.j3d.GroupState.readObject(GroupState.java:91)
at com.sun.j3d.utils.scenegraph.io.state.javax.media.j3d.TransformGroupState.readObject(TransformGroupState.java:75)
at com.sun.j3d.utils.scenegraph.io.retained.Controller.readObject(Controller.java:368)
at com.sun.j3d.utils.scenegraph.io.state.javax.media.j3d.GroupState.readObject(GroupState.java:91)
at com.sun.j3d.utils.scenegraph.io.retained.Controller.readObject(Controller.java:368)
at com.sun.j3d.utils.scenegraph.io.state.javax.media.j3d.GroupState.readObject(GroupState.java:91)
at com.sun.j3d.utils.scenegraph.io.retained.Controller.readObject(Controller.java:368)
at com.sun.j3d.utils.scenegraph.io.retained.RandomAccessFileControl.readNextBranchGraph(RandomAccessFileControl.java:323)
at com.sun.j3d.utils.scenegraph.io.retained.RandomAccessFileControl.readSingleBranchGraph(RandomAccessFileControl.java:310)
at com.sun.j3d.utils.scenegraph.io.retained.RandomAccessFileControl.readBranchGraph(RandomAccessFileControl.java:247)
at com.sun.j3d.utils.scenegraph.io.SceneGraphFileReader.readBranchGraph(SceneGraphFileReader.java:157)
at StdDraw3D.loadScene3D(StdDraw3D.java:3324)
at IOTester.main(IOTester.java:10)
at __SHELL2.run(__SHELL2.java:6)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at bluej.runtime.ExecServer$3.run(ExecServer.java:774)
java.lang.NullPointerException
at com.sun.j3d.utils.scenegraph.io.retained.RandomAccessFileControl.readBranchGraph(RandomAccessFileControl.java:254)
at com.sun.j3d.utils.scenegraph.io.SceneGraphFileReader.readBranchGraph(SceneGraphFileReader.java:157)
at StdDraw3D.loadScene3D(StdDraw3D.java:3324)
at IOTester.main(IOTester.java:10)

Here is my code for loading and saving:

Save:

try {
SceneGraphFileWriter writer = new SceneGraphFileWriter(file, universe, false, "3D scene saved from StdDraw3D.", null);
writer.writeBranchGraph(offscreenGroup);
writer.close();
StdOut.println("Scene successfully written to " + filename + "!");
}
catch (IOException ioe) { ioe.printStackTrace(); }

Load:

try {
SceneGraphFileReader reader = new SceneGraphFileReader(file);
StdOut.println("Branch graph count = " + reader.getBranchGraphCount());
BranchGroup bg = reader.readBranchGraph(0)[0]; // EXCEPTION IS THROWN HERE
offscreenGroup = bg;
reader.dereferenceBranchGraph(offscreenGroup);
StdOut.println("Scene successfully loaded from " + filename + "!");
}
catch (IOException ioe) { ioe.printStackTrace(); }

What could be the problem? Thanks for any help.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mcneillk
Offline
Joined: 2005-02-03

Please open an issue, and attach a short, self-contained test case demonstrating the bug. I will try to reproduce it, and I can fix the issue.