如何在使用canvas3d对象创建的SimpleUniverse实例上设置边界?
我尝试了下面的代码,但如果我尝试设置边界,我会得到“Capability not set exception”,如果我尝试设置写入边界的能力,我会得到“Restricted access exception”。
这是我的代码:
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);
请帮忙!
答案 0 :(得分:3)
我明白了。而不是像这样设置宇宙:
GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
Canvas3D canvas3d = new Canvas3D(config);
SimpleUniverse universe = new SimpleUniverse(canvas3d);
我自己设置了ViewingPlatform
,然后用它创建了宇宙:
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);