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(); } } }
@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 { assetManager = info.getManager(); InputStream in = info.openStream(); try { return load(in); } 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 Object load(AssetInfo assetInfo) throws IOException { Scanner scan = new Scanner(assetInfo.openStream()); StringBuilder sb = new StringBuilder(); try { while (scan.hasNextLine()) { sb.append(scan.nextLine()).append('\n'); } } finally { scan.close(); } return sb.toString(); } }
adapter = defaultMaterialAdapters.get("pbrMetallicRoughness"); adapter.init(info.getManager()); logger.log(Level.WARNING, "Couldn't find any matching material definition for material " + materialIndex); adapter = defaultMaterialAdapters.get("pbrMetallicRoughness"); adapter.init(info.getManager()); setDefaultParams(adapter.getMaterial());
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(); } } } }
public Object load(AssetInfo info){ // if (!(info.getKey() instanceof ModelKey)) // throw new IllegalArgumentException("Model assets must be loaded using a ModelKey"); assetManager = info.getManager(); InputStream is = null; try { is = info.openStream(); Savable s = load(is); return s; } catch (IOException ex) { logger.log(Level.SEVERE, "An error occured while loading jME binary object", ex); } finally { if (is != null){ try { is.close(); } catch (IOException ex) {} } } return null; }
protected byte[] getBytes(int bufferIndex, String uri, Integer bufferLength) throws IOException { byte[] data; if (uri != null) { if (uri.startsWith("data:")) { //base 64 embed data data = DatatypeConverter.parseBase64Binary(uri.substring(uri.indexOf(",") + 1)); } else { //external file let's load it if (!uri.endsWith(".bin")) { throw new AssetLoadException("Cannot load " + uri + ", a .bin extension is required."); } BinDataKey key = new BinDataKey(info.getKey().getFolder() + uri); InputStream input = (InputStream) info.getManager().loadAsset(key); data = new byte[bufferLength]; DataInputStream dataStream = new DataInputStream(input); dataStream.readFully(data); dataStream.close(); } } else { //no URI this should not happen in a gltf file, only in glb files. throw new AssetLoadException("Buffer " + bufferIndex + " has no uri"); } return data; }
public void setTime(float time) { if (time != 0f) { throw new UnsupportedOperationException("Seeking WAV files not supported"); } InputStream newStream = info.openStream(); try { newStream.skip(resetOffset); this.in = new BufferedInputStream(newStream); } catch (IOException ex) { // Resource could have gotten lost, etc. try { newStream.close(); } catch (IOException ex2) { } throw new RuntimeException(ex); } } }
@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(){
/** * Loads a JME texture of the texture name * * @param texture the texture name * @param assetInfo the assetInfo * @return texture file */ private Texture loadTexture(String texture, AssetInfo assetInfo) { // Load the texture TextureKey textureKey = new TextureKey(ConversionUtils.getCanonicalAssetKey(AssetsConverter.TEXTURES_FOLDER.concat("/").concat(texture).concat(".png")), false); Texture tex = assetInfo.getManager().loadTexture(textureKey); return tex; }
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(); } } }
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(); } } }
public Object load(AssetInfo info) throws IOException { assetManager = info.getManager(); InputStream in = null; try { in = info.openStream(); return load(in); } finally { if (in != null){ in.close(); } } } }
String extension = mimeType.split("/")[1]; TextureKey key = new TextureKey("image" + sourceIndex + "." + extension, flip); result = (Texture2D) info.getManager().loadAssetFromStream(key, new ByteArrayInputStream(data)); String extension = headerInfo.split("/")[1]; TextureKey key = new TextureKey("image" + sourceIndex + "." + extension, flip); result = (Texture2D) info.getManager().loadAssetFromStream(key, new ByteArrayInputStream(data)); } else { TextureKey key = new TextureKey(info.getKey().getFolder() + uri, flip); Texture tex = info.getManager().loadTexture(key); result = (Texture2D) tex;
@Override public Object load(AssetInfo assetInfo) throws IOException { return loadFromStream(assetInfo, assetInfo.openStream()); }
@Override public Object load(AssetInfo assetInfo) throws IOException { AndroidAudioData result = new AndroidAudioData(); result.setAssetKey(assetInfo.getKey()); return result; } }
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; } }