How to install universe capabilities in Java 3d?
How can I set borders for a SimpleUniverse instance created with canvas3d object?
I have tried the code below, but I get either "Option not to set an exception" if I try to set boundaries and an "Restricted exception" if I try to set the option to write boundaries.
Here's my code:
GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
Canvas3D canvas3d = new Canvas3D(config);
SimpleUniverse universe = new SimpleUniverse(canvas3d);
ViewingPlatform viewPlatform = universe.getViewingPlatform();
// Below line throws RestricedAccessException
viewPlatform.setCapability(ViewingPlatform.ALLOW_BOUNDS_WRITE);
// I want to set the bounds, thus the need for the capability above
viewPlatform.setBounds(bounds);
Please, help!
+2
source to share
1 answer
I understood that. Instead of setting up the universe like this:
GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
Canvas3D canvas3d = new Canvas3D(config);
SimpleUniverse universe = new SimpleUniverse(canvas3d);
I installed it myself ViewingPlatform
, then created a universe with it:
GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
Canvas3D canvas3d = new Canvas3D(config);
ViewingPlatform viewingPlatform = new ViewingPlatform();
viewingPlatform.setCapability(ViewingPlatform.ALLOW_BOUNDS_WRITE);
viewingPlatform.setBounds(bounds);
Viewer viewer = new Viewer(canvas3d);
SimpleUniverse universe = new SimpleUniverse(viewingPlatform, viewer);
+3
source to share