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(); } }
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 assetInfo) throws IOException { return loadFromStream(assetInfo, assetInfo.openStream()); }
public Object load(AssetInfo info) throws IOException { //AssetManager assetManager = info.getManager(); InputStream in = null; try { in = info.openStream(); return load(in); } finally { if (in != null){ in.close(); } } } }
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) throws IOException { assetManager = info.getManager(); InputStream in = info.openStream(); try { return load(in); } 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 { 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 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 { 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 InputStream getResourceAsStream(String path) { AssetKey<Object> key = new AssetKey<Object>(path); AssetInfo info = assetManager.locateAsset(key); if (info != null) { return info.openStream(); } else { throw new AssetNotFoundException(path); } }
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 { 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 { InputStream in = null; try { in = info.openStream(); BitmapFont font = load(info.getManager(), info.getKey().getFolder(), in); return font; } finally { if (in != null){ in.close(); } } }
@Test public void noDefaultTechnique_shouldBeSupported() throws IOException { when(assetInfo.openStream()).thenReturn(J3MLoader.class.getResourceAsStream("/no-default-technique.j3md")); MaterialDef def = (MaterialDef) j3MLoader.load(assetInfo); assertEquals(1, def.getTechniqueDefs("Test").size()); }
@Test public void oldStyleTextureParameters_shouldBeSupported() throws Exception { when(assetInfo.openStream()).thenReturn(J3MLoader.class.getResourceAsStream("/texture-parameters-oldstyle.j3m")); final Texture textureOldStyle = Mockito.mock(Texture.class); final Texture textureOldStyleUsingQuotes = Mockito.mock(Texture.class); final TextureKey textureKeyUsingQuotes = setupMockForTexture("OldStyleUsingQuotes", "old style using quotes/texture.png", true, textureOldStyleUsingQuotes); final TextureKey textureKeyOldStyle = setupMockForTexture("OldStyle", "old style/texture.png", true, textureOldStyle); j3MLoader.load(assetInfo); verify(assetManager).loadTexture(textureKeyUsingQuotes); verify(assetManager).loadTexture(textureKeyOldStyle); verify(textureOldStyle).setWrap(Texture.WrapMode.Repeat); verify(textureOldStyleUsingQuotes).setWrap(Texture.WrapMode.Repeat); }
@Test public void fixedPipelineTechnique_shouldBeIgnored() throws IOException { when(assetInfo.openStream()).thenReturn(J3MLoader.class.getResourceAsStream("/no-shader-specified.j3md")); MaterialDef def = (MaterialDef) j3MLoader.load(assetInfo); assertEquals(null, def.getTechniqueDefs("A")); assertEquals(1, def.getTechniqueDefs("B").size()); }
@Test public void multipleSameNamedTechniques_shouldBeSupported() throws IOException { when(assetInfo.openStream()).thenReturn(J3MLoader.class.getResourceAsStream("/same-name-technique.j3md")); MaterialDef def = (MaterialDef) j3MLoader.load(assetInfo); assertEquals(2, def.getTechniqueDefs("Test").size()); assertEquals(EnumSet.of(Caps.GLSL150), def.getTechniqueDefs("Test").get(0).getRequiredCaps()); assertEquals(EnumSet.of(Caps.GLSL100), def.getTechniqueDefs("Test").get(1).getRequiredCaps()); }