Ejemplo n.º 1
0
 private void reInitView() {
   Point3d center = new Point3d();
   getBoundingSphere(sceneBranchGroup).getCenter(center);
   float halfRadius = (float) (getBoundingSphere(sceneBranchGroup).getRadius() / 2f);
   orbitBehaviorInterim.setRotationCenter(center);
   orbitBehaviorInterim.setViewingTransform(
       new Point3d(
           halfRadius, getViewPlatformDistance(sceneBranchGroup, canvas, view), halfRadius),
       center,
       new Vector3d(0, -1, 0),
       true);
 }
Ejemplo n.º 2
0
  protected void createViewBranch() {
    TransformGroup viewTG = new TransformGroup();
    viewTG.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);

    ViewPlatform viewPlatform = new ViewPlatform();
    view = new View();
    view.setBackClipDistance(30000);
    view.addCanvas3D(canvas);
    view.setPhysicalBody(new PhysicalBody());
    view.setPhysicalEnvironment(new PhysicalEnvironment());
    view.attachViewPlatform(viewPlatform);

    float halfRadius = (float) (getBoundingSphere(sceneBranchGroup).getRadius() / 2f);
    Point3d center = new Point3d();
    getBoundingSphere(sceneBranchGroup).getCenter(center);

    BoundingSphere globalBounds = new BoundingSphere();
    globalBounds.setRadius(Double.MAX_VALUE);

    orbitBehaviorInterim =
        new OrbitBehaviorInterim(
            canvas,
            viewTG,
            OrbitBehaviorInterim.REVERSE_ROTATE | OrbitBehaviorInterim.REVERSE_TRANSLATE);

    orbitBehaviorInterim.setRotationCenter(center);
    orbitBehaviorInterim.setViewingTransform(
        new Point3d(
            halfRadius, getViewPlatformDistance(sceneBranchGroup, canvas, view), halfRadius),
        center,
        new Vector3d(0, -1, 0),
        true);
    orbitBehaviorInterim.setVpView(view);
    orbitBehaviorInterim.setTransFactors(3.0, 3.0);
    orbitBehaviorInterim.setSchedulingBounds(globalBounds);

    viewTG.addChild(viewPlatform);
    viewTG.addChild(orbitBehaviorInterim);

    viewBranchGroup.addChild(viewTG);
  }