/** * 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; }
public AssetInfo locate(AssetManager manager, AssetKey key){ final ZipEntry2 entry = entries.get(key.getName()); if (entry == null) return null; return new AssetInfo(manager, key){ @Override public InputStream openStream() { try { return HttpZipLocator.this.openStream(entry); } catch (IOException ex) { logger.log(Level.WARNING, "Error retrieving "+entry.name, ex); return null; } } }; }
public AssetInfo locate(AssetManager manager, AssetKey key) { String name = key.getName(); if(name.startsWith("/"))name=name.substring(1); ZipEntry entry = zipfile.getEntry(name); if (entry == null) return null; return new JarAssetInfo(manager, key, entry); }
public AssetInfo locate(AssetManager manager, AssetKey key) { String name = key.getName(); try{ //TODO: remove workaround for SDK // URL url = new URL(root, name); if(name.startsWith("/")){ name = name.substring(1); } URL url = new URL(root.toExternalForm() + name); return UrlAssetInfo.create(manager, key, url); }catch (FileNotFoundException e){ return null; }catch (IOException ex){ logger.log(Level.WARNING, "Error while locating " + name, ex); return null; } }
private List<TextureOptionValue> parseTextureOptions(final List<String> values) { final List<TextureOptionValue> matchList = new ArrayList<TextureOptionValue>(); if (values.isEmpty() || values.size() == 1) { return matchList; } // Loop through all but the last value, the last one is going to be the path. for (int i = 0; i < values.size() - 1; i++) { final String value = values.get(i); final TextureOption textureOption = TextureOption.getTextureOption(value); if (textureOption == null && !value.contains("\\") && !value.contains("/") && !values.get(0).equals("Flip") && !values.get(0).equals("Repeat")) { logger.log(Level.WARNING, "Unknown texture option \"{0}\" encountered for \"{1}\" in material \"{2}\"", new Object[]{value, key, material.getKey().getName()}); } else if (textureOption != null){ final String option = textureOption.getOptionValue(value); matchList.add(new TextureOptionValue(textureOption, option)); } } return matchList; }
@SuppressWarnings("rawtypes") @Override public AssetInfo locate(AssetManager manager, AssetKey key) { if(key instanceof ContentTextureKey) { String name = key.getName(); byte[] content = ((ContentTextureKey) key).getContent(); if(content != null) { return new ContentAssetInfo(manager, key, content); } else { logger.log(Level.WARNING, "No content for " + name); return null; } } else { logger.log(Level.SEVERE, "AssetKey should be TextureContentKey instance"); return null; } }
public AssetInfo locate(AssetManager manager, AssetKey key) { String name = key.getName(); File file = new File(root, name); if (file.exists() && file.isFile()){ try { // Now, check asset name requirements String canonical = file.getCanonicalPath(); String absolute = file.getAbsolutePath(); if (!canonical.endsWith(absolute)){ throw new AssetNotFoundException("Asset name doesn't match requirements.\n"+ "\"" + canonical + "\" doesn't match \"" + absolute + "\""); } } catch (IOException ex) { throw new AssetLoadException("Failed to get file canonical path " + file, ex); } return new AssetInfoFile(manager, key, file); }else{ return null; } }
public AssetInfo locate(AssetManager manager, AssetKey key) { if(key instanceof BlenderKey) { File linkedAbsoluteFile = new File(key.getName()); if(linkedAbsoluteFile.exists() && linkedAbsoluteFile.isFile()) { try {
/** * 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); }
@Override public AssetInfo locate(AssetManager manager, AssetKey key) { String assetPath = rootPath + key.getName();
public AssetInfo locate(AssetManager manager, AssetKey key) { URL url; String name = key.getName(); if (name.startsWith("/")) name = name.substring(1);
key = info.getKey(); assetManager = info.getManager(); sceneName = key.getName(); String ext = key.getExtension(); folderName = key.getFolder();
@Override public Object load(AssetInfo assetInfo) throws IOException { this.currentAssetInfo = assetInfo; this.assetManager = assetInfo.getManager(); AssetKey<?> assetKey = assetInfo.getKey(); if(assetKey instanceof SceneKey) animList = ((SceneKey) assetKey).getAnimations(); InputStream stream = assetInfo.openStream(); final Node sceneNode = this.sceneNode = new Node(sceneName + "-scene"); try { sceneFilename = assetKey.getName(); sceneFolderName = assetKey.getFolder(); String ext = assetKey.getExtension(); sceneName = sceneFilename.substring(0, sceneFilename.length() - ext.length() - 1); if(sceneFolderName != null && sceneFolderName.length() > 0) sceneName = sceneName.substring(sceneFolderName.length()); loadScene(stream); linkScene(); if(warnings.size() > 0) logger.log(Level.WARNING, "Model load finished with warnings:\n" + join(warnings, "\n")); } finally { releaseObjects(); if(stream != null) stream.close(); } return sceneNode; }
public Object load(AssetInfo info) throws IOException { try { key = info.getKey(); meshName = key.getName(); folderName = key.getFolder(); String ext = key.getExtension();
bitmap = BitmapFactory.decodeStream(in, null, options); if (bitmap == null) { throw new IOException("Failed to load image: " + assetInfo.getKey().getName());
materialDef.setAssetName(key.getName()); }else{ throw new MatParseException("Cannot use colon in material name/path", materialStat);
sceneFilename = assetKey.getName(); sceneFolderName = assetKey.getFolder(); String ext = assetKey.getExtension();
final AssetKey foamTextureKey = foamTexture.getKey(); if (causticsTextureKey != null && !DEFAULT_CAUSTICS.equals(causticsTextureKey.getName())) { oc.write(causticsTextureKey, "causticsTexture", null); if (heightTextureKey != null && !DEFAULT_HEIGHT_MAP.equals(heightTextureKey.getName())) { oc.write(heightTextureKey, "heightTexture", null); if (normalTextureKey != null && !DEFAULT_NORMAL_MAP.equals(normalTextureKey.getName())) { oc.write(normalTextureKey, "normalTexture", null); if (foamTextureKey != null && !DEFAULT_FOAM.equals(foamTextureKey.getName())) { oc.write(foamTextureKey, "foamTexture", null);
assetInfo.getManager().registerLocator(assetInfo.getKey().getName(), LinkedContentLocator.class);