Package com.ardor3d.extension.model.collada.jdom.data

Examples of com.ardor3d.extension.model.collada.jdom.data.ColladaStorage


        // Add a call back to load clips.
        final InputStore input = new InputStore();
        input.getClips().setMissCallback(new MissingCallback<String, AnimationClip>() {
            public AnimationClip getValue(final String key) {
                try {
                    final ColladaStorage storage1 = colladaImporter.load("collada/skeleton/" + key + ".dae");
                    return storage1.extractChannelsAsClip(key);
                } catch (final IOException e) {
                    e.printStackTrace();
                }
                return null;
            }
View Full Code Here


     * @return a ColladaStorage data object containing the Collada scene and other useful elements.
     * @throws IOException
     *             if the resource can not be loaded for some reason.
     */
    public ColladaStorage load(final ResourceSource resource) throws IOException {
        final ColladaStorage colladaStorage = new ColladaStorage();
        final DataCache dataCache = new DataCache();
        if (_externalJointMapping != null) {
            dataCache.getExternalJointMapping().putAll(_externalJointMapping);
        }
        final ColladaDOMUtil colladaDOMUtil = new ColladaDOMUtil(dataCache);
        final ColladaMaterialUtils colladaMaterialUtils = new ColladaMaterialUtils(this, dataCache, colladaDOMUtil);
        final ColladaMeshUtils colladaMeshUtils = new ColladaMeshUtils(dataCache, colladaDOMUtil, colladaMaterialUtils,
                _optimizeMeshes, _optimizeSettings);
        final ColladaAnimUtils colladaAnimUtils = new ColladaAnimUtils(colladaStorage, dataCache, colladaDOMUtil,
                colladaMeshUtils);
        final ColladaNodeUtils colladaNodeUtils = new ColladaNodeUtils(dataCache, colladaDOMUtil, colladaMaterialUtils,
                colladaMeshUtils, colladaAnimUtils);

        try {
            // Pull in the DOM tree of the Collada resource.
            final Element collada = readCollada(resource, dataCache);

            // if we don't specify a texture locator, add a temporary texture locator at the location of this model
            // resource..
            final boolean addLocator = _textureLocator == null;

            final RelativeResourceLocator loc;
            if (addLocator) {
                loc = new RelativeResourceLocator(resource);
                ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_TEXTURE, loc);
            } else {
                loc = null;
            }

            final AssetData assetData = colladaNodeUtils.parseAsset(collada.getChild("asset"));

            // Collada may or may not have a scene, so this can return null.
            final Node scene = colladaNodeUtils.getVisualScene(collada);

            if (_loadAnimations) {
                colladaAnimUtils.parseLibraryAnimations(collada);
            }

            // reattach attachments to scene
            if (scene != null) {
                colladaNodeUtils.reattachAttachments(scene);
            }

            // set our scene into storage
            colladaStorage.setScene(scene);

            // set our asset data into storage
            colladaStorage.setAssetData(assetData);

            // drop our added locator if needed.
            if (addLocator) {
                ResourceLocatorTool.removeResourceLocator(ResourceLocatorTool.TYPE_TEXTURE, loc);
            }

            // copy across our mesh colors - only for objects with multiple channels
            final Multimap<MeshData, FloatBuffer> colors = ArrayListMultimap.create();
            final Multimap<MeshData, FloatBuffer> temp = dataCache.getParsedVertexColors();
            for (final MeshData key : temp.keySet()) {
                // only copy multiple channels since their data is lost
                final Collection<FloatBuffer> val = temp.get(key);
                if (val != null && val.size() > 1) {
                    colors.putAll(key, val);
                }
            }
            colladaStorage.setParsedVertexColors(colors);

            // copy across our mesh material info
            colladaStorage.setMeshMaterialInfo(dataCache.getMeshMaterialMap());
            colladaStorage.setMaterialMap(dataCache.getMaterialInfoMap());

            // return storage
            return colladaStorage;
        } catch (final Exception e) {
            throw new IOException("Unable to load collada resource from URL: " + resource, e);
View Full Code Here

TOP

Related Classes of com.ardor3d.extension.model.collada.jdom.data.ColladaStorage

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.