diff options
Diffstat (limited to 'ardor3d-collada/src/main/java/com')
12 files changed, 267 insertions, 270 deletions
diff --git a/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaAnimUtils.java b/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaAnimUtils.java index da9773f..d20278c 100644 --- a/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaAnimUtils.java +++ b/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaAnimUtils.java @@ -25,9 +25,9 @@ import java.util.StringTokenizer; import java.util.logging.Level; import java.util.logging.Logger; -import org.jdom.Attribute; -import org.jdom.DataConversionException; -import org.jdom.Element; +import org.jdom2.Attribute; +import org.jdom2.DataConversionException; +import org.jdom2.Element; import com.ardor3d.extension.animation.skeletal.AttachmentPoint; import com.ardor3d.extension.animation.skeletal.Joint; @@ -198,7 +198,7 @@ public class ColladaAnimUtils { if (meshNode != null) { // Look for skeleton entries in the original <instance_controller> element final List<Element> skeletonRoots = Lists.newArrayList(); - for (final Element sk : (List<Element>) instanceController.getChildren("skeleton")) { + for (final Element sk : instanceController.getChildren("skeleton")) { final Element skroot = _colladaDOMUtil.findTargetWithId(sk.getText()); if (skroot != null) { // add as a possible root for when we need to locate a joint by name later. @@ -220,7 +220,7 @@ public class ColladaAnimUtils { final List<Transform> bindMatrices = Lists.newArrayList(); final List<ColladaInputPipe.ParamType> paramTypes = Lists.newArrayList(); - for (final Element inputEL : (List<Element>) jointsEL.getChildren("input")) { + for (final Element inputEL : jointsEL.getChildren("input")) { final ColladaInputPipe pipe = new ColladaInputPipe(_colladaDOMUtil, inputEL); final ColladaInputPipe.SourceData sd = pipe.getSourceData(); if (pipe.getType() == ColladaInputPipe.Type.JOINT) { @@ -330,7 +330,7 @@ public class ColladaAnimUtils { int indOff = 0, weightOff = 0; int maxOffset = 0; - for (final Element inputEL : (List<Element>) weightsEL.getChildren("input")) { + for (final Element inputEL : weightsEL.getChildren("input")) { final ColladaInputPipe pipe = new ColladaInputPipe(_colladaDOMUtil, inputEL); final ColladaInputPipe.SourceData sd = pipe.getSourceData(); if (pipe.getOffset() > maxOffset) { @@ -650,7 +650,7 @@ public class ColladaAnimUtils { private void buildAnimations(final Element parentElement, final Collection<TargetChannel> targetList) { final List<Element> elementTransforms = new ArrayList<Element>(); - for (final Element child : (List<Element>) parentElement.getChildren()) { + for (final Element child : parentElement.getChildren()) { if (_dataCache.getTransformTypes().contains(child.getName())) { elementTransforms.add(child); } @@ -675,7 +675,7 @@ public class ColladaAnimUtils { final EnumMap<Type, ColladaInputPipe> pipes = Maps.newEnumMap(Type.class); final Element samplerElement = _colladaDOMUtil.findTargetWithId(source); - for (final Element inputElement : (List<Element>) samplerElement.getChildren("input")) { + for (final Element inputElement : samplerElement.getChildren("input")) { final ColladaInputPipe pipe = new ColladaInputPipe(_colladaDOMUtil, inputElement); pipes.put(pipe.getType(), pipe); } @@ -849,7 +849,7 @@ public class ColladaAnimUtils { final AnimationItem animationItem = new AnimationItem(name); animationItemRoot.getChildren().add(animationItem); - for (final Element animationElement : (List<Element>) animationRoot.getChildren("animation")) { + for (final Element animationElement : animationRoot.getChildren("animation")) { parseAnimations(channelMap, animationElement, animationItem); } } diff --git a/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaDOMUtil.java b/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaDOMUtil.java index 73287c6..956af66 100644 --- a/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaDOMUtil.java +++ b/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaDOMUtil.java @@ -18,15 +18,15 @@ import java.util.StringTokenizer; import java.util.logging.Level; import java.util.logging.Logger; -import org.jdom.Attribute; -import org.jdom.CDATA; -import org.jdom.Comment; -import org.jdom.DataConversionException; -import org.jdom.Element; -import org.jdom.JDOMException; -import org.jdom.ProcessingInstruction; -import org.jdom.Text; -import org.jdom.xpath.XPath; +import org.jdom2.Attribute; +import org.jdom2.CDATA; +import org.jdom2.Comment; +import org.jdom2.DataConversionException; +import org.jdom2.Element; +import org.jdom2.JDOMException; +import org.jdom2.ProcessingInstruction; +import org.jdom2.Text; +import org.jdom2.xpath.XPath; import com.ardor3d.extension.model.collada.jdom.data.DataCache; import com.ardor3d.math.ColorRGBA; @@ -361,7 +361,7 @@ public class ColladaDOMUtil { */ @SuppressWarnings("unchecked") public Element getPositionSource(final Element v) { - for (final Element input : (List<Element>) v.getChildren("input")) { + for (final Element input : v.getChildren("input")) { if ("POSITION".equals(input.getAttributeValue("semantic"))) { final Element n = findTargetWithId(input.getAttributeValue("source")); if (n != null && "source".equals(n.getName())) { diff --git a/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaException.java b/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaException.java index b4d4927..edadb0b 100644 --- a/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaException.java +++ b/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaException.java @@ -1,31 +1,31 @@ -/**
- * Copyright (c) 2008-2012 Ardor Labs, Inc.
- *
- * This file is part of Ardor3D.
- *
- * Ardor3D is free software: you can redistribute it and/or modify it
- * under the terms of its license which may be found in the accompanying
- * LICENSE file or at <http://www.ardor3d.com/LICENSE>.
- */
-
-package com.ardor3d.extension.model.collada.jdom;
-
-/**
- * Customer exception thrown when something unexpected is encountered in a Collada file.
- */
-public class ColladaException extends RuntimeException {
-
- private static final long serialVersionUID = 1L;
-
- public ColladaException(final String message, final Object source) {
- super(ColladaException.createMessage(message, source));
- }
-
- public ColladaException(final String msg, final Object source, final Throwable cause) {
- super(ColladaException.createMessage(msg, source), cause);
- }
-
- private static String createMessage(final String message, final Object source) {
- return "Collada problem for source: " + (source != null ? source.toString() : "null") + ": " + message;
- }
-}
+/** + * Copyright (c) 2008-2012 Ardor Labs, Inc. + * + * This file is part of Ardor3D. + * + * Ardor3D is free software: you can redistribute it and/or modify it + * under the terms of its license which may be found in the accompanying + * LICENSE file or at <http://www.ardor3d.com/LICENSE>. + */ + +package com.ardor3d.extension.model.collada.jdom; + +/** + * Customer exception thrown when something unexpected is encountered in a Collada file. + */ +public class ColladaException extends RuntimeException { + + private static final long serialVersionUID = 1L; + + public ColladaException(final String message, final Object source) { + super(ColladaException.createMessage(message, source)); + } + + public ColladaException(final String msg, final Object source, final Throwable cause) { + super(ColladaException.createMessage(msg, source), cause); + } + + private static String createMessage(final String message, final Object source) { + return "Collada problem for source: " + (source != null ? source.toString() : "null") + ": " + message; + } +} diff --git a/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaImporter.java b/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaImporter.java index 0298984..c813e5d 100644 --- a/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaImporter.java +++ b/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaImporter.java @@ -22,15 +22,17 @@ import java.util.Set; import java.util.StringTokenizer; import java.util.logging.Logger; -import org.jdom.Attribute; -import org.jdom.DataConversionException; -import org.jdom.DefaultJDOMFactory; -import org.jdom.Document; -import org.jdom.Element; -import org.jdom.Namespace; -import org.jdom.Text; -import org.jdom.input.SAXBuilder; -import org.jdom.input.SAXHandler; +import org.jdom2.Attribute; +import org.jdom2.DataConversionException; +import org.jdom2.DefaultJDOMFactory; +import org.jdom2.Document; +import org.jdom2.Element; +import org.jdom2.JDOMFactory; +import org.jdom2.Namespace; +import org.jdom2.Text; +import org.jdom2.input.SAXBuilder; +import org.jdom2.input.sax.SAXHandler; +import org.jdom2.input.sax.SAXHandlerFactory; import org.xml.sax.SAXException; import com.ardor3d.extension.animation.skeletal.Joint; @@ -289,18 +291,18 @@ public class ColladaImporter { */ private Element readCollada(final ResourceSource resource, final DataCache dataCache) { try { - final SAXBuilder builder = new SAXBuilder() { + final JDOMFactory jdomFac = new ArdorFactory(dataCache); + final SAXBuilder builder = new SAXBuilder(null, new SAXHandlerFactory() { @Override - protected SAXHandler createContentHandler() { - return new SAXHandler(new ArdorFactory(dataCache)) { + public SAXHandler createSAXHandler(final JDOMFactory factory) { + return new SAXHandler(jdomFac) { @Override public void startPrefixMapping(final String prefix, final String uri) throws SAXException { // Just kill what's usually done here... } - }; } - }; + }, jdomFac); final Document doc = builder.build(resource.openStream()); final Element collada = doc.getRootElement(); @@ -335,7 +337,7 @@ public class ColladaImporter { } @Override - public Text text(final String text) { + public Text text(final int line, final int col, final String text) { try { switch (bufferType) { case Float: { @@ -435,29 +437,29 @@ public class ColladaImporter { } @Override - public Element element(final String name, final Namespace namespace) { - currentElement = super.element(name); + public Element element(final int line, final int col, final String name, final Namespace namespace) { + currentElement = super.element(line, col, name); handleTypes(name); return currentElement; } @Override - public Element element(final String name, final String prefix, final String uri) { - currentElement = super.element(name); + public Element element(final int line, final int col, final String name, final String prefix, final String uri) { + currentElement = super.element(line, col, name); handleTypes(name); return currentElement; } @Override - public Element element(final String name, final String uri) { - currentElement = super.element(name); + public Element element(final int line, final int col, final String name, final String uri) { + currentElement = super.element(line, col, name); handleTypes(name); return currentElement; } @Override - public Element element(final String name) { - currentElement = super.element(name); + public Element element(final int line, final int col, final String name) { + currentElement = super.element(line, col, name); handleTypes(name); return currentElement; } diff --git a/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaInputPipe.java b/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaInputPipe.java index 75704ec..d883756 100644 --- a/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaInputPipe.java +++ b/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaInputPipe.java @@ -16,7 +16,7 @@ import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; -import org.jdom.Element; +import org.jdom2.Element; import com.ardor3d.extension.model.collada.jdom.data.DataCache; import com.ardor3d.scenegraph.FloatBufferData; diff --git a/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaMaterialUtils.java b/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaMaterialUtils.java index 34626bb..e4572ff 100644 --- a/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaMaterialUtils.java +++ b/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaMaterialUtils.java @@ -14,7 +14,7 @@ import java.util.HashMap; import java.util.List; import java.util.logging.Logger; -import org.jdom.Element; +import org.jdom2.Element; import com.ardor3d.extension.model.collada.jdom.data.DataCache; import com.ardor3d.extension.model.collada.jdom.data.MaterialInfo; @@ -154,7 +154,7 @@ public class ColladaMaterialUtils { /* Diffuse property */ property = blinnPhongLambert.getChild("diffuse"); if (property != null) { - final Element propertyValue = (Element) property.getChildren().get(0); + final Element propertyValue = property.getChildren().get(0); if ("color".equals(propertyValue.getName())) { final ColorRGBA color = _colladaDOMUtil.getColor(propertyValue.getText()); mState.setDiffuse(MaterialFace.FrontAndBack, color); @@ -166,7 +166,7 @@ public class ColladaMaterialUtils { /* Ambient property */ property = blinnPhongLambert.getChild("ambient"); if (property != null) { - final Element propertyValue = (Element) property.getChildren().get(0); + final Element propertyValue = property.getChildren().get(0); if ("color".equals(propertyValue.getName())) { final ColorRGBA color = _colladaDOMUtil.getColor(propertyValue.getText()); mState.setAmbient(MaterialFace.FrontAndBack, color); @@ -177,7 +177,7 @@ public class ColladaMaterialUtils { /* Transparent property */ property = blinnPhongLambert.getChild("transparent"); if (property != null) { - final Element propertyValue = (Element) property.getChildren().get(0); + final Element propertyValue = property.getChildren().get(0); if ("color".equals(propertyValue.getName())) { transparent = _colladaDOMUtil.getColor(propertyValue.getText()); // TODO: use this @@ -190,7 +190,7 @@ public class ColladaMaterialUtils { /* Transparency property */ property = blinnPhongLambert.getChild("transparency"); if (property != null) { - final Element propertyValue = (Element) property.getChildren().get(0); + final Element propertyValue = property.getChildren().get(0); if ("float".equals(propertyValue.getName())) { transparency = Float.parseFloat(propertyValue.getText().replace(",", ".")); // TODO: use this @@ -205,7 +205,7 @@ public class ColladaMaterialUtils { /* Emission property */ property = blinnPhongLambert.getChild("emission"); if (property != null) { - final Element propertyValue = (Element) property.getChildren().get(0); + 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) { @@ -215,7 +215,7 @@ public class ColladaMaterialUtils { /* Specular property */ property = blinnPhongLambert.getChild("specular"); if (property != null) { - final Element propertyValue = (Element) property.getChildren().get(0); + 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) { @@ -225,7 +225,7 @@ public class ColladaMaterialUtils { /* Shininess property */ property = blinnPhongLambert.getChild("shininess"); if (property != null) { - final Element propertyValue = (Element) property.getChildren().get(0); + 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) { @@ -248,7 +248,7 @@ public class ColladaMaterialUtils { float reflectivity = 1.0f; property = blinnPhongLambert.getChild("reflectivity"); if (property != null) { - final Element propertyValue = (Element) property.getChildren().get(0); + final Element propertyValue = property.getChildren().get(0); if ("float".equals(propertyValue.getName())) { reflectivity = Float.parseFloat(propertyValue.getText().replace(",", ".")); } @@ -256,7 +256,7 @@ public class ColladaMaterialUtils { /* Reflective property. Texture only */ property = blinnPhongLambert.getChild("reflective"); if (property != null) { - final Element propertyValue = (Element) property.getChildren().get(0); + final Element propertyValue = property.getChildren().get(0); if ("texture".equals(propertyValue.getName()) && _loadTextures) { final Texture reflectiveTexture = populateTextureState(mesh, propertyValue, effect, loadedTextures, mInfo, "reflective"); @@ -414,7 +414,7 @@ public class ColladaMaterialUtils { } if ("newparam".equals(node.getName())) { - node = (Element) node.getChildren().get(0); + node = node.getChildren().get(0); } Element sampler = null; @@ -434,7 +434,7 @@ public class ColladaMaterialUtils { } if ("newparam".equals(node.getName())) { - node = (Element) node.getChildren().get(0); + node = node.getChildren().get(0); } if ("surface".equals(node.getName())) { @@ -457,7 +457,7 @@ public class ColladaMaterialUtils { // look for an init_from with lowest mip and use that. (usually 0) // TODO: mip? - final Element lowest = (Element) surface.getChildren("init_from").get(0); + final Element lowest = surface.getChildren("init_from").get(0); // Element lowest = null; // for (final Element i : (List<Element>) surface.getChildren("init_from")) { // if (lowest == null || lowest.getMip() > i.getMip()) { @@ -541,8 +541,7 @@ public class ColladaMaterialUtils { return; } - for (final Element instance : (List<Element>) bindMaterial.getChild("technique_common").getChildren( - "instance_material")) { + for (final Element instance : bindMaterial.getChild("technique_common").getChildren("instance_material")) { final Element matNode = _colladaDOMUtil.findTargetWithId(instance.getAttributeValue("target")); if (matNode != null && "material".equals(matNode.getName())) { _dataCache.bindMaterial(instance.getAttributeValue("symbol"), matNode); @@ -559,8 +558,7 @@ public class ColladaMaterialUtils { if (bindMaterial == null || bindMaterial.getChildren().isEmpty()) { return; } - for (final Element instance : (List<Element>) bindMaterial.getChild("technique_common").getChildren( - "instance_material")) { + for (final Element instance : bindMaterial.getChild("technique_common").getChildren("instance_material")) { _dataCache.unbindMaterial(instance.getAttributeValue("symbol")); } } diff --git a/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaMeshUtils.java b/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaMeshUtils.java index bbff59e..c04e854 100644 --- a/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaMeshUtils.java +++ b/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaMeshUtils.java @@ -13,10 +13,9 @@ package com.ardor3d.extension.model.collada.jdom; import java.nio.FloatBuffer; import java.util.EnumSet; import java.util.LinkedList; -import java.util.List; import java.util.logging.Logger; -import org.jdom.Element; +import org.jdom2.Element; import com.ardor3d.extension.model.collada.jdom.ColladaInputPipe.Type; import com.ardor3d.extension.model.collada.jdom.data.DataCache; @@ -88,7 +87,7 @@ public class ColladaMeshUtils { // Create each as an Ardor3D Mesh, and attach to node boolean hasChild = false; if (cMesh.getChild("polygons") != null) { - for (final Element p : (List<Element>) cMesh.getChildren("polygons")) { + for (final Element p : cMesh.getChildren("polygons")) { final Mesh child = buildMeshPolygons(colladaGeometry, p); if (child != null) { if (child.getName() == null) { @@ -100,7 +99,7 @@ public class ColladaMeshUtils { } } if (cMesh.getChild("polylist") != null) { - for (final Element p : (List<Element>) cMesh.getChildren("polylist")) { + for (final Element p : cMesh.getChildren("polylist")) { final Mesh child = buildMeshPolylist(colladaGeometry, p); if (child != null) { if (child.getName() == null) { @@ -112,7 +111,7 @@ public class ColladaMeshUtils { } } if (cMesh.getChild("triangles") != null) { - for (final Element t : (List<Element>) cMesh.getChildren("triangles")) { + for (final Element t : cMesh.getChildren("triangles")) { final Mesh child = buildMeshTriangles(colladaGeometry, t); if (child != null) { if (child.getName() == null) { @@ -124,7 +123,7 @@ public class ColladaMeshUtils { } } if (cMesh.getChild("lines") != null) { - for (final Element l : (List<Element>) cMesh.getChildren("lines")) { + for (final Element l : cMesh.getChildren("lines")) { final Line child = buildMeshLines(colladaGeometry, l); if (child != null) { if (child.getName() == null) { @@ -243,7 +242,7 @@ public class ColladaMeshUtils { // use interval & sum of sizes of p entries to determine buffer sizes. int numEntries = 0; int numIndices = 0; - for (final Element vals : (List<Element>) polys.getChildren("p")) { + for (final Element vals : polys.getChildren("p")) { final int length = _colladaDOMUtil.parseIntArray(vals).length; numEntries += length; numIndices += (length / interval - 2) * 3; @@ -268,7 +267,7 @@ public class ColladaMeshUtils { // go through the polygon entries int firstIndex = 0, vecIndex; final int[] currentVal = new int[interval]; - for (final Element dia : (List<Element>) polys.getChildren("p")) { + for (final Element dia : polys.getChildren("p")) { // for each p, iterate using max offset final int[] vals = _colladaDOMUtil.parseIntArray(dia); @@ -528,13 +527,13 @@ public class ColladaMeshUtils { private int extractPipes(final Element inputsParent, final LinkedList<ColladaInputPipe> pipesStore) { int maxOffset = 0; int texCount = 0; - for (final Element input : (List<Element>) inputsParent.getChildren("input")) { + for (final Element input : inputsParent.getChildren("input")) { maxOffset = Math.max(maxOffset, _colladaDOMUtil.getAttributeIntValue(input, "offset", 0)); try { final Type type = Type.valueOf(input.getAttributeValue("semantic")); if (type == Type.VERTEX) { final Element vertexElement = _colladaDOMUtil.findTargetWithId(input.getAttributeValue("source")); - for (final Element vertexInput : (List<Element>) vertexElement.getChildren("input")) { + for (final Element vertexInput : vertexElement.getChildren("input")) { vertexInput.setAttribute("offset", input.getAttributeValue("offset")); vertexInput.setAttribute("isVertexDefined", "true"); final ColladaInputPipe pipe = new ColladaInputPipe(_colladaDOMUtil, vertexInput); diff --git a/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaNodeUtils.java b/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaNodeUtils.java index eb5ae6f..165ad89 100644 --- a/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaNodeUtils.java +++ b/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/ColladaNodeUtils.java @@ -15,7 +15,7 @@ import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; -import org.jdom.Element; +import org.jdom2.Element; import com.ardor3d.extension.animation.skeletal.AttachmentPoint; import com.ardor3d.extension.animation.skeletal.Joint; @@ -87,7 +87,7 @@ public class ColladaNodeUtils { // Load each sub node and attach final JointNode baseJointNode = new JointNode(null); _dataCache.setRootJointNode(baseJointNode); - for (final Element n : (List<Element>) visualScene.getChildren("node")) { + for (final Element n : visualScene.getChildren("node")) { final Node subNode = buildNode(n, baseJointNode); if (subNode != null) { sceneRoot.attachChild(subNode); @@ -163,7 +163,7 @@ public class ColladaNodeUtils { public AssetData parseAsset(final Element asset) { final AssetData assetData = new AssetData(); - for (final Element child : (List<Element>) asset.getChildren()) { + for (final Element child : asset.getChildren()) { if ("contributor".equals(child.getName())) { parseContributor(assetData, child); } else if ("created".equals(child.getName())) { @@ -204,7 +204,7 @@ public class ColladaNodeUtils { @SuppressWarnings("unchecked") private void parseContributor(final AssetData assetData, final Element contributor) { - for (final Element child : (List<Element>) contributor.getChildren()) { + for (final Element child : contributor.getChildren()) { if ("author".equals(child.getName())) { assetData.setAuthor(child.getText()); } else if ("authoringTool".equals(child.getName())) { @@ -270,7 +270,7 @@ public class ColladaNodeUtils { final Node node = new Node(nodeName); final List<Element> transforms = new ArrayList<Element>(); - for (final Element child : (List<Element>) dNode.getChildren()) { + for (final Element child : dNode.getChildren()) { if (_dataCache.getTransformTypes().contains(child.getName())) { transforms.add(child); } @@ -287,7 +287,7 @@ public class ColladaNodeUtils { } // process any instance geometries - for (final Element instance_geometry : (List<Element>) dNode.getChildren("instance_geometry")) { + for (final Element instance_geometry : dNode.getChildren("instance_geometry")) { _colladaMaterialUtils.bindMaterials(instance_geometry.getChild("bind_material")); final Spatial mesh = _colladaMeshUtils.getGeometryMesh(instance_geometry); @@ -299,12 +299,12 @@ public class ColladaNodeUtils { } // process any instance controllers - for (final Element instanceController : (List<Element>) dNode.getChildren("instance_controller")) { + for (final Element instanceController : dNode.getChildren("instance_controller")) { _dataCache.getControllers().add(new ControllerStore(node, instanceController)); } // process any instance nodes - for (final Element in : (List<Element>) dNode.getChildren("instance_node")) { + for (final Element in : dNode.getChildren("instance_node")) { final Node subNode = getNode(in, jointNode); if (subNode != null) { node.attachChild(subNode); @@ -317,7 +317,7 @@ public class ColladaNodeUtils { } // process any concrete child nodes. - for (final Element n : (List<Element>) dNode.getChildren("node")) { + for (final Element n : dNode.getChildren("node")) { final Node subNode = buildNode(n, jointNode); if (subNode != null) { node.attachChild(subNode); diff --git a/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/data/AnimationItem.java b/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/data/AnimationItem.java index 43c732b..400384c 100644 --- a/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/data/AnimationItem.java +++ b/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/data/AnimationItem.java @@ -1,94 +1,94 @@ -/**
- * Copyright (c) 2008-2012 Ardor Labs, Inc.
- *
- * This file is part of Ardor3D.
- *
- * Ardor3D is free software: you can redistribute it and/or modify it
- * under the terms of its license which may be found in the accompanying
- * LICENSE file or at <http://www.ardor3d.com/LICENSE>.
- */
-
-package com.ardor3d.extension.model.collada.jdom.data;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.List;
-
-import com.ardor3d.annotation.SavableFactory;
-import com.ardor3d.extension.animation.skeletal.clip.AnimationClip;
-import com.ardor3d.util.export.InputCapsule;
-import com.ardor3d.util.export.OutputCapsule;
-import com.ardor3d.util.export.Savable;
-import com.google.common.collect.Lists;
-
-@SavableFactory(factoryMethod = "initSavable")
-public class AnimationItem implements Savable {
- private final String _name;
- private final List<AnimationItem> _children = Lists.newArrayList();
- private AnimationClip _animationClip;
-
- public AnimationItem(final String name) {
- _name = name;
- }
-
- public AnimationClip getAnimationClip() {
- return _animationClip;
- }
-
- public void setAnimationClip(final AnimationClip animationClip) {
- _animationClip = animationClip;
- }
-
- public String getName() {
- return _name;
- }
-
- public List<AnimationItem> getChildren() {
- return _children;
- }
-
- @Override
- public String toString() {
- return "AnimationItem [name=" + _name + (_animationClip != null ? ", " + _animationClip.toString() : "") + "]";
- }
-
- // /////////////////
- // Methods for Savable
- // /////////////////
-
- @Override
- public Class<? extends AnimationItem> getClassTag() {
- return this.getClass();
- }
-
- @Override
- public void read(final InputCapsule capsule) throws IOException {
- final String name = capsule.readString("name", "");
- try {
- final Field field1 = AnimationClip.class.getDeclaredField("_name");
- field1.setAccessible(true);
- field1.set(this, name);
- } catch (final Exception e) {
- e.printStackTrace();
- }
- _children.clear();
- _children.addAll(capsule.readSavableList("children", new ArrayList<AnimationItem>()));
- _animationClip = (AnimationClip) capsule.readSavable("animationClip", null);
- }
-
- @Override
- public void write(final OutputCapsule capsule) throws IOException {
- capsule.write(_name, "name", null);
- capsule.writeSavableList(_children, "children", null);
- capsule.write(_animationClip, "animationClip", null);
- }
-
- public static AnimationItem initSavable() {
- return new AnimationItem();
- }
-
- private AnimationItem() {
- this(null);
- }
-}
+/** + * Copyright (c) 2008-2012 Ardor Labs, Inc. + * + * This file is part of Ardor3D. + * + * Ardor3D is free software: you can redistribute it and/or modify it + * under the terms of its license which may be found in the accompanying + * LICENSE file or at <http://www.ardor3d.com/LICENSE>. + */ + +package com.ardor3d.extension.model.collada.jdom.data; + +import java.io.IOException; +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.List; + +import com.ardor3d.annotation.SavableFactory; +import com.ardor3d.extension.animation.skeletal.clip.AnimationClip; +import com.ardor3d.util.export.InputCapsule; +import com.ardor3d.util.export.OutputCapsule; +import com.ardor3d.util.export.Savable; +import com.google.common.collect.Lists; + +@SavableFactory(factoryMethod = "initSavable") +public class AnimationItem implements Savable { + private final String _name; + private final List<AnimationItem> _children = Lists.newArrayList(); + private AnimationClip _animationClip; + + public AnimationItem(final String name) { + _name = name; + } + + public AnimationClip getAnimationClip() { + return _animationClip; + } + + public void setAnimationClip(final AnimationClip animationClip) { + _animationClip = animationClip; + } + + public String getName() { + return _name; + } + + public List<AnimationItem> getChildren() { + return _children; + } + + @Override + public String toString() { + return "AnimationItem [name=" + _name + (_animationClip != null ? ", " + _animationClip.toString() : "") + "]"; + } + + // ///////////////// + // Methods for Savable + // ///////////////// + + @Override + public Class<? extends AnimationItem> getClassTag() { + return this.getClass(); + } + + @Override + public void read(final InputCapsule capsule) throws IOException { + final String name = capsule.readString("name", ""); + try { + final Field field1 = AnimationClip.class.getDeclaredField("_name"); + field1.setAccessible(true); + field1.set(this, name); + } catch (final Exception e) { + e.printStackTrace(); + } + _children.clear(); + _children.addAll(capsule.readSavableList("children", new ArrayList<AnimationItem>())); + _animationClip = (AnimationClip) capsule.readSavable("animationClip", null); + } + + @Override + public void write(final OutputCapsule capsule) throws IOException { + capsule.write(_name, "name", null); + capsule.writeSavableList(_children, "children", null); + capsule.write(_animationClip, "animationClip", null); + } + + public static AnimationItem initSavable() { + return new AnimationItem(); + } + + private AnimationItem() { + this(null); + } +} diff --git a/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/data/ControllerStore.java b/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/data/ControllerStore.java index 9da548b..b827add 100644 --- a/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/data/ControllerStore.java +++ b/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/data/ControllerStore.java @@ -1,7 +1,7 @@ package com.ardor3d.extension.model.collada.jdom.data; -import org.jdom.Element; +import org.jdom2.Element; import com.ardor3d.scenegraph.Node; diff --git a/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/plugin/ColladaExtraPlugin.java b/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/plugin/ColladaExtraPlugin.java index f9b4bd3..d766f38 100644 --- a/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/plugin/ColladaExtraPlugin.java +++ b/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/plugin/ColladaExtraPlugin.java @@ -1,19 +1,19 @@ -/**
- * Copyright (c) 2008-2012 Ardor Labs, Inc.
- *
- * This file is part of Ardor3D.
- *
- * Ardor3D is free software: you can redistribute it and/or modify it
- * under the terms of its license which may be found in the accompanying
- * LICENSE file or at <http://www.ardor3d.com/LICENSE>.
- */
-
-package com.ardor3d.extension.model.collada.jdom.plugin;
-
-import org.jdom.Element;
-
-public interface ColladaExtraPlugin {
-
- boolean processExtra(Element extra, Object[] params);
-
-}
+/** + * Copyright (c) 2008-2012 Ardor Labs, Inc. + * + * This file is part of Ardor3D. + * + * Ardor3D is free software: you can redistribute it and/or modify it + * under the terms of its license which may be found in the accompanying + * LICENSE file or at <http://www.ardor3d.com/LICENSE>. + */ + +package com.ardor3d.extension.model.collada.jdom.plugin; + +import org.jdom2.Element; + +public interface ColladaExtraPlugin { + + boolean processExtra(Element extra, Object[] params); + +} diff --git a/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/plugin/GoogleEarthPlugin.java b/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/plugin/GoogleEarthPlugin.java index 8481428..73621ff 100644 --- a/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/plugin/GoogleEarthPlugin.java +++ b/ardor3d-collada/src/main/java/com/ardor3d/extension/model/collada/jdom/plugin/GoogleEarthPlugin.java @@ -1,46 +1,44 @@ -/**
- * Copyright (c) 2008-2012 Ardor Labs, Inc.
- *
- * This file is part of Ardor3D.
- *
- * Ardor3D is free software: you can redistribute it and/or modify it
- * under the terms of its license which may be found in the accompanying
- * LICENSE file or at <http://www.ardor3d.com/LICENSE>.
- */
-
-package com.ardor3d.extension.model.collada.jdom.plugin;
-
-import java.util.List;
-
-import org.jdom.Attribute;
-import org.jdom.Element;
-
-import com.ardor3d.renderer.state.CullState;
-import com.ardor3d.scenegraph.Mesh;
-
-public class GoogleEarthPlugin implements ColladaExtraPlugin {
- @SuppressWarnings("unchecked")
- @Override
- public boolean processExtra(final Element extra, final Object[] params) {
- if (params.length > 0 && params[0] instanceof Mesh) {
- final Mesh mesh = (Mesh) params[0];
- // should have a child: <technique profile="GOOGLEEARTH">
- final Element technique = extra.getChild("technique");
- if (technique != null) {
- final Attribute profile = technique.getAttribute("profile");
- if (profile != null && "GOOGLEEARTH".equalsIgnoreCase(profile.getValue())) {
- for (final Element child : (List<Element>) technique.getChildren()) {
- // disable back face culling if it's been enabled.
- if ("double_sided".equalsIgnoreCase(child.getName()) && "1".equals(child.getTextTrim())) {
- final CullState cs = new CullState();
- cs.setEnabled(false);
- mesh.setRenderState(cs);
- }
- }
- return true;
- }
- }
- }
- return false;
- }
-}
+/** + * Copyright (c) 2008-2012 Ardor Labs, Inc. + * + * This file is part of Ardor3D. + * + * Ardor3D is free software: you can redistribute it and/or modify it + * under the terms of its license which may be found in the accompanying + * LICENSE file or at <http://www.ardor3d.com/LICENSE>. + */ + +package com.ardor3d.extension.model.collada.jdom.plugin; + +import org.jdom2.Attribute; +import org.jdom2.Element; + +import com.ardor3d.renderer.state.CullState; +import com.ardor3d.scenegraph.Mesh; + +public class GoogleEarthPlugin implements ColladaExtraPlugin { + + @Override + public boolean processExtra(final Element extra, final Object[] params) { + if (params.length > 0 && params[0] instanceof Mesh) { + final Mesh mesh = (Mesh) params[0]; + // should have a child: <technique profile="GOOGLEEARTH"> + final Element technique = extra.getChild("technique"); + if (technique != null) { + final Attribute profile = technique.getAttribute("profile"); + if (profile != null && "GOOGLEEARTH".equalsIgnoreCase(profile.getValue())) { + for (final Element child : technique.getChildren()) { + // disable back face culling if it's been enabled. + if ("double_sided".equalsIgnoreCase(child.getName()) && "1".equals(child.getTextTrim())) { + final CullState cs = new CullState(); + cs.setEnabled(false); + mesh.setRenderState(cs); + } + } + return true; + } + } + } + return false; + } +} |