public Object load(AssetInfo info) throws IOException { assetManager = info.getManager(); InputStream in = info.openStream(); try { return load(in); } finally { if (in != null) in.close(); } }
public Object load(AssetInfo info){ // if (!(info.getKey() instanceof ModelKey)) // throw new IllegalArgumentException("Model assets must be loaded using a ModelKey"); assetManager = info.getManager(); InputStream is = null; try { is = info.openStream(); Savable s = load(is); return s; } catch (IOException ex) { logger.log(Level.SEVERE, "An error occured while loading jME binary object", ex); } finally { if (is != null){ try { is.close(); } catch (IOException ex) {} } } return null; }
public Object load(AssetInfo info) throws IOException { InputStream in = null; try { in = info.openStream(); return load(info.getManager(), info.getKey(), in); } finally { if (in != null){ in.close(); } } }
protected byte[] getBytes(int bufferIndex, String uri, Integer bufferLength) throws IOException { byte[] data; if (uri != null) { if (uri.startsWith("data:")) { //base 64 embed data data = DatatypeConverter.parseBase64Binary(uri.substring(uri.indexOf(",") + 1)); } else { //external file let's load it if (!uri.endsWith(".bin")) { throw new AssetLoadException("Cannot load " + uri + ", a .bin extension is required."); } BinDataKey key = new BinDataKey(info.getKey().getFolder() + uri); InputStream input = (InputStream) info.getManager().loadAsset(key); data = new byte[bufferLength]; DataInputStream dataStream = new DataInputStream(input); dataStream.readFully(data); dataStream.close(); } } else { //no URI this should not happen in a gltf file, only in glb files. throw new AssetLoadException("Buffer " + bufferIndex + " has no uri"); } return data; }
public Object load(AssetInfo info) throws IOException { InputStream in = null; try { in = info.openStream(); BitmapFont font = load(info.getManager(), info.getKey().getFolder(), in); return font; } finally { if (in != null){ in.close(); } } }
/** * 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 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; } }
this.assetManager = info.getManager(); Reader reader = new InputStreamReader(info.openStream()); boolean injectDependencies = true;
public Object load(AssetInfo info) throws IOException { try { key = info.getKey(); assetManager = info.getManager(); sceneName = key.getName(); String ext = key.getExtension();
String extension = mimeType.split("/")[1]; TextureKey key = new TextureKey("image" + sourceIndex + "." + extension, flip); result = (Texture2D) info.getManager().loadAssetFromStream(key, new ByteArrayInputStream(data)); String extension = headerInfo.split("/")[1]; TextureKey key = new TextureKey("image" + sourceIndex + "." + extension, flip); result = (Texture2D) info.getManager().loadAssetFromStream(key, new ByteArrayInputStream(data)); } else { Texture tex = info.getManager().loadTexture(key); result = (Texture2D) tex;
@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; }
meshName = meshName.substring(folderName.length()); assetManager = info.getManager();
stream.close(); return assetInfo.getManager().loadAsset(new SceneKey(key.getFolder() + modelName, animList));
@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(); }
defaultMat = new Material(assetInfo.getManager(), "Common/MatDefs/Light/PBRLighting.j3md"); defaultMat.setColor("BaseColor", ColorRGBA.White); defaultMat.setFloat("Metallic", 0f);
assetManager = info.getManager(); objName = key.getName();
@Override public Object handleExtension(GltfLoader loader, String parentName, JsonElement parent, JsonElement extension, Object input) throws IOException { MaterialAdapter adapter = materialAdapter; AssetKey key = loader.getInfo().getKey(); //check for a custom adapter for spec/gloss pipeline if (key instanceof GltfModelKey) { GltfModelKey gltfKey = (GltfModelKey) key; MaterialAdapter ma = gltfKey.getAdapterForMaterial("pbrSpecularGlossiness"); if (ma != null) { adapter = ma; } } adapter.init(loader.getInfo().getManager()); adapter.setParam("diffuseFactor", getAsColor(extension.getAsJsonObject(), "diffuseFactor")); adapter.setParam("specularFactor", getAsColor(extension.getAsJsonObject(), "specularFactor")); adapter.setParam("glossinessFactor", getAsFloat(extension.getAsJsonObject(), "glossinessFactor")); adapter.setParam("diffuseTexture", loader.readTexture(extension.getAsJsonObject().getAsJsonObject("diffuseTexture"))); adapter.setParam("specularGlossinessTexture", loader.readTexture(extension.getAsJsonObject().getAsJsonObject("specularGlossinessTexture"))); return adapter; } }
@Override public Object load(AssetInfo assetInfo) throws IOException { this.assetManager = assetInfo.getManager(); AssetKey<?> assetKey = assetInfo.getKey(); if (!(assetKey instanceof ModelKey)) {
this.assetManager = info.getManager(); folderName = info.getKey().getFolder(); matList = new MaterialList();
adapter = defaultMaterialAdapters.get("pbrMetallicRoughness"); adapter.init(info.getManager()); logger.log(Level.WARNING, "Couldn't find any matching material definition for material " + materialIndex); adapter = defaultMaterialAdapters.get("pbrMetallicRoughness"); adapter.init(info.getManager()); setDefaultParams(adapter.getMaterial());