/** * Construct a new URLResourceSource from a specific URL and type. * * @param sourceUrl * The url to load the resource from. Must not be null. * @param type * our type. Usually a file extension such as .png. Required for generic loading when multiple resource * handlers could be used. */ public URLResourceSource(final URL sourceUrl, final String type) { assert (sourceUrl != null) : "sourceUrl must not be null"; setURL(sourceUrl); _type = type; }
public ResourceSource locateResource(final String resourceName) { return doRecursiveLocate(cleanup(resourceName)); }
/** * Construct a new InputStreamResourceSource from a specific stream and type. * * @param stream * The stream to load the resource from. Must not be null. * @param type * our type. Usually a file extension such as .png. Required for generic loading when multiple resource * handlers could be used. */ public InputStreamResourceSource(final InputStream stream, final String type) { assert (stream != null) : "stream must not be null"; setStream(stream); _is = stream; }
public static void addDefaultResourceLocators() { try { ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_MATERIAL, new SimpleResourceLocator( ResourceLocatorTool.getClassPathResource(Terrain.class, "com/ardor3d/extension/terrain/material"))); ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_SHADER, new SimpleResourceLocator( ResourceLocatorTool.getClassPathResource(Terrain.class, "com/ardor3d/extension/terrain/shader"))); } catch (final URISyntaxException ex) { ex.printStackTrace(); } } }
/** * Reads a MD2 file from the given resource * * @param resource * the name of the resource to find. * @return an ObjGeometryStore data object containing the scene and other useful elements. */ public Md2DataStore load(final String resource) { final ResourceSource source; if (_modelLocator == null) { source = ResourceLocatorTool.locateResource(ResourceLocatorTool.TYPE_MODEL, resource); } else { source = _modelLocator.locateResource(resource); } if (source == null) { throw new Error("Unable to locate '" + resource + "'"); } return load(source); }
@Override public ResourceSource locateResource(String resourceName) { resourceName = cleanup(resourceName); if (_trySpecifiedFormatFirst) { final ResourceSource src = doRecursiveLocate(resourceName); if (src != null) { return src; } } final String baseFileName = getBaseFileName(resourceName); for (final String extension : _extensions) { final ResourceSource src = doRecursiveLocate(baseFileName + extension); if (src != null) { return src; } } if (!_trySpecifiedFormatFirst) { // If all else fails, just try the original name. return doRecursiveLocate(resourceName); } else { return null; } }
@Override public boolean equals(final Object obj) { if (obj instanceof MultiFormatResourceLocator) { return getBaseDir().equals(((MultiFormatResourceLocator) obj).getBaseDir()) && Arrays.equals(_extensions, ((MultiFormatResourceLocator) obj)._extensions); } return super.equals(obj); } }
/** * Loads a texture by attempting to locate the given name using ResourceLocatorTool. * * @param name * the name of the texture image. * @param minFilter * the filter for the near values. Used to determine if we should generate mipmaps. * @param flipVertically * If true, the image is flipped vertically during image loading. * @return the loaded texture. */ public static Texture load(final String name, final Texture.MinificationFilter minFilter, final boolean flipVertically) { return load(ResourceLocatorTool.locateResource(ResourceLocatorTool.TYPE_TEXTURE, name), minFilter, TextureStoreFormat.GuessNoCompressedFormat, flipVertically); }
public ResourceSource locateResource(String resourceName) { // Trim off any prepended local dir. while (resourceName.startsWith("./") && resourceName.length() > 2) { resourceName = resourceName.substring(2); } while (resourceName.startsWith(".\\") && resourceName.length() > 2) { resourceName = resourceName.substring(2); } return _baseSource.getRelativeSource(resourceName); }
protected String trimResourceName(String resourceName) { // it's possible this URL has back slashes, so replace them. resourceName = cleanup(resourceName); final int firstSlashIndex = resourceName.indexOf('/'); if (firstSlashIndex >= 0 && firstSlashIndex < resourceName.length() - 1) { return resourceName.substring(firstSlashIndex + 1); } else { return null; } }
public static void addDefaultResourceLocators() { try { ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_MATERIAL, new SimpleResourceLocator(ResourceLocatorTool.getClassPathResource(SkinnedMesh.class, "com/ardor3d/extension/animation/skeletal/material"))); ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_SHADER, new SimpleResourceLocator(ResourceLocatorTool.getClassPathResource(SkinnedMesh.class, "com/ardor3d/extension/animation/skeletal/shader"))); } catch (final URISyntaxException ex) { ex.printStackTrace(); } } }
/** * Reads a Wavefront OBJ file from the given resource * * @param resource * the name of the resource to find. * @return an ObjGeometryStore data object containing the scene and other useful elements. */ public ObjGeometryStore load(final String resource) { final ResourceSource source; if (_modelLocator == null) { source = ResourceLocatorTool.locateResource(ResourceLocatorTool.TYPE_MODEL, resource); } else { source = _modelLocator.locateResource(resource); } if (source == null) { throw new Error("Unable to locate '" + resource + "'"); } return load(source); }
@Override public ResourceSource locateResource(String resourceName) { resourceName = cleanup(resourceName); if (_trySpecifiedFormatFirst) { final ResourceSource src = doRecursiveLocate(resourceName); if (src != null) { return src; } } final String baseFileName = getBaseFileName(resourceName); for (final String extension : _extensions) { final ResourceSource src = doRecursiveLocate(baseFileName + extension); if (src != null) { return src; } } if (!_trySpecifiedFormatFirst) { // If all else fails, just try the original name. return doRecursiveLocate(resourceName); } else { return null; } }
public ResourceSource locateResource(final String resourceName) { return doRecursiveLocate(cleanup(resourceName)); }
@Override public boolean equals(final Object obj) { if (obj instanceof MultiFormatResourceLocator) { return getBaseDir().equals(((MultiFormatResourceLocator) obj).getBaseDir()) && Arrays.equals(_extensions, ((MultiFormatResourceLocator) obj)._extensions); } return super.equals(obj); } }
public static RenderMaterial loadChecked(final String sourceUrl) throws IOException { final ResourceSource source = ResourceLocatorTool.locateResource(ResourceLocatorTool.TYPE_MATERIAL, sourceUrl); if (source == null) { throw new IOException("Unable to locate '" + sourceUrl + "'"); } return load(source); }
public ResourceSource locateResource(String resourceName) { // Trim off any prepended local dir. while (resourceName.startsWith("./") && resourceName.length() > 2) { resourceName = resourceName.substring(2); } while (resourceName.startsWith(".\\") && resourceName.length() > 2) { resourceName = resourceName.substring(2); } return _baseSource.getRelativeSource(resourceName); }
/** * Construct a new URLResourceSource from a specific URL and type. * * @param sourceUrl * The url to load the resource from. Must not be null. * @param type * our type. Usually a file extension such as .png. Required for generic loading when multiple resource * handlers could be used. */ public URLResourceSource(final URL sourceUrl, final String type) { assert (sourceUrl != null) : "sourceUrl must not be null"; setURL(sourceUrl); _type = type; }
protected String trimResourceName(String resourceName) { // it's possible this URL has back slashes, so replace them. resourceName = cleanup(resourceName); final int firstSlashIndex = resourceName.indexOf('/'); if (firstSlashIndex >= 0 && firstSlashIndex < resourceName.length() - 1) { return resourceName.substring(firstSlashIndex + 1); } else { return null; } }
public static void addDefaultResourceLocators() { try { ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_MATERIAL, new SimpleResourceLocator(ResourceLocatorTool.getClassPathResource(EffectUtils.class, "com/ardor3d/extension/effect/material"))); ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_SHADER, new SimpleResourceLocator(ResourceLocatorTool.getClassPathResource(EffectUtils.class, "com/ardor3d/extension/effect/shader"))); } catch (final URISyntaxException ex) { ex.printStackTrace(); } } }