コード例 #1
0
  @SuppressWarnings("empty-statement")
  public Object load(AssetInfo info) throws IOException {
    reset();

    this.key = info.getKey();
    this.assetManager = info.getManager();
    if (info.getKey() instanceof EnhancedAssetKey) {
      folderName = ((EnhancedAssetKey) info.getKey()).getMaterialsPath();
    } else {
      folderName = info.getKey().getFolder();
    }
    matList = new MaterialList();

    InputStream in = null;
    try {
      in = info.openStream();
      scan = new Scanner(in);
      scan.useLocale(Locale.US);

      while (readLine()) ;
    } finally {
      if (in != null) {
        in.close();
      }
    }

    if (matName != null) {
      // still have a material in the vars
      createMaterial();
      resetMaterial();
    }

    MaterialList list = matList;
    return list;
  }
コード例 #2
0
  public Object load(AssetInfo info) throws IOException {
    this.assetManager = info.getManager();

    InputStream in = info.openStream();
    try {
      key = info.getKey();
      if (key.getExtension().equals("j3m") && !(key instanceof MaterialKey)) {
        throw new IOException("Material instances must be loaded via MaterialKey");
      } else if (key.getExtension().equals("j3md") && key instanceof MaterialKey) {
        throw new IOException("Material definitions must be loaded via AssetKey");
      }
      loadFromRoot(BlockLanguageParser.parse(in));
    } finally {
      if (in != null) {
        in.close();
      }
    }

    if (material != null) {
      // material implementation
      return material;
    } else {
      // material definition
      return materialDef;
    }
  }
コード例 #3
0
  public Object load(AssetInfo info) throws IOException {
    if (!(info.getKey() instanceof TextureKey)) {
      throw new IllegalArgumentException("Texture assets must be loaded using a TextureKey");
    }

    boolean flip = ((TextureKey) info.getKey()).isFlipY();
    InputStream in = null;
    try {
      in = info.openStream();
      Image img = load(in, flip);
      return img;
    } finally {
      if (in != null) {
        in.close();
      }
    }
  }