gpt4 book ai didi

java - 如何在 Java 3d 中设置 Universe 的功能?

转载 作者:行者123 更新时间:2023-12-04 07:04:40 25 4
gpt4 key购买 nike

如何在使用 canvas3d 对象创建的 SimpleUniverse 实例上设置边界?

我尝试了下面的代码,但是如果我尝试设置边界,我会得到一个“能力未设置异常”,如果我尝试设置写入边界的能力,我会得到一个“受限访问异常”。

这是我的代码:

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);

请帮忙!

最佳答案

我想到了。而不是像这样设置宇宙:

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);

关于java - 如何在 Java 3d 中设置 Universe 的功能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1300378/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com