Package com.ardor3d.util.export

Examples of com.ardor3d.util.export.Savable


        return ret;
    }

    private Savable readSavableFromCurrentElem(final Savable defVal) throws InstantiationException,
            ClassNotFoundException, IOException, IllegalAccessException {
        Savable ret = defVal;
        Savable tmp = null;

        if (_currentElem == null || _currentElem.getNodeName().equals("null")) {
            return null;
        }
        final String reference = _currentElem.getAttribute("ref");
        if (reference.length() > 0) {
            ret = _referencedSavables.get(reference);
        } else {
            String className = _currentElem.getNodeName();
            if (defVal != null) {
                className = defVal.getClass().getName();
            } else if (_currentElem.hasAttribute("class")) {
                className = _currentElem.getAttribute("class");
            }

            try {
                @SuppressWarnings("unchecked")
                final Class<? extends Savable> clazz = (Class<? extends Savable>) Class.forName(className);
                final SavableFactory ann = clazz.getAnnotation(SavableFactory.class);
                if (ann == null) {
                    tmp = clazz.newInstance();
                } else {
                    tmp = (Savable) clazz.getMethod(ann.factoryMethod(), (Class<?>[]) null).invoke(null,
                            (Object[]) null);
                }
            } catch (final InstantiationException e) {
                Logger.getLogger(getClass().getName()).logp(
                        Level.SEVERE,
                        this.getClass().toString(),
                        "readSavableFromCurrentElem(Savable)",
                        "Could not access constructor of class '" + className + "'! \n"
                                + "Some types may require the annotation SavableFactory.  Please double check.");
                throw new Ardor3dException(e);
            } catch (final NoSuchMethodException e) {
                Logger.getLogger(getClass().getName())
                        .logp(Level.SEVERE,
                                this.getClass().toString(),
                                "readSavableFromCurrentElem(Savable)",
                                e.getMessage()
                                        + " \n"
                                        + "Method specified in annotation does not appear to exist or has an invalid method signature.");
                throw new Ardor3dException(e);
            } catch (final Exception e) {
                Logger.getLogger(getClass().getName()).logp(Level.SEVERE, this.getClass().toString(),
                        "readSavableFromCurrentElem(Savable)", "Exception", e);
                return null;
            }

            final String refID = _currentElem.getAttribute("reference_ID");
            if (refID.length() > 0) {
                _referencedSavables.put(refID, tmp);
            }
            if (tmp != null) {
                tmp.read(this);
                ret = tmp;
            }
        }
        return ret;
    }
View Full Code Here


        _geomShader = capsule.readByteBuffer("geomShader", null);
        _tessControlShader = capsule.readByteBuffer("tessControlShader", null);
        _tessEvalShader = capsule.readByteBuffer("tessEvalShader", null);
        _useAttributeVBO = capsule.readBoolean("useAttributeVBO", false);

        final Savable shaderDataLogic = capsule.readSavable("shaderDataLogic", null);
        // only override set _shaderDataLogic if we have something in the capsule.
        if (shaderDataLogic != null) {
            if (shaderDataLogic instanceof GLSLShaderDataLogic) {
                _shaderDataLogic = (GLSLShaderDataLogic) shaderDataLogic;
            } else {
                logger.warning("Deserialized shaderDataLogic is not of type GLSLShaderDataLogic. "
                        + shaderDataLogic.getClass().getName());
            }
        }
    }
View Full Code Here

        }

        _localTransform.set((Transform) capsule.readSavable("localTransform", new Transform(Transform.IDENTITY)));
        _worldTransform.set((Transform) capsule.readSavable("worldTransform", new Transform(Transform.IDENTITY)));

        final Savable userData = capsule.readSavable("userData", null);
        // only override set userdata if we have something in the capsule.
        if (userData != null) {
            _userData = userData;
        }
View Full Code Here

        final BinaryExporter exporter = new BinaryExporter();
        exporter.save(meshData, bos);
        bos.flush();
        final ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
        final BinaryImporter importer = new BinaryImporter();
        final Savable sav = importer.load(bis);
        return (MeshData) sav;
    }
View Full Code Here

TOP

Related Classes of com.ardor3d.util.export.Savable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.