Exemplo n.º 1
0
 public void buildGraph() {
   ((Light) node)
       .setInfluencingBoundingLeaf(
           (BoundingLeaf) control.getSymbolTable().getJ3dNode(boundingLeaf));
   for (int i = 0; i < scope.length; i++) {
     ((Light) node).addScope((Group) control.getSymbolTable().getJ3dNode(scope[i]));
   }
   super.buildGraph(); // Must be last call in method
 }
Exemplo n.º 2
0
  public ObjectViewer(URL url) {
    setLayout(new BorderLayout());
    Canvas3D canvas3D = new Canvas3D(SimpleUniverse.getPreferredConfiguration());
    add("Center", canvas3D);

    BoundingSphere bounds = new BoundingSphere(new Point3d(), 1000);
    BranchGroup root = new BranchGroup();
    BranchGroup scene = createSceneGraph(url);
    scene.setBoundsAutoCompute(true);
    System.out.println(scene.getBounds());
    BoundingSphere sceneBounds = new BoundingSphere(scene.getBounds());

    SimpleUniverse univ = new SimpleUniverse(canvas3D);
    ViewingPlatform view = univ.getViewingPlatform();
    view.setNominalViewingTransform();

    Transform3D t = new Transform3D();
    TransformGroup viewTransform = view.getViewPlatformTransform();

    t.set(new Vector3d(0, 0, 3 * sceneBounds.getRadius()));
    viewTransform.setTransform(t);

    BranchGroup lights = new BranchGroup();
    Light light = new AmbientLight();
    light.setInfluencingBounds(bounds);
    lights.addChild(light);
    light = new DirectionalLight();
    light.setInfluencingBounds(bounds);
    lights.addChild(light);
    root.addChild(lights);

    TransformGroup tg = new TransformGroup();
    tg.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
    tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    tg.addChild(scene);

    root.addChild(tg);

    MouseRotate mouse = new MouseRotate();
    mouse.setTransformGroup(tg);
    mouse.setSchedulingBounds(bounds);
    root.addChild(mouse);

    MouseZoom mousezoom = new MouseZoom();
    mousezoom.setTransformGroup(tg);
    mousezoom.setSchedulingBounds(bounds);
    root.addChild(mousezoom);

    Background background = new Background(1, 1, 1);
    background.setApplicationBounds(bounds);
    root.addChild(background);

    root.compile();

    univ.addBranchGraph(root);
  }
Exemplo n.º 3
0
  public void readObject(DataInput in) throws IOException {
    super.readObject(in);
    ((Light) node).setColor(control.readColor3f(in));
    ((Light) node).setEnable(in.readBoolean());

    boundingLeaf = in.readInt();

    ((Light) node).setInfluencingBounds(control.readBounds(in));

    scope = new int[in.readInt()];
    for (int i = 0; i < scope.length; i++) {
      scope[i] = in.readInt();
    }
  }
Exemplo n.º 4
0
  public void writeObject(DataOutput out) throws IOException {
    super.writeObject(out);

    scope = new int[((Light) node).numScopes()];
    for (int i = 0; i < ((Light) node).numScopes(); i++) {
      scope[i] = control.getSymbolTable().addReference(((Light) node).getScope(i));
      ;
    }
    boundingLeaf =
        control.getSymbolTable().addReference(((Light) node).getInfluencingBoundingLeaf());

    Color3f color = new Color3f();
    ((Light) node).getColor(color);
    control.writeColor3f(out, color);

    out.writeBoolean(((Light) node).getEnable());

    out.writeInt(boundingLeaf);
    control.writeBounds(out, ((Light) node).getInfluencingBounds());

    out.writeInt(scope.length);
    for (int i = 0; i < scope.length; i++) {
      out.writeInt(scope[i]);
    }
  }