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();
}
}
}
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);
}
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();
}
}
}
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;
}
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;
}
Aggregations