Search in sources :

Example 1 with AssetInfo

use of com.jme3.asset.AssetInfo in project jmonkeyengine by jMonkeyEngine.

the class BitmapFontLoader method load.

public Object load(AssetInfo info) throws IOException {
    InputStream in = null;
    try {
        in = info.openStream();
        BitmapFont font = load(info.getManager(), info.getKey().getFolder(), in);
        return font;
    } finally {
        if (in != null) {
            in.close();
        }
    }
}
Also used : InputStream(java.io.InputStream) BitmapFont(com.jme3.font.BitmapFont)

Example 2 with AssetInfo

use of com.jme3.asset.AssetInfo in project jmonkeyengine by jMonkeyEngine.

the class ShaderNodeDefinitionLoader method load.

@Override
public Object load(AssetInfo assetInfo) throws IOException {
    AssetKey k = assetInfo.getKey();
    if (!(k instanceof ShaderNodeDefinitionKey)) {
        throw new IOException("ShaderNodeDefinition file must be loaded via ShaderNodeDefinitionKey");
    }
    ShaderNodeDefinitionKey key = (ShaderNodeDefinitionKey) k;
    loaderDelegate = new ShaderNodeLoaderDelegate();
    InputStream in = assetInfo.openStream();
    List<Statement> roots = BlockLanguageParser.parse(in);
    if (roots.size() == 2) {
        Statement exception = roots.get(0);
        String line = exception.getLine();
        if (line.startsWith("Exception")) {
            throw new AssetLoadException(line.substring("Exception ".length()));
        } else {
            throw new MatParseException("In multiroot shader node definition, expected first statement to be 'Exception'", exception);
        }
    } else if (roots.size() != 1) {
        throw new MatParseException("Too many roots in J3SN file", roots.get(0));
    }
    return loaderDelegate.readNodesDefinitions(roots.get(0).getContents(), key);
}
Also used : AssetKey(com.jme3.asset.AssetKey) ShaderNodeDefinitionKey(com.jme3.asset.ShaderNodeDefinitionKey) InputStream(java.io.InputStream) Statement(com.jme3.util.blockparser.Statement) IOException(java.io.IOException) AssetLoadException(com.jme3.asset.AssetLoadException)

Example 3 with AssetInfo

use of com.jme3.asset.AssetInfo in project jmonkeyengine by jMonkeyEngine.

the class WAVLoader method load.

public Object load(AssetInfo info) throws IOException {
    AudioData data;
    InputStream inputStream = null;
    try {
        inputStream = info.openStream();
        data = load(info, inputStream, ((AudioKey) info.getKey()).isStream());
        if (data instanceof AudioStream) {
            inputStream = null;
        }
        return data;
    } finally {
        if (inputStream != null) {
            inputStream.close();
        }
    }
}
Also used : AudioStream(com.jme3.audio.AudioStream) AudioData(com.jme3.audio.AudioData) BufferedInputStream(java.io.BufferedInputStream) InputStream(java.io.InputStream) AudioKey(com.jme3.audio.AudioKey)

Example 4 with AssetInfo

use of com.jme3.asset.AssetInfo in project jmonkeyengine by jMonkeyEngine.

the class MTLLoader method load.

@SuppressWarnings("empty-statement")
public Object load(AssetInfo info) throws IOException {
    reset();
    this.key = info.getKey();
    this.assetManager = info.getManager();
    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;
}
Also used : Scanner(java.util.Scanner) InputStream(java.io.InputStream) MaterialList(com.jme3.material.MaterialList)

Example 5 with AssetInfo

use of com.jme3.asset.AssetInfo in project jmonkeyengine by jMonkeyEngine.

the class IosImageLoader method load.

public Object load(AssetInfo info) throws IOException {
    boolean flip = ((TextureKey) info.getKey()).isFlipY();
    Image img = null;
    InputStream in = null;
    try {
        in = info.openStream();
        img = loadImageData(Format.RGBA8, flip, in);
    } finally {
        if (in != null) {
            in.close();
        }
    }
    return img;
}
Also used : TextureKey(com.jme3.asset.TextureKey) InputStream(java.io.InputStream) Image(com.jme3.texture.Image)

Aggregations

InputStream (java.io.InputStream)17 TextureKey (com.jme3.asset.TextureKey)12 IOException (java.io.IOException)9 Image (com.jme3.texture.Image)7 AssetInfo (com.jme3.asset.AssetInfo)6 Texture (com.jme3.texture.Texture)6 AssetLoadException (com.jme3.asset.AssetLoadException)5 Test (org.junit.Test)5 AssetKey (com.jme3.asset.AssetKey)4 AssetNotFoundException (com.jme3.asset.AssetNotFoundException)4 ModelKey (com.jme3.asset.ModelKey)4 InputStreamReader (java.io.InputStreamReader)4 BlenderKey (com.jme3.asset.BlenderKey)3 AudioStream (com.jme3.audio.AudioStream)3 MaterialDef (com.jme3.material.MaterialDef)3 DataInputStream (java.io.DataInputStream)3 AssetFileDescriptor (android.content.res.AssetFileDescriptor)2 AssetManager (com.jme3.asset.AssetManager)2 AndroidAssetInfo (com.jme3.asset.plugins.AndroidLocator.AndroidAssetInfo)2 AudioBuffer (com.jme3.audio.AudioBuffer)2