2009-08-19 6 views
3

J'ai une scène à l'intérieur d'un TransformGroup qui permet à la souris d'effectuer un zoom/rotation/panoramique.Comment définir ViewingPlatform et mettre à jour TransformGroup?

J'ai besoin de régler la position de la caméra suffisamment loin que je peux voir toute la scène, que je fais avec le code suivant:

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

L'exécution du code ci-dessus fonctionne dans ce que je peux manipuler la scène avec la souris. Toutefois, si j'échange sur cette ligne:

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

avec:

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

je perds la capacité de manipuler l'écran avec la souris.

Comment puis-je conserver la possibilité de transformer avec la souris tout en poussant l'appareil photo plus loin pour que je puisse voir l'intégralité de l'écran?

Merci beaucoup d'avance!

Répondre

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 fait varier les objets, mais que fait .setBackClipDistance? –

+0

La distance du clip arrière détermine dans quelle mesure une distance à l'arrière (arrière) des objets de la scène restera visible. – Cuga

Questions connexes