3

TransformGroup内に、マウスのズーム/回転/パンを可能にするシーンがあります。

次のコードを使用して、シーン全体を表示できるようにカメラの位置を十分に戻す必要があります。

    // Position the position from which the user is viewing the scene
    ViewingPlatform viewPlatform = universe.getViewingPlatform();
    TransformGroup viewTransform = viewPlatform.getViewPlatformTransform();
    Transform3D t3d = new Transform3D();
    viewTransform.getTransform(t3d);
    t3d.lookAt(new Point3d(0,0,50), new Point3d(0,0,0), new Vector3d(0,1,0));
    t3d.invert();
    viewTransform.setTransform(t3d);

上記のコードを実行すると、マウスでシーンを操作できるようになります。ただし、この行を入れ替えると、次のようになります。

t3d.lookAt(new Point3d(0,0,50), new Point3d(0,0,0), new Vector3d(0,1,0));

と:

// Change value from 50 to 90 to push the camera back further
t3d.lookAt(new Point3d(0,0,90), new Point3d(0,0,0), new Vector3d(0,1,0));

マウスで画面を操作できなくなります。

画面全体を表示できるように、カメラをさらに押し戻しながらマウスで変形する機能を維持するにはどうすればよいですか?

よろしくお願いします!

4

1 に答える 1

4
    GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
    Canvas3D canvas3d = new Canvas3D(config);

    // Manually create the viewing platform so that we can customize it
    ViewingPlatform viewingPlatform = new ViewingPlatform();

    // **** This is the part I was missing: Activation radius
    viewingPlatform.getViewPlatform().setActivationRadius(300f);

    // Set the view position back far enough so that we can see things
    TransformGroup viewTransform = viewingPlatform.getViewPlatformTransform();
    Transform3D t3d = new Transform3D();
    // Note: Now the large value works
    t3d.lookAt(new Point3d(0,0,150), new Point3d(0,0,0), new Vector3d(0,1,0));
    t3d.invert();
    viewTransform.setTransform(t3d);

    // Set back clip distance so things don't disappear 
    Viewer viewer = new Viewer(canvas3d);
    View view = viewer.getView();
    view.setBackClipDistance(300);

    SimpleUniverse universe = new SimpleUniverse(viewingPlatform, viewer);
于 2009-08-19T16:31:18.117 に答える