public Object load(AssetInfo info) throws IOException { if (!(info.getKey() instanceof TextureKey)) throw new IllegalArgumentException("Texture assets must be loaded using a TextureKey"); InputStream in = null; try { in = info.openStream(); return load(in, ((TextureKey)info.getKey()).isFlipY()); } finally { if (in != null){ in.close(); } } }
@Override public Object load(AssetInfo info) throws IOException { AssetKey key=info.getKey(); Spatial output=cache.get(key); if(output==null){ output=(Spatial)super.load(info); cache.put(key,output); } return output.clone(false); } public void reset(){
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(); } } }
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(); } } }
@Override public Object load(AssetInfo info) throws IOException { if (!(info.getKey() instanceof TextureKey)) { throw new IllegalArgumentException("Texture assets must be loaded using a TextureKey"); } InputStream in = null; try { in = info.openStream(); Image img = load(in); return img; } finally { if (in != null) { in.close(); } } }
@Override public Object load(AssetInfo assetInfo) throws IOException { AndroidAudioData result = new AndroidAudioData(); result.setAssetKey(assetInfo.getKey()); return result; } }
@Override public Object load(AssetInfo assetInfo) throws IOException { if (!(assetInfo.getKey() instanceof BinDataKey)) { throw new AssetLoadException(".bin files cannot be loaded directly, load the associated .gltf file"); } return assetInfo.openStream(); } }
public Object load(AssetInfo info) throws IOException { InputStream in = null; try { in = info.openStream(); return load(info.getManager(), info.getKey(), in); } finally { if (in != null){ in.close(); } } }
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; }
public Object load(AssetInfo info) throws IOException { if (!(info.getKey() instanceof AudioKey)){ throw new IllegalArgumentException("Audio assets must be loaded using an AudioKey"); } AudioKey key = (AudioKey) info.getKey(); boolean readStream = key.isStream(); boolean streamCache = key.useStreamCache(); InputStream in = null; try { in = info.openStream(); AudioData data = load(in, readStream, streamCache); if (readStream && !streamCache) { // we still need the stream in this case .. in = null; } return data; } finally { if (in != null){ in.close(); } } }
@Override public Object load(AssetInfo assetInfo) throws IOException { AudioKey key = (AudioKey) assetInfo.getKey(); if (!(assetInfo instanceof AndroidLocator.AndroidAssetInfo)) { throw new UnsupportedOperationException("Cannot load audio files from classpath." + "Place your audio files in " + "Android's assets directory"); } if (key.isStream()) { return loadStream(assetInfo); } else { return loadBuffer(assetInfo); } } }
public Object load(AssetInfo info) throws IOException { if (!(info.getKey() instanceof TextureKey)) { throw new IllegalArgumentException("Texture assets must be loaded using a TextureKey"); } InputStream stream = null; try { stream = info.openStream(); in = new LittleEndien(stream); loadHeader(); if (texture3D) { ((TextureKey) info.getKey()).setTextureTypeHint(Texture.Type.ThreeDimensional); } else if (depth > 1) { ((TextureKey) info.getKey()).setTextureTypeHint(Texture.Type.CubeMap); } ArrayList<ByteBuffer> data = readData(((TextureKey) info.getKey()).isFlipY()); return new Image(pixelFormat, width, height, depth, data, sizes, ColorSpace.sRGB); } finally { if (stream != null){ stream.close(); } } }
public Object load(AssetInfo info) throws IOException { if (ImageIO.getImageReadersBySuffix(info.getKey().getExtension()) != null){ boolean flip = ((TextureKey) info.getKey()).isFlipY(); InputStream in = null; try { in = info.openStream(); Image img = load(in, flip); if (img == null){ throw new AssetLoadException("The given image cannot be loaded " + info.getKey()); } return img; } finally { if (in != null){ in.close(); } } }else{ throw new AssetLoadException("The extension " + info.getKey().getExtension() + " is not supported"); } } }
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(); } } } }
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(); } } }
/** * The internal data is only needed during loading so make it unreachable so that the GC can release * that memory (which can be quite large amount). */ protected void clear(AssetInfo assetInfo) { assetInfo.getManager().unregisterLocator(assetInfo.getKey().getName(), LinkedContentLocator.class); }
public Image load(AssetInfo info) throws IOException { boolean flip = ((TextureKey) info.getKey()).isFlipY(); InputStream in = null; try { in = info.openStream(); return load(info.openStream(), flip, tmpArray); } finally { if (in != null){ in.close(); } } } }
@Before public void setUp() throws Exception { when(assetKey.getExtension()).thenReturn(".j3m"); when(assetInfo.getManager()).thenReturn(assetManager); when(assetInfo.getKey()).thenReturn(assetKey); when(assetManager.loadAsset(any(AssetKey.class))).thenReturn(materialDef); j3MLoader = new J3MLoader(); }
@Override public Object handleExtension(GltfLoader loader, String parentName, JsonElement parent, JsonElement extension, Object input) throws IOException { MaterialAdapter adapter = materialAdapter; AssetKey key = loader.getInfo().getKey(); //check for a custom adapter for spec/gloss pipeline if (key instanceof GltfModelKey) { GltfModelKey gltfKey = (GltfModelKey) key; MaterialAdapter ma = gltfKey.getAdapterForMaterial("pbrSpecularGlossiness"); if (ma != null) { adapter = ma; } } adapter.init(loader.getInfo().getManager()); adapter.setParam("diffuseFactor", getAsColor(extension.getAsJsonObject(), "diffuseFactor")); adapter.setParam("specularFactor", getAsColor(extension.getAsJsonObject(), "specularFactor")); adapter.setParam("glossinessFactor", getAsFloat(extension.getAsJsonObject(), "glossinessFactor")); adapter.setParam("diffuseTexture", loader.readTexture(extension.getAsJsonObject().getAsJsonObject("diffuseTexture"))); adapter.setParam("specularGlossinessTexture", loader.readTexture(extension.getAsJsonObject().getAsJsonObject("specularGlossinessTexture"))); return adapter; } }