Beispiel #1
0
  @SuppressWarnings("unchecked")
  public void saveAsFile() {
    TransformGroup themodel = lobj.getModel3D();
    File file = showSaveImageDialog();
    if (file != null) {
      BranchGroup scene = new BranchGroup();
      render.removeObj3D(lobj);
      Enumeration<Group> enume = themodel.getAllChildren();

      while (enume.hasMoreElements()) {
        Group next = enume.nextElement();
        themodel.removeChild(next);
        scene.addChild(next);
      }

      // String file=this.getModel3DHref();
      // file.replace(".3ds", ".j3d");

      // OutputStream outS;
      try {
        SceneGraphFileWriter filew =
            new SceneGraphFileWriter(file, null, false, "genereted by Neptus", null);
        filew.writeBranchGraph(scene);
        System.err.println("vehicle w:" + file.getPath() + "\n");
        filew.close();
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (UnsupportedUniverseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      TransformGroup themodel2 = new TransformGroup();
      enume = scene.getAllChildren();
      while (enume.hasMoreElements()) {
        Group next = enume.nextElement();
        scene.removeChild(next);
        themodel2.addChild(next);
      }

      lobj = new Obj3D();
      lobj.setModel3D(themodel2);
      render.addObj3D(lobj);
    }
  }
Beispiel #2
0
  public void prepareCorak(
      String projectPath, CorakLSystem cor, CorakDataObject obj, boolean encloseOBJ) {

    this.projectPath = projectPath;

    // initiate our "turtle" -> Canting
    canting = new Canting(cor, obj);

    // start creating shapes based on Cor
    timer = System.currentTimeMillis();
    canting.generate(encloseOBJ);

    BoundingSphere lightingBounds = new BoundingSphere(new Point3d(0, 0, 0), FARTHEST);
    camLamp = new PointLight();
    camLamp.setCapability(PointLight.ALLOW_POSITION_READ);
    camLamp.setCapability(PointLight.ALLOW_POSITION_WRITE);
    camLamp.setColor(new Color3f(1.0f, 1.0f, 1.0f));
    camLamp.setInfluencingBounds(lightingBounds);

    ambient = new AmbientLight();
    ambient.setColor(new Color3f(1.0f, 1.0f, 1.0f));
    ambient.setInfluencingBounds(lightingBounds);

    canting.getBatikBG().addChild(camLamp);
    canting.getBatikBG().addChild(ambient);

    // attach generated shapes to root TransformGroup
    Enumeration kaintgchildren = kainTG.getAllChildren();
    while (kaintgchildren.hasMoreElements()) {
      Node child = (Node) kaintgchildren.nextElement();
      if (child instanceof Measurer) {
        ((Measurer) child).removeAllChildren();
      } else {
        kainTG.removeChild(child);
      }
    }
    //        canting.getBatikBG().compile();
    kainTG.addChild(canting.getBatikBG());

    timer = System.currentTimeMillis() - timer;
    // System.out.println("Timer= " + timer);

    bs = (BoundingSphere) canting.getBatikBG().getBounds();
  }