BinaryImporter imp = BinaryImporter.getInstance(); if (manager != null) { imp.setAssetManager(manager);
/** * Saves the object into memory then loads it from memory. * * Used by tests to check if the persistence system is working. * * @param <T> The type of savable. * @param assetManager AssetManager to load assets from. * @param object The object to save and then load. * @return A new instance that has been saved and loaded from the * original object. */ public static <T extends Savable> T saveAndLoad(AssetManager assetManager, T object) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { BinaryExporter exporter = new BinaryExporter(); exporter.save(object, baos); BinaryImporter importer = new BinaryImporter(); importer.setAssetManager(assetManager); return (T) importer.load(baos.toByteArray()); } catch (IOException ex) { // Should never happen. throw new AssertionError(ex); } }
fis = new FileInputStream(f); BinaryImporter imp = BinaryImporter.getInstance(); imp.setAssetManager(assetManager); terrain = (TerrainQuad) imp.load(new BufferedInputStream(fis)); rootNode.attachChild((Node)terrain);
@Override public void simpleInitApp() { Spatial ogreModel = assetManager.loadModel("Models/Oto/Oto.mesh.xml"); DirectionalLight dl = new DirectionalLight(); dl.setColor(ColorRGBA.White); dl.setDirection(new Vector3f(0,-1,-1).normalizeLocal()); rootNode.addLight(dl); try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); BinaryExporter exp = new BinaryExporter(); exp.save(ogreModel, baos); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); BinaryImporter imp = new BinaryImporter(); imp.setAssetManager(assetManager); Node ogreModelReloaded = (Node) imp.load(bais, null, null); AnimComposer composer = ogreModelReloaded.getControl(AnimComposer.class); composer.setCurrentAction("Walk"); rootNode.attachChild(ogreModelReloaded); } catch (IOException ex){ ex.printStackTrace(); } } }
imp.setAssetManager(assetManager); Node newLoaderNode=(Node)imp.load(bin);
imp.setAssetManager(assetManager); Node newPhysicsRootNode=(Node)imp.load(bin);
BinaryImporter imp = BinaryImporter.getInstance(); if (manager != null) { imp.setAssetManager(manager);
BinaryImporter imp = BinaryImporter.getInstance(); if (manager != null) { imp.setAssetManager(manager);
/** * Saves the object into memory then loads it from memory. * * Used by tests to check if the persistence system is working. * * @param <T> The type of savable. * @param assetManager AssetManager to load assets from. * @param object The object to save and then load. * @return A new instance that has been saved and loaded from the * original object. */ public static <T extends Savable> T saveAndLoad(AssetManager assetManager, T object) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { BinaryExporter exporter = new BinaryExporter(); exporter.save(object, baos); BinaryImporter importer = new BinaryImporter(); importer.setAssetManager(assetManager); return (T) importer.load(baos.toByteArray()); } catch (IOException ex) { // Should never happen. throw new AssertionError(ex); } }