2009-08-19 18 views
3

私は、マウスがズーム/回転/パンすることを可能にするTransformGroupの内部にシーンを持っています。その中で働く私はとのシーンを操作することができViewingPlatformを設定して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
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); 
+0

.setActivationRadiusはオブジェクトを範囲に表示しますが、.setBackClipDistanceは何をしますか? –

+0

バッククリップ距離は、シーンオブジェクトの背面(背面)までの距離がどれくらい遠くに見えるかを決定します。 – Cuga

関連する問題