ViewingPlatformを設定し、TransformGroupを更新するには?
質問
私は、マウスが/回転/パンをズームすることができます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));
私は、マウスで画面を操作する能力を失います。
どのように私は、画面全体を見ることができるように戻って、さらにカメラを押しながらマウスを使って変換する能力を維持することができますか?
事前に多くの感謝!
解決
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);
所属していません StackOverflow