Ejemplo n.º 1
0
  public void loadDoodads() {
    InputStream fis =
        game.getGameApplication()
            .getAssetManager()
            .locateAsset(new AssetKey("Scenes/" + map + "/doodads.jme"))
            .openStream();
    BinaryImporter importer = BinaryImporter.getInstance();
    importer.setAssetManager(assetManager);

    try {
      doodadNode = (Node) importer.load(new BufferedInputStream(fis));

      // this node is for buildings in fog (unsauber usw.....)
      doodadNode.attachChild(new Node());

      /*
      Node test =new Node();

      List list =doodadNode.getChildren();
        for(int i=0;i<list.size();i++)
        {
            BatchNode batch = new BatchNode();
            batch.attachChild((Node)list.get(i));
            batch.batch();
            test.attachChild(batch);
        }
      rootNode.attachChild(test);
       *
       */

      reflectNode.attachChild(doodadNode);
    } catch (IOException ex) {
      //  Logger.getLogger(Main.class.getName()).log(Level.SEVERE, "No saved node loaded.", ex);
    }
  }
Ejemplo n.º 2
0
  public void loadTerrain() {
    try {
      long start = System.currentTimeMillis();
      // remove the existing terrain and detach it from the root node.
      if (terrain != null) {
        Node existingTerrain = (Node) terrain;
        existingTerrain.removeFromParent();
        existingTerrain.removeControl(TerrainLodControl.class);
        existingTerrain.detachAllChildren();
        terrain = null;
      }

      InputStream fis =
          game.getGameApplication()
              .getAssetManager()
              .locateAsset(new AssetKey("Scenes/" + map + "/terrainsave.jme"))
              .openStream();
      BinaryImporter imp = BinaryImporter.getInstance();
      imp.setAssetManager(assetManager);

      terrain = (TerrainQuad) imp.load(new BufferedInputStream(fis));
      terrain.setShadowMode(ShadowMode.CastAndReceive);

      clickableNode.attachChild((Node) terrain);

      float duration = (System.currentTimeMillis() - start) / 1000.0f;
      System.out.println("Load took " + duration + " seconds");
    } catch (Exception e) {
    }
  }