public AssetKey(String name){ this.name = reducePath(name); this.extension = getExtension(this.name); }
/** * Returns the AssetLoader registered for the given extension * of the current thread. * @return AssetLoader registered with addLoader. */ public AssetLoader aquireLoader(AssetKey key){ // No need to synchronize() against map, its concurrent ImplThreadLocal local = extensionToLoaderMap.get(key.getExtension()); if (local == null){ throw new AssetLoadException("No loader registered for type \"" + key.getExtension() + "\""); } return (AssetLoader) local.get(); }
/** * Loads and return a cursor file of one of the following format: .ani, .cur and .ico. * @param info The {@link AssetInfo} describing the cursor file. * @return A JmeCursor representation of the LWJGL's Cursor. * @throws IOException if the file is not found. */ public JmeCursor load(AssetInfo info) throws IOException { isIco = false; isAni = false; isCur = false; isIco = ((AssetKey) info.getKey()).getExtension().equals("ico"); if (!isIco) { isCur = ((AssetKey) info.getKey()).getExtension().equals("cur"); if (!isCur) { isAni = ((AssetKey) info.getKey()).getExtension().equals("ani"); } } if (!isAni && !isIco && !isCur) { throw new IllegalArgumentException("Cursors supported are .ico, .cur or .ani"); } InputStream in = null; try { in = info.openStream(); return loadCursor(in); } finally { if (in != null) { in.close(); } } }
public Object load(AssetInfo info) throws IOException { this.assetManager = info.getManager(); InputStream in = info.openStream(); try { key = info.getKey(); if (key.getExtension().equals("j3m") && !(key instanceof MaterialKey)) { throw new IOException("Material instances must be loaded via MaterialKey"); } else if (key.getExtension().equals("j3md") && key instanceof MaterialKey) { throw new IOException("Material definitions must be loaded via AssetKey"); } loadFromRoot(BlockLanguageParser.parse(in)); } finally { if (in != null){ in.close(); } } if (material != null){ // material implementation return material; }else{ // material definition return materialDef; } }
public void read(JmeImporter im) throws IOException { InputCapsule ic = im.getCapsule(this); name = reducePath(ic.readString("name", null)); extension = getExtension(name); }
injectDependencies = ((ShaderAssetKey) info.getKey()).isInjectDependencies(); if (info.getKey().getExtension().equals("glsllib")) {
assetManager = info.getManager(); sceneName = key.getName(); String ext = key.getExtension(); folderName = key.getFolder(); sceneName = sceneName.substring(0, sceneName.length() - ext.length() - 1);
@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; }
@Before public void setUp() throws Exception { when(assetKey.getExtension()).thenReturn(".j3m"); when(assetInfo.getManager()).thenReturn(assetManager); when(assetInfo.getKey()).thenReturn(assetKey); when(assetManager.loadAsset(any(AssetKey.class))).thenReturn(materialDef); j3MLoader = new J3MLoader(); }
meshName = key.getName(); folderName = key.getFolder(); String ext = key.getExtension(); meshName = meshName.substring(0, meshName.length() - ext.length() - 1); if (folderName != null && folderName.length() > 0) {
public Object load(AssetInfo info) throws IOException { if (ImageIO.getImageReadersBySuffix(info.getKey().getExtension()) != null){ boolean flip = ((TextureKey) info.getKey()).isFlipY(); InputStream in = null; try { in = info.openStream(); Image img = load(in, flip); if (img == null){ throw new AssetLoadException("The given image cannot be loaded " + info.getKey()); } return img; } finally { if (in != null){ in.close(); } } }else{ throw new AssetLoadException("The extension " + info.getKey().getExtension() + " is not supported"); } } }
sceneFilename = assetKey.getName(); sceneFolderName = assetKey.getFolder(); String ext = assetKey.getExtension();
@Override public void assetRequested(AssetKey key) { if (key.getExtension().equals("png") || key.getExtension().equals("jpg") || key.getExtension().equals("dds")) { TextureKey tkey = (TextureKey) key; tkey.setAnisotropy(Settings.getInstance().getSettingInteger(Settings.Setting.ANISOTROPY)); } }
public AssetKey(String name){ this.name = reducePath(name); this.extension = getExtension(this.name); }
public AssetKey(String name){ this.name = reducePath(name); this.extension = getExtension(this.name); }
/** * Returns the AssetLoader registered for the given extension * of the current thread. * @return AssetLoader registered with addLoader. */ public AssetLoader aquireLoader(AssetKey key){ // No need to synchronize() against map, its concurrent ImplThreadLocal local = extensionToLoaderMap.get(key.getExtension()); if (local == null){ throw new AssetLoadException("No loader registered for type \"" + key.getExtension() + "\""); } return (AssetLoader) local.get(); }
/** * Returns the AssetLoader registered for the given extension * of the current thread. * @return AssetLoader registered with addLoader. */ public AssetLoader aquireLoader(AssetKey key){ synchronized (loaders){ ImplThreadLocal local = loaders.get(key.getExtension()); if (local != null){ AssetLoader loader = (AssetLoader) local.get(); return loader; } return null; } }
public void read(JmeImporter im) throws IOException { InputCapsule ic = im.getCapsule(this); name = reducePath(ic.readString("name", null)); extension = getExtension(name); }
public void read(JmeImporter im) throws IOException { InputCapsule ic = im.getCapsule(this); name = reducePath(ic.readString("name", null)); extension = getExtension(name); }
public Object load(AssetInfo info) throws IOException { if (ImageIO.getImageWritersBySuffix(info.getKey().getExtension()) != null){ 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(); } } } return null; } }