带有Canvas3D的Java3D立体视图

带有Canvas3D的Java3D立体视图,java,buffer,java-3d,stereo-3d,wavefront,Java,Buffer,Java 3d,Stereo 3d,Wavefront,我目前正在做我的学生项目。其中一部分是在立体视图中渲染加载的.OBJ文件(真正的立体视图,而不是红/蓝阴影)。我能够加载.OBJ文件并在两个视图中渲染它:左眼和右眼,但我仍然坚持在双缓冲区上渲染它。下面是它的样子: 代码如下: public class ObjStereoscope extends JFrame{ Canvas3D c1 = new Canvas3D(SimpleUniverse.getPreferredConfiguration()); Canvas3D c2 = new

我目前正在做我的学生项目。其中一部分是在立体视图中渲染加载的.OBJ文件(真正的立体视图,而不是红/蓝阴影)。我能够加载.OBJ文件并在两个视图中渲染它:左眼和右眼,但我仍然坚持在双缓冲区上渲染它。下面是它的样子:

代码如下:

public class ObjStereoscope extends JFrame{

Canvas3D c1 = new Canvas3D(SimpleUniverse.getPreferredConfiguration());
Canvas3D c2 = new Canvas3D(SimpleUniverse.getPreferredConfiguration());

private SimpleUniverse u = null;
private BranchGroup scene = null;
private JPanel mainPanel = null;

public ObjStereoscope() {
    super();
    GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice device = env.getDefaultScreenDevice();
    init(device);
}

public void init(GraphicsDevice dev) {

    this.setUndecorated(true);
    //this.setIgnoreRepaint(true);

    try {
        dev.setFullScreenWindow(this);
    } finally {
        dev.setFullScreenWindow(null);
    }

    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    mainPanel = new JPanel();
    mainPanel.setLayout(new FlowLayout());
    this.setLayout(new FlowLayout());
    this.add(mainPanel);

    setExtendedState(this.getExtendedState() | JFrame.MAXIMIZED_BOTH);

    GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
    c1.setSize(500, 500);
    c1.setMonoscopicViewPolicy(View.LEFT_EYE_VIEW);
    mainPanel.add(c1);
    c2.setSize(500, 500);
    c2.setMonoscopicViewPolicy(View.RIGHT_EYE_VIEW);
    mainPanel.add(c2);
    mainPanel.repaint();

    scene = makeScene();
    u = new SimpleUniverse(c1);

    View view0 = u.getViewer().getView();
    View view = new View();
    PhysicalBody myBod = view0.getPhysicalBody();
    myBod.setLeftEyePosition(new Point3d(-.006, 0.0, 0.0)); // default
                                                            // is(-0.033,
                                                            // 0.0, 0.0)
    myBod.setRightEyePosition(new Point3d(+.006, 0.0, 0.0));
    view.setPhysicalBody(myBod);
    view.setPhysicalEnvironment(view0.getPhysicalEnvironment());
    view.attachViewPlatform(u.getViewingPlatform().getViewPlatform());
    view.addCanvas3D(c2);

    view.repaint();

    // This will move the ViewPlatform back a bit so the
    // objects in the scene can be viewed.
    u.getViewingPlatform().setNominalViewingTransform();
    u.addBranchGraph(scene);

}

private BranchGroup makeScene() {
    BranchGroup branchGroup = new BranchGroup();

    Transform3D rotation1 = new Transform3D();
    Transform3D ratation2 = new Transform3D();
    rotation1.rotX(Math.PI / 4.0d);
    ratation2.rotY(Math.PI / 5.0d);
    rotation1.mul(ratation2);

    TransformGroup objTrans = new TransformGroup(rotation1);
    objTrans.setCapability(17); // 17
    objTrans.setCapability(18); // 18
    ObjectFile file = new ObjectFile(ObjectFile.RESIZE);
    Scene scene = null;

    try {
        scene = file.load(ClassLoader.getSystemResource("penguin.obj"));
    } catch (FileNotFoundException e) {
        System.err.println(e);
    } catch (ParsingErrorException e) {
        System.err.println(e);
    } catch (IncorrectFormatException e) {
        System.err.println(e);
    } catch (Exception e) {
        System.err.println(e);
    }
    objTrans.addChild(scene.getSceneGroup());

    DirectionalLight d_Licht = new DirectionalLight(new Color3f(0.7f, 1.5f, 0.3f), new Vector3f(1.0f, -10.0f, 1.0f));
    d_Licht.setInfluencingBounds(new BoundingSphere(new Point3d(0.0d, 0.0d, 0.0d), 100.0d));
    objTrans.addChild(d_Licht);

    BoundingSphere bounds = new BoundingSphere();
    MouseRotate spin = new MouseRotate();
    spin.setTransformGroup(objTrans);
    spin.setSchedulingBounds(bounds);

    branchGroup.addChild(spin);
    branchGroup.addChild(objTrans);

    return branchGroup;
}

public static void main(String[] args) {
    new ObjStereoscope();

    }

}
我的问题是:

1) 在Java3D中使用多个缓冲区可以进行立体渲染吗?如果是,如何进行

2) 我需要一些额外的硬件来实现立体声吗?我只需要实现它,该应用程序将在立体投影仪与主动眼镜。此示例在我的计算机上正常工作:


3) 提前感谢您的帮助。非常感谢。

它应该与Java 3D 1.6配合使用,请在Java 3D官方论坛上提问: