Example usage for org.jdom2 Element getChildren

List of usage examples for org.jdom2 Element getChildren

Introduction

In this page you can find the example usage for org.jdom2 Element getChildren.

Prototype

public List<Element> getChildren() 

Source Link

Document

This returns a List of all the child elements nested directly (one level deep) within this element, as Element objects.

Usage

From source file:com.abyala.decisiontree.SimpleDecisionTreeParser.java

License:Open Source License

private Node parseInputs(final String parentPath, final List<Element> inputs,
        final Map<String, InputType> types, final ResultSpec resultSpec) throws DecisionTreeParserException {
    final String inputName = getInputName(parentPath, inputs);
    final String nodePath = parentPath + inputName;
    final InputType inputType = getInputType(inputName, types);
    final NodeBuilder builder = inputType.createNodeBuilder();

    for (Element input : inputs) {
        final String value = input.getAttributeValue("value");
        final String refId = input.getAttributeValue("refid");
        final String childPath = nodePath + "=" + value;
        final List<Element> children = input.getChildren();

        if (refId != null) {
            if (!children.isEmpty()) {
                throw new DecisionTreeParserException(
                        "Node at path " + childPath + " may not have both a refid and child elements.");
            } else {
                builder.addReferenceMapping(value, refId);
            }/*  ww  w  .  j a  v  a  2s  .  c o m*/
        } else if (children.isEmpty()) {
            throw new DecisionTreeParserException(
                    "Node at path " + childPath + " must have a result, child inputs, or a refid");
        } else if (children.size() == 1 && "result".equals(children.get(0).getName())) {
            builder.addResultMapping(value, parseResult(children.get(0), resultSpec));
        } else {
            builder.addNodeMapping(value, parseInputs(childPath + "/", children, types, resultSpec));
        }
    }

    return builder.build();
}

From source file:com.abyala.decisiontree.SimpleDecisionTreeParser.java

License:Open Source License

protected Map<String, InputType> parseInputTypes(final Element child) throws DecisionTreeParserException {
    final Map<String, InputType> types = new HashMap<String, InputType>(child.getChildren().size());

    for (Element typeElement : child.getChildren()) {
        final InputType type = parseInputType(typeElement);

        if ("result".equals(type.getName())) {
            throw new DecisionTreeParserException(
                    "Invalid configuration: No input-type may be named \"result\" since it is() a reserved keyword");
        }// w ww .  ja  v  a2  s .c  o m

        types.put(type.getName(), type);
    }

    return types;
}

From source file:com.archimatetool.editor.model.compatibility.Archimate2To3Converter.java

License:Open Source License

/**
 * Remove "Derived" folder and move contents to "Relations" folder
 *//* w w w  . jav  a 2s  .  c  om*/
private void moveDerivedRelationsFolderContents() {
    Element eDerivedFolder = getModelFolder("derived");
    if (eDerivedFolder != null) {
        eDerivedFolder.detach();

        Element eRelationsFolder = getModelFolder("relations");
        if (eRelationsFolder != null) {
            List<Element> copy = new ArrayList<>(eDerivedFolder.getChildren());
            for (Element eChild : copy) {
                eChild.detach();
                eRelationsFolder.addContent(eChild);
            }
        }
    }
}

From source file:com.archimatetool.editor.model.compatibility.Archimate2To3Converter.java

License:Open Source License

private void traverseAllElements(Element element) {
    // "relationship" type
    convertRelationshipType(element);/*from  w ww  .  j  a va2  s .c  om*/

    // concept type name
    convertConceptTypeName(element);

    // move concepts
    moveConceptType(element);

    // Children
    List<Element> copy = new ArrayList<>(element.getChildren());
    for (Element eChild : copy) {
        traverseAllElements(eChild);
    }
}

From source file:com.ardor3d.extension.model.collada.jdom.ColladaAnimUtils.java

License:Open Source License

/**
 * Parse all animations in library_animations
 * //from   w w w .  j a v a2 s  . co m
 * @param colladaRoot
 */
public void parseLibraryAnimations(final Element colladaRoot) {
    final Element libraryAnimations = colladaRoot.getChild("library_animations");

    if (libraryAnimations == null || libraryAnimations.getChildren().isEmpty()) {
        if (logger.isLoggable(Level.WARNING)) {
            logger.warning("No animations found in collada file!");
        }
        return;
    }

    final AnimationItem animationItemRoot = new AnimationItem("Animation Root");
    _colladaStorage.setAnimationItemRoot(animationItemRoot);

    final Multimap<Element, TargetChannel> channelMap = ArrayListMultimap.create();

    parseAnimations(channelMap, libraryAnimations, animationItemRoot);

    for (final Element key : channelMap.keySet()) {
        buildAnimations(key, channelMap.get(key));
    }
}

From source file:com.ardor3d.extension.model.collada.jdom.ColladaAnimUtils.java

License:Open Source License

/**
 * Merge all animation channels into Ardor jointchannels
 * // w w  w  .  ja v  a2s  . c  o m
 * @param entry
 */
@SuppressWarnings("unchecked")
private void buildAnimations(final Element parentElement, final Collection<TargetChannel> targetList) {

    final List<Element> elementTransforms = new ArrayList<Element>();
    for (final Element child : parentElement.getChildren()) {
        if (_dataCache.getTransformTypes().contains(child.getName())) {
            elementTransforms.add(child);
        }
    }
    final List<TransformElement> transformList = getNodeTransformList(elementTransforms);

    AnimationItem animationItemRoot = null;
    for (final TargetChannel targetChannel : targetList) {
        if (animationItemRoot == null) {
            animationItemRoot = targetChannel.animationItemRoot;
        }
        final String source = targetChannel.source;
        // final Target target = targetChannel.target;
        final Element targetNode = targetChannel.targetNode;

        final int targetIndex = elementTransforms.indexOf(targetNode);
        if (logger.isLoggable(Level.FINE)) {
            logger.fine(parentElement.getName() + "(" + parentElement.getAttributeValue("name") + ") -> "
                    + targetNode.getName() + "(" + targetIndex + ")");
        }

        final EnumMap<Type, ColladaInputPipe> pipes = Maps.newEnumMap(Type.class);

        final Element samplerElement = _colladaDOMUtil.findTargetWithId(source);
        for (final Element inputElement : samplerElement.getChildren("input")) {
            final ColladaInputPipe pipe = new ColladaInputPipe(_colladaDOMUtil, inputElement);
            pipes.put(pipe.getType(), pipe);
        }

        // get input (which is TIME for now)
        final ColladaInputPipe inputPipe = pipes.get(Type.INPUT);
        final ColladaInputPipe.SourceData sdIn = inputPipe.getSourceData();
        final float[] time = sdIn.floatArray;
        targetChannel.time = time;
        if (logger.isLoggable(Level.FINE)) {
            logger.fine("inputPipe: " + Arrays.toString(time));
        }

        // get output data
        final ColladaInputPipe outputPipe = pipes.get(Type.OUTPUT);
        final ColladaInputPipe.SourceData sdOut = outputPipe.getSourceData();
        final float[] animationData = sdOut.floatArray;
        targetChannel.animationData = animationData;
        if (logger.isLoggable(Level.FINE)) {
            logger.fine("outputPipe: " + Arrays.toString(animationData));
        }

        // TODO: Need to add support for other interpolation types.

        // get target array from transform list
        final TransformElement transformElement = transformList.get(targetIndex);
        final double[] array = transformElement.getArray();
        targetChannel.array = array;

        final int stride = sdOut.stride;
        targetChannel.stride = stride;

        targetChannel.currentPos = 0;
    }

    final List<Float> finalTimeList = Lists.newArrayList();
    final List<Transform> finalTransformList = Lists.newArrayList();
    final List<TargetChannel> workingChannels = Lists.newArrayList();
    for (;;) {
        float lowestTime = Float.MAX_VALUE;
        boolean found = false;
        for (final TargetChannel targetChannel : targetList) {
            if (targetChannel.currentPos < targetChannel.time.length) {
                final float time = targetChannel.time[targetChannel.currentPos];
                if (time < lowestTime) {
                    lowestTime = time;
                }
                found = true;
            }
        }
        if (!found) {
            break;
        }

        workingChannels.clear();
        for (final TargetChannel targetChannel : targetList) {
            if (targetChannel.currentPos < targetChannel.time.length) {
                final float time = targetChannel.time[targetChannel.currentPos];
                if (time == lowestTime) {
                    workingChannels.add(targetChannel);
                }
            }
        }

        for (final TargetChannel targetChannel : workingChannels) {
            final Target target = targetChannel.target;
            final float[] animationData = targetChannel.animationData;
            final double[] array = targetChannel.array;

            // set the correct values depending on accessor
            final int position = targetChannel.currentPos * targetChannel.stride;
            if (target.accessorType == AccessorType.None) {
                for (int j = 0; j < array.length; j++) {
                    array[j] = animationData[position + j];
                }
            } else {
                if (target.accessorType == AccessorType.Vector) {
                    array[target.accessorIndexX] = animationData[position];
                } else if (target.accessorType == AccessorType.Matrix) {
                    array[target.accessorIndexY * 4 + target.accessorIndexX] = animationData[position];
                }
            }
            targetChannel.currentPos++;
        }

        // bake the transform
        final Transform transform = bakeTransforms(transformList);
        finalTimeList.add(lowestTime);
        finalTransformList.add(transform);
    }

    final float[] time = new float[finalTimeList.size()];
    for (int i = 0; i < finalTimeList.size(); i++) {
        time[i] = finalTimeList.get(i);
    }
    final Transform[] transforms = finalTransformList.toArray(new Transform[finalTransformList.size()]);

    AnimationClip animationClip = animationItemRoot.getAnimationClip();
    if (animationClip == null) {
        animationClip = new AnimationClip(animationItemRoot.getName());
        animationItemRoot.setAnimationClip(animationClip);
    }

    // Make an animation channel - first find if we have a matching joint
    Joint joint = _dataCache.getElementJointMapping().get(parentElement);
    if (joint == null) {
        String nodeName = parentElement.getAttributeValue("name", (String) null);
        if (nodeName == null) { // use id if name doesn't exist
            nodeName = parentElement.getAttributeValue("id", parentElement.getName());
        }
        if (nodeName != null) {
            joint = _dataCache.getExternalJointMapping().get(nodeName);
        }

        if (joint == null) {
            // no joint still, so make a transform channel.
            final TransformChannel transformChannel = new TransformChannel(nodeName, time, transforms);
            animationClip.addChannel(transformChannel);
            _colladaStorage.getAnimationChannels().add(transformChannel);
            return;
        }
    }

    // create joint channel
    final JointChannel jointChannel = new JointChannel(joint, time, transforms);
    animationClip.addChannel(jointChannel);
    _colladaStorage.getAnimationChannels().add(jointChannel);
}

From source file:com.ardor3d.extension.model.collada.jdom.ColladaAnimUtils.java

License:Open Source License

@SuppressWarnings("unchecked")
private static void getElementString(final Element e, final StringBuilder str, final int depth,
        final int maxDepth, final boolean showDots) {
    addSpacing(str, depth);//from ww w .  ja v a 2  s .com
    str.append('<');
    str.append(e.getName());
    str.append(' ');
    final List<Attribute> attrs = e.getAttributes();
    for (int i = 0; i < attrs.size(); i++) {
        final Attribute attr = attrs.get(i);
        str.append(attr.getName());
        str.append("=\"");
        str.append(attr.getValue());
        str.append('"');
        if (i < attrs.size() - 1) {
            str.append(' ');
        }
    }
    if (!e.getChildren().isEmpty() || !"".equals(e.getText())) {
        str.append('>');
        if (depth < maxDepth) {
            str.append('\n');
            for (final Element child : (List<Element>) e.getChildren()) {
                getElementString(child, str, depth + 1, maxDepth, showDots);
            }
            if (!"".equals(e.getText())) {
                addSpacing(str, depth + 1);
                str.append(e.getText());
                str.append('\n');
            }
        } else if (showDots) {
            str.append('\n');
            addSpacing(str, depth + 1);
            str.append("...");
            str.append('\n');
        }
        addSpacing(str, depth);
        str.append("</");
        str.append(e.getName());
        str.append('>');
    } else {
        str.append("/>");
    }
    str.append('\n');
}

From source file:com.ardor3d.extension.model.collada.jdom.ColladaDOMUtil.java

License:Open Source License

/**
 * Strips the namespace from all nodes in a tree.
 * // w w  w.  j  av a2s.  c om
 * @param rootElement
 *            Root of strip operation
 */
public void stripNamespace(final Element rootElement) {
    rootElement.setNamespace(null);

    @SuppressWarnings("unchecked")
    final List<Element> children = rootElement.getChildren();
    final Iterator<Element> i = children.iterator();
    while (i.hasNext()) {
        final Element child = i.next();
        stripNamespace(child);
    }
}

From source file:com.ardor3d.extension.model.collada.jdom.ColladaMaterialUtils.java

License:Open Source License

/**
 * Find and apply the given material to the given Mesh.
 * //  w  w w  .j a v a  2 s  .c om
 * @param materialName
 *            our material name
 * @param mesh
 *            the mesh to apply material to.
 */
public void applyMaterial(final String materialName, final Mesh mesh) {
    if (materialName == null) {
        logger.warning("materialName is null");
        return;
    }

    Element mat = _dataCache.getBoundMaterial(materialName);
    if (mat == null) {
        logger.warning("material not bound: " + materialName + ", trying search with id.");
        mat = _colladaDOMUtil.findTargetWithId(materialName);
    }
    if (mat == null || !"material".equals(mat.getName())) {
        logger.warning("material not found: " + materialName);
        return;
    }

    final String originalMaterial = mat.getAttributeValue("id");
    MaterialInfo mInfo = null;
    if (!_dataCache.getMaterialInfoMap().containsKey(originalMaterial)) {
        mInfo = new MaterialInfo();
        mInfo.setMaterialName(originalMaterial);
        _dataCache.getMaterialInfoMap().put(originalMaterial, mInfo);
    }
    _dataCache.getMeshMaterialMap().put(mesh, originalMaterial);

    final Element child = mat.getChild("instance_effect");
    final Element effectNode = _colladaDOMUtil.findTargetWithId(child.getAttributeValue("url"));
    if (effectNode == null) {
        logger.warning(
                "material effect not found: " + mat.getChild("instance_material").getAttributeValue("url"));
        return;
    }

    if ("effect".equals(effectNode.getName())) {
        /*
         * temp cache for textures, we do not want to add textures twice (for example, transparant map might point
         * to diffuse texture)
         */
        final HashMap<String, Texture> loadedTextures = new HashMap<String, Texture>();
        final Element effect = effectNode;
        // XXX: For now, just grab the common technique:
        final Element common = effect.getChild("profile_COMMON");
        if (common != null) {
            if (mInfo != null) {
                mInfo.setProfile("COMMON");
            }

            final Element commonExtra = common.getChild("extra");
            if (commonExtra != null) {
                // process with any plugins
                _importer.readExtra(commonExtra, mesh);
            }

            final Element technique = common.getChild("technique");
            String type = "blinn";
            if (technique.getChild(type) == null) {
                type = "phong";
                if (technique.getChild(type) == null) {
                    type = "lambert";
                    if (technique.getChild(type) == null) {
                        type = "constant";
                        if (technique.getChild(type) == null) {
                            ColladaMaterialUtils.logger.warning("COMMON material has unusuable techinque. "
                                    + child.getAttributeValue("url"));
                            return;
                        }
                    }
                }
            }
            final Element blinnPhongLambert = technique.getChild(type);
            if (mInfo != null) {
                mInfo.setTechnique(type);
            }
            final MaterialState mState = new MaterialState();

            // TODO: implement proper transparency handling
            Texture diffuseTexture = null;
            ColorRGBA transparent = new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f);
            float transparency = 1.0f;
            boolean useTransparency = false;
            String opaqueMode = "A_ONE";

            /*
             * place holder for current property, we import material properties in fixed order (for texture order)
             */
            Element property = null;
            /* Diffuse property */
            property = blinnPhongLambert.getChild("diffuse");
            if (property != null) {
                final Element propertyValue = property.getChildren().get(0);
                if ("color".equals(propertyValue.getName())) {
                    final ColorRGBA color = _colladaDOMUtil.getColor(propertyValue.getText());
                    mState.setDiffuse(MaterialFace.FrontAndBack, color);
                } else if ("texture".equals(propertyValue.getName()) && _loadTextures) {
                    diffuseTexture = populateTextureState(mesh, propertyValue, effect, loadedTextures, mInfo,
                            "diffuse");
                }
            }
            /* Ambient property */
            property = blinnPhongLambert.getChild("ambient");
            if (property != null) {
                final Element propertyValue = property.getChildren().get(0);
                if ("color".equals(propertyValue.getName())) {
                    final ColorRGBA color = _colladaDOMUtil.getColor(propertyValue.getText());
                    mState.setAmbient(MaterialFace.FrontAndBack, color);
                } else if ("texture".equals(propertyValue.getName()) && _loadTextures) {
                    populateTextureState(mesh, propertyValue, effect, loadedTextures, mInfo, "ambient");
                }
            }
            /* Transparent property */
            property = blinnPhongLambert.getChild("transparent");
            if (property != null) {
                final Element propertyValue = property.getChildren().get(0);
                if ("color".equals(propertyValue.getName())) {
                    transparent = _colladaDOMUtil.getColor(propertyValue.getText());
                    // TODO: use this
                    useTransparency = true;
                } else if ("texture".equals(propertyValue.getName()) && _loadTextures) {
                    populateTextureState(mesh, propertyValue, effect, loadedTextures, mInfo, "transparent");
                }
                opaqueMode = property.getAttributeValue("opaque", "A_ONE");
            }
            /* Transparency property */
            property = blinnPhongLambert.getChild("transparency");
            if (property != null) {
                final Element propertyValue = property.getChildren().get(0);
                if ("float".equals(propertyValue.getName())) {
                    transparency = Float.parseFloat(propertyValue.getText().replace(",", "."));
                    // TODO: use this
                    if (_flipTransparency) {
                        transparency = 1f - transparency;
                    }
                    useTransparency = true;
                } else if ("texture".equals(propertyValue.getName()) && _loadTextures) {
                    populateTextureState(mesh, propertyValue, effect, loadedTextures, mInfo, "transparency");
                }
            }
            /* Emission property */
            property = blinnPhongLambert.getChild("emission");
            if (property != null) {
                final Element propertyValue = property.getChildren().get(0);
                if ("color".equals(propertyValue.getName())) {
                    mState.setEmissive(MaterialFace.FrontAndBack,
                            _colladaDOMUtil.getColor(propertyValue.getText()));
                } else if ("texture".equals(propertyValue.getName()) && _loadTextures) {
                    populateTextureState(mesh, propertyValue, effect, loadedTextures, mInfo, "emissive");
                }
            }
            /* Specular property */
            property = blinnPhongLambert.getChild("specular");
            if (property != null) {
                final Element propertyValue = property.getChildren().get(0);
                if ("color".equals(propertyValue.getName())) {
                    mState.setSpecular(MaterialFace.FrontAndBack,
                            _colladaDOMUtil.getColor(propertyValue.getText()));
                } else if ("texture".equals(propertyValue.getName()) && _loadTextures) {
                    populateTextureState(mesh, propertyValue, effect, loadedTextures, mInfo, "specular");
                }
            }
            /* Shininess property */
            property = blinnPhongLambert.getChild("shininess");
            if (property != null) {
                final Element propertyValue = property.getChildren().get(0);
                if ("float".equals(propertyValue.getName())) {
                    float shininess = Float.parseFloat(propertyValue.getText().replace(",", "."));
                    if (shininess >= 0.0f && shininess <= 1.0f) {
                        final float oldShininess = shininess;
                        shininess *= 128;
                        logger.finest("Shininess - " + oldShininess
                                + " - was in the [0,1] range. Scaling to [0, 128] - " + shininess);
                    } else if (shininess < 0 || shininess > 128) {
                        final float oldShininess = shininess;
                        shininess = MathUtils.clamp(shininess, 0, 128);
                        logger.warning("Shininess must be between 0 and 128. Shininess " + oldShininess
                                + " was clamped to " + shininess);
                    }
                    mState.setShininess(MaterialFace.FrontAndBack, shininess);
                } else if ("texture".equals(propertyValue.getName()) && _loadTextures) {
                    populateTextureState(mesh, propertyValue, effect, loadedTextures, mInfo, "shininess");
                }
            }
            /* Reflectivity property */
            float reflectivity = 1.0f;
            property = blinnPhongLambert.getChild("reflectivity");
            if (property != null) {
                final Element propertyValue = property.getChildren().get(0);
                if ("float".equals(propertyValue.getName())) {
                    reflectivity = Float.parseFloat(propertyValue.getText().replace(",", "."));
                }
            }
            /* Reflective property. Texture only */
            property = blinnPhongLambert.getChild("reflective");
            if (property != null) {
                final Element propertyValue = property.getChildren().get(0);
                if ("texture".equals(propertyValue.getName()) && _loadTextures) {
                    final Texture reflectiveTexture = populateTextureState(mesh, propertyValue, effect,
                            loadedTextures, mInfo, "reflective");

                    reflectiveTexture.setEnvironmentalMapMode(Texture.EnvironmentalMapMode.SphereMap);
                    reflectiveTexture.setApply(ApplyMode.Combine);

                    reflectiveTexture.setCombineFuncRGB(CombinerFunctionRGB.Interpolate);
                    // color 1
                    reflectiveTexture.setCombineSrc0RGB(CombinerSource.CurrentTexture);
                    reflectiveTexture.setCombineOp0RGB(CombinerOperandRGB.SourceColor);
                    // color 2
                    reflectiveTexture.setCombineSrc1RGB(CombinerSource.Previous);
                    reflectiveTexture.setCombineOp1RGB(CombinerOperandRGB.SourceColor);
                    // interpolate param will come from alpha of constant color
                    reflectiveTexture.setCombineSrc2RGB(CombinerSource.Constant);
                    reflectiveTexture.setCombineOp2RGB(CombinerOperandRGB.SourceAlpha);

                    reflectiveTexture.setConstantColor(new ColorRGBA(1, 1, 1, reflectivity));
                }
            }

            /*
             * An extra tag defines some materials not part of the collada standard. Since we're not able to parse
             * we simply extract the textures from the element (such that shaders etc can at least pick up on them)
             */
            property = technique.getChild("extra");
            if (property != null) {
                // process with any plugins
                if (!_importer.readExtra(property, mesh)) {
                    // no plugin processed our mesh, so process ourselves.
                    getTexturesFromElement(mesh, property, effect, loadedTextures, mInfo);
                }
            }

            // XXX: There are some issues with clarity on how to use alpha blending in OpenGL FFP.
            // The best interpretation I have seen is that if transparent has a texture == diffuse,
            // Turn on alpha blending and use diffuse alpha.

            // check to make sure we actually need this.
            // testing separately for a transparency of 0.0 is to hack around erroneous exports, since usually
            // there is no use in exporting something with 100% transparency.
            if ("A_ONE".equals(opaqueMode) && ColorRGBA.WHITE.equals(transparent) && transparency == 1.0
                    || transparency == 0.0) {
                useTransparency = false;
            }

            if (useTransparency) {
                if (diffuseTexture != null) {
                    final BlendState blend = new BlendState();
                    blend.setBlendEnabled(true);
                    blend.setTestEnabled(true);
                    blend.setSourceFunction(BlendState.SourceFunction.SourceAlpha);
                    blend.setDestinationFunction(BlendState.DestinationFunction.OneMinusSourceAlpha);
                    mesh.setRenderState(blend);
                } else {
                    final BlendState blend = new BlendState();
                    blend.setBlendEnabled(true);
                    blend.setTestEnabled(true);
                    transparent.setAlpha(transparent.getAlpha() * transparency);
                    blend.setConstantColor(transparent);
                    blend.setSourceFunction(BlendState.SourceFunction.ConstantAlpha);
                    blend.setDestinationFunction(BlendState.DestinationFunction.OneMinusConstantAlpha);
                    mesh.setRenderState(blend);
                }

                mesh.getSceneHints().setRenderBucketType(RenderBucketType.Transparent);
            }

            if (mInfo != null) {
                if (useTransparency) {
                    mInfo.setUseTransparency(useTransparency);
                    if (diffuseTexture == null) {
                        mInfo.setTransparency(transparent.getAlpha() * transparency);
                    }
                }
                mInfo.setMaterialState(mState);
            }
            mesh.setRenderState(mState);
        }
    } else {
        ColladaMaterialUtils.logger.warning(
                "material effect not found: " + mat.getChild("instance_material").getAttributeValue("url"));
    }
}

From source file:com.ardor3d.extension.model.collada.jdom.ColladaMaterialUtils.java

License:Open Source License

/**
 * Function to searches an xml node for <texture> elements and adds them to the texture state of the mesh.
 * /*from w w w . j  a  va 2s.co m*/
 * @param mesh
 *            the Ardor3D Mesh to add the Texture to.
 * @param element
 *            the xml element to start the search on
 * @param effect
 *            our <instance_effect> element
 * @param info
 */
private void getTexturesFromElement(final Mesh mesh, final Element element, final Element effect,
        final HashMap<String, Texture> loadedTextures, final MaterialInfo info) {
    if ("texture".equals(element.getName()) && _loadTextures) {
        populateTextureState(mesh, element, effect, loadedTextures, info, null);
    }
    @SuppressWarnings("unchecked")
    final List<Element> children = element.getChildren();
    if (children != null) {
        for (final Element child : children) {
            /* recurse on children */
            getTexturesFromElement(mesh, child, effect, loadedTextures, info);
        }
    }
}