private void startSkeleton(String name) { AssetKey assetKey = new AssetKey(folderName + name + ".xml"); try { animData = (AnimData) assetManager.loadAsset(assetKey); } catch (AssetNotFoundException ex) { logger.log(Level.WARNING, "Cannot locate {0} for model {1}", new Object[]{assetKey, key}); animData = null; } }
public Object loadAsset(String name){ return loadAsset(new AssetKey(name)); }
public Material(AssetManager contentMan, String defName) { this((MaterialDef) contentMan.loadAsset(new AssetKey(defName))); }
public BitmapFont loadFont(String name){ return (BitmapFont) loadAsset(new AssetKey(name)); }
public void init() { AssetInfo info = assetManager.locateAsset(new AssetKey<Shader>(fileName)); if (info != null && info instanceof UrlAssetInfo) { try { Field f = info.getClass().getDeclaredField("url"); f.setAccessible(true); URL url = (URL) f.get(info); file = new File(url.getFile()); fileLastM = file.lastModified(); } catch (NoSuchFieldException ex) { Logger.getLogger(MaterialDebugAppState.class.getName()).log(Level.SEVERE, null, ex); } catch (SecurityException ex) { Logger.getLogger(MaterialDebugAppState.class.getName()).log(Level.SEVERE, null, ex); } catch (IllegalArgumentException ex) { Logger.getLogger(MaterialDebugAppState.class.getName()).log(Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { Logger.getLogger(MaterialDebugAppState.class.getName()).log(Level.SEVERE, null, ex); } } }
protected void loadMtlLib(String name) throws IOException{ if (!name.toLowerCase().endsWith(".mtl")) throw new IOException("Expected .mtl file! Got: " + name); // NOTE: Cut off any relative/absolute paths name = new File(name).getName(); AssetKey mtlKey = new AssetKey(key.getFolder() + name); try { matList = (MaterialList) assetManager.loadAsset(mtlKey); } catch (AssetNotFoundException ex){ logger.log(Level.WARNING, "Cannot locate {0} for model {1}", new Object[]{name, key}); } if (matList != null){ // create face lists for every material for (String matName : matList.keySet()){ matFaces.put(matName, new ArrayList<Face>()); } } }
private void buildSourcesRec(BufferedReader reader, StringBuilder builder, AssetManager assetManager) throws IOException { String ln; while ((ln = reader.readLine()) != null) { if (ln.trim().startsWith("#import ")) { ln = ln.trim().substring(8).trim(); if (ln.startsWith("\"")) { ln = ln.substring(1); } if (ln.endsWith("\"")) { ln = ln.substring(0, ln.length()-1); } AssetInfo info = assetManager.locateAsset(new AssetKey<String>(ln)); if (info == null) { throw new AssetNotFoundException("Unable to load source file \""+ln+"\""); } try (BufferedReader r = new BufferedReader(new InputStreamReader(info.openStream()))) { builder.append("//-- begin import ").append(ln).append(" --\n"); buildSourcesRec(r, builder, assetManager); builder.append("//-- end import ").append(ln).append(" --\n"); } } else { builder.append(ln).append('\n'); } } }
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); } }
str.append(include); for (String res : resources) { AssetInfo info = assetManager.locateAsset(new AssetKey<String>(res)); if (info == null) { throw new AssetNotFoundException("Unable to load source file \""+res+"\"");
private BitmapFont load(AssetManager assetManager, String folder, InputStream in) throws IOException{ MaterialDef spriteMat = (MaterialDef) assetManager.loadAsset(new AssetKey("Common/MatDefs/Misc/Unshaded.j3md")); BitmapCharacterSet charSet = new BitmapCharacterSet(); Material[] matPages = null;
MaterialDef def = (MaterialDef) assetManager.loadAsset(new AssetKey(extendedMat)); if (def == null) { throw new MatParseException("Extended material " + extendedMat + " cannot be found.", materialStat);
AssetInfo a = am.locateAsset(new AssetKey<Object>("Interface/Fonts/Default.fnt"));
AssetInfo info = new AssetInfo(assetManager, new AssetKey("test")) { @Override public InputStream openStream() {
def = (MaterialDef) im.getAssetManager().loadAsset(new AssetKey(defName)); paramValues = new ListMap<String, MatParam>();
AssetInfo info = new AssetInfo(assetManager, new AssetKey("test")) { @Override public InputStream openStream() {
private void startSkeleton(String name) { AssetKey assetKey = new AssetKey(folderName + name + ".xml"); try { animData = (AnimData) assetManager.loadAsset(assetKey); } catch (AssetNotFoundException ex) { logger.log(Level.WARNING, "Cannot locate {0} for model {1}", new Object[]{assetKey, key}); animData = null; } }
private void startSkeleton(String name) { AssetKey assetKey = new AssetKey(folderName + name + ".xml"); try { animData = (AnimData) assetManager.loadAsset(assetKey); } catch (AssetNotFoundException ex) { logger.log(Level.WARNING, "Cannot locate {0} for model {1}", new Object[]{assetKey, key}); animData = null; } }
private void startSkeleton(String name) { AssetKey assetKey = new AssetKey(folderName + name + ".xml"); try { animData = (AnimData) assetManager.loadAsset(assetKey); } catch (AssetNotFoundException ex) { logger.log(Level.WARNING, "Cannot locate {0} for model {1}", new Object[]{assetKey, key}); animData = null; } }
/** * Loads a bitmap font with the given name. * * @param name * @return */ public BitmapFont loadFont(String name){ return (BitmapFont) loadAsset(new AssetKey(name)); }
private static void drawImage(AssetManager assetManager, Graphics2D g, int width, int height, String image) { if (image != null) { try { // TODO: cache the images BufferedImage img = ImageIO.read(assetManager.locateAsset(new AssetKey(image)).openStream()); g.drawImage(img, (width - img.getWidth()) / 2, (height - img.getHeight()) / 2, null); } catch (Exception ex) { logger.log(Level.SEVERE, "Can't load the texture " + image + "!", ex); } } }