Пример #1
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) {
    }
  }