Hi Jonathan,
There is a couple of Capability not set correctly. Attach
is the file which fixed the problem.
Besides, there is a bug in Java3D which output
misleading capabilibityNotSetException message
"Node: no capability to read Pickable"
instead of
"Node: no capability to read Collidable"
when ALLOW_COLLIDABLE_READ not set.
Bug 4730461
- Incorrect capabilityNotSetException message output for Node.getCollidable
is submitted for this.
Thanks for your bug report.
- Kelvin
-----------------------
Java 3D Team
Sun Microsystems Inc.
Jonathan Smolarski wrote:
> Hi, <<...>>
>
> I'm trying to use the SceneGraphFileWriter to save simpleUniverse on a
> file.
> Problem is : I keep getting CapabilityNotSetException even when I set
> all capabilities on all Group nodes of the scene.
> I join a simple example of what I do. If someone could tell me what I
> made wrong, I would be very thankfull.
>
>
> Cordialement, Jonathan Smolarski.
> Mail : [EMAIL PROTECTED]
>
> I watch myself drown
> In the blue aura
> Of mine and I see
> The swans leave the pond
> ...And Oceans, The Black Vagabond and the Swan of Two Heads
>
/*
* Main.java
*
* Created on 24 juillet 2002, 15:07
*/
import javax.media.j3d.*;
import java.awt.GraphicsConfiguration;
import com.sun.j3d.utils.geometry.ColorCube;
import com.sun.j3d.utils.universe.SimpleUniverse;
import com.sun.j3d.utils.scenegraph.io.*;
import java.io.File;
/**
*
* @author JS
*/
public class Main {
/** Creates a new instance of Main */
public Main() {
GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
Canvas3D canvas3D = new Canvas3D(config);
BranchGroup scene = createSceneGraph();
scene.setCapability(BranchGroup.ALLOW_DETACH);
scene.setCapability(BranchGroup.ALLOW_BOUNDS_READ);
scene.setCapability(BranchGroup.ALLOW_PICKABLE_READ);
scene.setCapability(BranchGroup.ALLOW_COLLISION_BOUNDS_READ);
scene.setCapability(BranchGroup.ALLOW_AUTO_COMPUTE_BOUNDS_READ);
scene.setCapability(BranchGroup.ENABLE_PICK_REPORTING);
scene.setCapability(BranchGroup.ENABLE_COLLISION_REPORTING);
scene.setCapability(BranchGroup.ALLOW_COLLIDABLE_READ);
scene.setCapability(BranchGroup.ALLOW_CHILDREN_READ);
// SimpleUniverse is a Convenience Utility class
SimpleUniverse simpleU = new SimpleUniverse(canvas3D);
// This will move the ViewPlatform back a bit so the
// objects in the scene can be viewed.
simpleU.getViewingPlatform().setNominalViewingTransform();
simpleU.addBranchGraph(scene);
try {
File f = new File("test.bg");
SceneGraphFileWriter s = new SceneGraphFileWriter(f, simpleU, true,
"Simple Test", null);
s.writeBranchGraph(scene);
s.close();
} catch(Exception e) {
e.printStackTrace();
}
}
public BranchGroup createSceneGraph() {
// Create the root of the branch graph
BranchGroup objRoot = new BranchGroup();
objRoot.setCapability(BranchGroup.ALLOW_DETACH);
objRoot.setCapability(BranchGroup.ALLOW_BOUNDS_READ);
objRoot.setCapability(BranchGroup.ALLOW_PICKABLE_READ);
objRoot.setCapability(BranchGroup.ALLOW_COLLISION_BOUNDS_READ);
objRoot.setCapability(BranchGroup.ALLOW_AUTO_COMPUTE_BOUNDS_READ);
objRoot.setCapability(BranchGroup.ENABLE_PICK_REPORTING);
objRoot.setCapability(BranchGroup.ENABLE_COLLISION_REPORTING);
ColorCube cube = new ColorCube(0.4);
cube.setCapability(Shape3D.ALLOW_BOUNDS_READ);
cube.setCapability(Shape3D.ALLOW_PICKABLE_READ);
cube.setCapability(Shape3D.ALLOW_COLLIDABLE_READ);
cube.setCapability(Shape3D.ALLOW_AUTO_COMPUTE_BOUNDS_READ);
cube.setCapability(Shape3D.ALLOW_COLLISION_BOUNDS_READ);
objRoot.addChild(cube);
return objRoot;
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Main m = new Main();
}
}