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); } }
/** * 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 Texture loadTexture(String name){ TextureKey key = new TextureKey(name, true); key.setGenerateMips(true); return loadTexture(key); }
@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(); } }
@Override public <T> T loadAssetFromStream(AssetKey<T> key, InputStream inputStream) { if (key == null) { throw new IllegalArgumentException("key cannot be null"); } for (AssetEventListener listener : eventListeners){ listener.assetRequested(key); } AssetProcessor proc = handler.getProcessor(key.getProcessorType()); StreamAssetInfo info = new StreamAssetInfo(this, key, inputStream); return loadLocatedAsset(key, info, proc, null); }
/** * Returns the asset key name of the asset from which this material was loaded. * * <p>This value will be <code>null</code> unless this material was loaded * from a .j3m file. * * @return Asset key name of the j3m file */ public String getAssetName() { return key != null ? key.getName() : null; }
/** * Creates the font that will be set to the guiFont field * and subsequently set as the font for the stats text. */ protected BitmapFont loadGuiFont() { return assetManager.loadFont("Interface/Fonts/Default.fnt"); }
public void checkTimesConsistantcy() { if ((translations != null && times.length != translations.length) || (rotations != null && times.length != rotations.length) || (scales != null && times.length != scales.length)) { throw new AssetLoadException("Inconsistent animation sampling "); } }
public Material loadMaterial(String name){ return (Material) loadAsset(new MaterialKey(name)); }
/** * @return The folder in which the asset is located in. * E.g. if the {@link #getName() name} is "Models/MyModel/MyModel.j3o" * then "Models/MyModel/" is returned. */ public String getFolder(){ if (folder == null) folder = getFolder(name); return folder; }
public FilterPostProcessor loadFilter(String name){ return loadFilter(new FilterKey(name)); }
@Override public void applyToTextureKey(final String option, final TextureKey textureKey) { textureKey.setFlipY(true); } };
public KeyRef(AssetKey originalKey, ReferenceQueue<AssetKey> refQueue) { super(originalKey, refQueue); clonedKey = originalKey.clone(); } }
@Override public String toString() { return blenderKey == null ? "BlenderContext [key = null]" : "BlenderContext [ key = " + blenderKey.toString() + " ]"; } }
public static void assertNotNull(Object o, String errorMessage) { if (o == null) { throw new AssetLoadException(errorMessage); } }