Пример #1
0
  public void loadLight() {

    XMLImporter imp = XMLImporter.getInstance();
    imp.setAssetManager(assetManager);

    try {
      InputStream fis =
          assetManager
              .locateAsset(new AssetKey("Scenes/" + map + "/directlightsave.xml"))
              .openStream();
      DirectionalLight dl = (DirectionalLight) imp.load(new BufferedInputStream(fis));
      rootNode.addLight(dl);
    } catch (Exception e) {
    }

    try {
      InputStream fis =
          assetManager
              .locateAsset(new AssetKey("Scenes/" + map + "/ambientlightsave.xml"))
              .openStream();
      AmbientLight al = (AmbientLight) imp.load(new BufferedInputStream(fis));
      rootNode.addLight(al);
    } catch (Exception e) {
    }

    try {
      InputStream fis =
          assetManager.locateAsset(new AssetKey("Scenes/" + map + "/fogsave.xml")).openStream();
      FogFilter fog = (FogFilter) imp.load(new BufferedInputStream(fis));

      FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
      fpp.addFilter(fog);
      viewPort.addProcessor(fpp);
    } catch (Exception e) {
    }

    /*
    try{
        InputStream fis = assetManager.locateAsset(new AssetKey("Scenes/"+map+"/shadowsave.xml")).openStream();
        PssmShadowRenderer pssmRenderer = (PssmShadowRenderer) imp.load(new BufferedInputStream(fis));
         viewPort.addProcessor(pssmRenderer);
    }catch(Exception e){}
     *
     */
  }
Пример #2
0
 public static TypeList load(String gamePath, String dataName) {
   System.out.println("load:" + dataName);
   InputStream is = null;
   Savable sav = null;
   try {
     File file =
         new File(
             System.getProperty("user.dir")
                 + File.separator
                 + gamePath
                 + File.separator
                 + dataName);
     if (!file.exists()) {
       return null;
     }
     is = new BufferedInputStream(new FileInputStream(file));
     // is = new GZIPInputStream(new BufferedInputStream(new FileInputStream(file)));
     XMLImporter imp = XMLImporter.getInstance();
     // if (manager != null) {
     //     imp.setAssetManager(manager);
     // }
     sav = imp.load(is);
   } catch (IOException ex) {
     Logger.getLogger(Type.class.getName()).log(Level.SEVERE, "Error loading data: {0}", ex);
     ex.printStackTrace();
   } finally {
     if (is != null) {
       try {
         is.close();
       } catch (IOException ex) {
         Logger.getLogger(Type.class.getName()).log(Level.SEVERE, "Error loading data: {0}", ex);
         ex.printStackTrace();
       }
     }
   }
   return (TypeList) sav;
 }