diff options
5 files changed, 38 insertions, 83 deletions
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 4464a0b..f448ea0 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 @@ -3,7 +3,7 @@ * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * 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>. */ @@ -42,7 +42,6 @@ import com.ardor3d.extension.model.collada.jdom.data.DataCache; import com.ardor3d.extension.model.collada.jdom.plugin.ColladaExtraPlugin; import com.ardor3d.scenegraph.MeshData; import com.ardor3d.scenegraph.Node; -import com.ardor3d.util.geom.GeometryTool; import com.ardor3d.util.geom.GeometryTool.MatchCondition; import com.ardor3d.util.resource.RelativeResourceLocator; import com.ardor3d.util.resource.ResourceLocator; @@ -171,7 +170,7 @@ public class ColladaImporter { /** * Reads a Collada file from the given resource and returns it as a ColladaStorage object. - * + * * @param resource * the name of the resource to find. ResourceLocatorTool will be used with TYPE_MODEL to find the * resource. @@ -196,7 +195,7 @@ public class ColladaImporter { /** * Reads a Collada file from the given resource and returns it as a ColladaStorage object. - * + * * @param resource * the name of the resource to find. * @return a ColladaStorage data object containing the Collada scene and other useful elements. @@ -204,21 +203,6 @@ public class ColladaImporter { * if the resource can not be loaded for some reason. */ public ColladaStorage load(final ResourceSource resource) throws IOException { - return load(resource, new GeometryTool()); - } - - /** - * Reads a Collada file from the given resource and returns it as a ColladaStorage object. - * - * @param resource - * the name of the resource to find. - * @param geometryTool - * the geometry tool used to minimize the vertex count. - * @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, final GeometryTool geometryTool) throws IOException { final ColladaStorage colladaStorage = new ColladaStorage(); final DataCache dataCache = new DataCache(); if (_externalJointMapping != null) { @@ -227,7 +211,7 @@ public class ColladaImporter { final ColladaDOMUtil colladaDOMUtil = new ColladaDOMUtil(dataCache); final ColladaMaterialUtils colladaMaterialUtils = new ColladaMaterialUtils(this, dataCache, colladaDOMUtil); final ColladaMeshUtils colladaMeshUtils = new ColladaMeshUtils(dataCache, colladaDOMUtil, colladaMaterialUtils, - _optimizeMeshes, _optimizeSettings, geometryTool); + _optimizeMeshes, _optimizeSettings); final ColladaAnimUtils colladaAnimUtils = new ColladaAnimUtils(colladaStorage, dataCache, colladaDOMUtil, colladaMeshUtils); final ColladaNodeUtils colladaNodeUtils = new ColladaNodeUtils(dataCache, colladaDOMUtil, colladaMaterialUtils, @@ -300,7 +284,7 @@ public class ColladaImporter { /** * Reads the whole Collada DOM tree from the given resource and returns its root element. Exceptions may be thrown * by underlying tools; these will be wrapped in a RuntimeException and rethrown. - * + * * @param resource * the ResourceSource to read the resource from * @return the Collada root element @@ -497,7 +481,7 @@ public class ColladaImporter { /** * Parse a numeric value. Commas are replaced by dot automaticly. Also handle special values : INF, -INF, NaN - * + * * @param number * string * @return float 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 4c40b0a..6fe3de6 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 @@ -3,7 +3,7 @@ * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * 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>. */ @@ -43,28 +43,20 @@ public class ColladaMeshUtils { private final ColladaMaterialUtils _colladaMaterialUtils; private final boolean _optimizeMeshes; private final EnumSet<MatchCondition> _optimizeSettings; - private final GeometryTool _geometryTool; public ColladaMeshUtils(final DataCache dataCache, final ColladaDOMUtil colladaDOMUtil, final ColladaMaterialUtils colladaMaterialUtils, final boolean optimizeMeshes, final EnumSet<MatchCondition> optimizeSettings) { - this(dataCache, colladaDOMUtil, colladaMaterialUtils, optimizeMeshes, optimizeSettings, new GeometryTool()); - } - - public ColladaMeshUtils(final DataCache dataCache, final ColladaDOMUtil colladaDOMUtil, - final ColladaMaterialUtils colladaMaterialUtils, final boolean optimizeMeshes, - final EnumSet<MatchCondition> optimizeSettings, final GeometryTool geometryTool) { _dataCache = dataCache; _colladaDOMUtil = colladaDOMUtil; _colladaMaterialUtils = colladaMaterialUtils; _optimizeMeshes = optimizeMeshes; _optimizeSettings = EnumSet.copyOf(optimizeSettings); - _geometryTool = geometryTool; } /** * Builds geometry from an instance_geometry element. - * + * * @param instanceGeometry * @return our Spatial */ @@ -81,7 +73,7 @@ public class ColladaMeshUtils { * Builds a mesh from a Collada geometry element. Currently supported mesh types: mesh, polygons, polylist, * triangles, lines. Not supported yet: linestrips, trifans, tristrips. If no meshtype is found, a pointcloud is * built. - * + * * @param colladaGeometry * @return a Node containing all of the Ardor3D meshes we've parsed from this geometry element. */ @@ -220,7 +212,7 @@ public class ColladaMeshUtils { _dataCache.getVertMappings().put(colladaGeometry, mvp); if (_optimizeMeshes) { - final VertMap map = _geometryTool.minimizeVerts(points, _optimizeSettings); + final VertMap map = GeometryTool.minimizeVerts(points, _optimizeSettings); _dataCache.setMeshVertMap(points, map); } @@ -315,7 +307,7 @@ public class ColladaMeshUtils { } if (_optimizeMeshes) { - final VertMap map = _geometryTool.minimizeVerts(polyMesh, _optimizeSettings); + final VertMap map = GeometryTool.minimizeVerts(polyMesh, _optimizeSettings); _dataCache.setMeshVertMap(polyMesh, map); } @@ -407,7 +399,7 @@ public class ColladaMeshUtils { } if (_optimizeMeshes) { - final VertMap map = _geometryTool.minimizeVerts(polyMesh, _optimizeSettings); + final VertMap map = GeometryTool.minimizeVerts(polyMesh, _optimizeSettings); _dataCache.setMeshVertMap(polyMesh, map); } @@ -461,7 +453,7 @@ public class ColladaMeshUtils { } if (_optimizeMeshes) { - final VertMap map = _geometryTool.minimizeVerts(triMesh, _optimizeSettings); + final VertMap map = GeometryTool.minimizeVerts(triMesh, _optimizeSettings); _dataCache.setMeshVertMap(triMesh, map); } @@ -512,7 +504,7 @@ public class ColladaMeshUtils { } if (_optimizeMeshes) { - final VertMap map = _geometryTool.minimizeVerts(lineMesh, _optimizeSettings); + final VertMap map = GeometryTool.minimizeVerts(lineMesh, _optimizeSettings); _dataCache.setMeshVertMap(lineMesh, map); } @@ -523,7 +515,7 @@ public class ColladaMeshUtils { /** * Extract our pipes from the given parent element. - * + * * @param inputsParent * @param pipesStore * the store for our pipes @@ -564,7 +556,7 @@ public class ColladaMeshUtils { /** * Push the values at the given indices of currentVal onto the buffers defined in pipes. - * + * * @param pipes * @param currentVal * @return the vertex index referenced in the given indices based on the pipes. Integer.MIN_VALUE is returned if no @@ -586,7 +578,7 @@ public class ColladaMeshUtils { /** * Extract name from xml element, some exporters don't support 'name' attribute, so we better use the material * instead of a generic name. - * + * * @param element * @return value from 'name' or 'material' attribute */ diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/geom/GeometryTool.java b/ardor3d-core/src/main/java/com/ardor3d/util/geom/GeometryTool.java index a9f4f3f..71fd338 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/util/geom/GeometryTool.java +++ b/ardor3d-core/src/main/java/com/ardor3d/util/geom/GeometryTool.java @@ -3,7 +3,7 @@ * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * 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>. */ @@ -25,11 +25,11 @@ import com.google.common.collect.Maps; /** * This tool assists in reducing geometry information.<br> - * + * * Note: Does not work with geometry using texcoords other than 2d coords. <br> * TODO: Consider adding an option for "close enough" vertex matches... ie, smaller than X distance apart.<br> */ -public class GeometryTool { +public final class GeometryTool { private static final Logger logger = Logger.getLogger(GeometryTool.class.getName()); /** @@ -46,7 +46,7 @@ public class GeometryTool { Group; } - public GeometryTool() { + private GeometryTool() { super(); } @@ -54,14 +54,14 @@ public class GeometryTool { * Attempt to collapse duplicate vertex data in a given mesh. Vertices are considered duplicate if they occupy the * same place in space and match the supplied conditions. All vertices in the mesh are considered part of the same * vertex "group". - * + * * @param mesh * the mesh to reduce * @param conditions * our match conditions. * @return a mapping of old vertex positions to their new positions. */ - public VertMap minimizeVerts(final Mesh mesh, final EnumSet<MatchCondition> conditions) { + public static VertMap minimizeVerts(final Mesh mesh, final EnumSet<MatchCondition> conditions) { final VertGroupData groupData = new VertGroupData(); groupData.setGroupConditions(VertGroupData.DEFAULT_GROUP, conditions); return minimizeVerts(mesh, groupData); @@ -70,14 +70,14 @@ public class GeometryTool { /** * Attempt to collapse duplicate vertex data in a given mesh. Vertices are consider duplicate if they occupy the * same place in space and match the supplied conditions. The conditions are supplied per vertex group. - * + * * @param mesh * the mesh to reduce * @param groupData * grouping data for the vertices in this mesh. * @return a mapping of old vertex positions to their new positions. */ - public VertMap minimizeVerts(final Mesh mesh, final VertGroupData groupData) { + public static VertMap minimizeVerts(final Mesh mesh, final VertGroupData groupData) { final long start = System.currentTimeMillis(); int vertCount = -1; @@ -209,7 +209,7 @@ public class GeometryTool { return result; } - private Vector2[] getTexs(final Vector2[][] tex, final int i) { + private static Vector2[] getTexs(final Vector2[][] tex, final int i) { final Vector2[] res = new Vector2[tex.length]; for (int x = 0; x < tex.length; x++) { if (tex[x] != null) { @@ -219,7 +219,7 @@ public class GeometryTool { return res; } - public void trimEmptyBranches(final Spatial spatial) { + public static void trimEmptyBranches(final Spatial spatial) { if (spatial instanceof Node) { final Node node = (Node) spatial; for (int i = node.getNumberOfChildren(); --i >= 0;) { diff --git a/ardor3d-extras/src/main/java/com/ardor3d/extension/model/obj/ObjGeometryStore.java b/ardor3d-extras/src/main/java/com/ardor3d/extension/model/obj/ObjGeometryStore.java index cac72f6..bd96824 100644 --- a/ardor3d-extras/src/main/java/com/ardor3d/extension/model/obj/ObjGeometryStore.java +++ b/ardor3d-extras/src/main/java/com/ardor3d/extension/model/obj/ObjGeometryStore.java @@ -3,7 +3,7 @@ * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * 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>. */ @@ -58,15 +58,8 @@ public class ObjGeometryStore { private final Map<String, ObjMaterial> materialLibrary = Maps.newHashMap(); private final Map<Spatial, String> _materialMap = Maps.newHashMap(); - private final GeometryTool _geometryTool; - public ObjGeometryStore() { - this(new GeometryTool()); - } - - public ObjGeometryStore(final GeometryTool geometryTool) { super(); - _geometryTool = geometryTool; } public Map<String, ObjMaterial> getMaterialLibrary() { @@ -199,7 +192,7 @@ public class ObjGeometryStore { } points.getMeshData().setIndices(indexBuffer); - _geometryTool.minimizeVerts(points, EnumSet.noneOf(MatchCondition.class)); + GeometryTool.minimizeVerts(points, EnumSet.noneOf(MatchCondition.class)); applyCurrentMaterial(points); mapToGroups(points); @@ -247,7 +240,7 @@ public class ObjGeometryStore { } line.getMeshData().setIndexLengths(lengths); } - _geometryTool.minimizeVerts(line, EnumSet.of(MatchCondition.UVs)); + GeometryTool.minimizeVerts(line, EnumSet.of(MatchCondition.UVs)); applyCurrentMaterial(line); mapToGroups(line); @@ -326,7 +319,7 @@ public class ObjGeometryStore { groupData.setVertGroups(vertGroups); groupData.setGroupConditions(VertGroupData.DEFAULT_GROUP, EnumSet.of(MatchCondition.Normal, MatchCondition.UVs)); - _geometryTool.minimizeVerts(mesh, groupData); + GeometryTool.minimizeVerts(mesh, groupData); applyCurrentMaterial(mesh); mapToGroups(mesh); diff --git a/ardor3d-extras/src/main/java/com/ardor3d/extension/model/obj/ObjImporter.java b/ardor3d-extras/src/main/java/com/ardor3d/extension/model/obj/ObjImporter.java index f7b7c28..4328e19 100644 --- a/ardor3d-extras/src/main/java/com/ardor3d/extension/model/obj/ObjImporter.java +++ b/ardor3d-extras/src/main/java/com/ardor3d/extension/model/obj/ObjImporter.java @@ -3,7 +3,7 @@ * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * 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>. */ @@ -21,7 +21,6 @@ import com.ardor3d.image.TextureStoreFormat; import com.ardor3d.math.MathUtils; import com.ardor3d.math.Vector3; import com.ardor3d.util.TextureManager; -import com.ardor3d.util.geom.GeometryTool; import com.ardor3d.util.resource.ResourceLocator; import com.ardor3d.util.resource.ResourceLocatorTool; import com.ardor3d.util.resource.ResourceSource; @@ -103,7 +102,7 @@ public class ObjImporter { /** * Reads a Wavefront OBJ file from the given resource - * + * * @param resource * the name of the resource to find. * @return an ObjGeometryStore data object containing the scene and other useful elements. @@ -125,27 +124,14 @@ public class ObjImporter { /** * Reads a Wavefront OBJ file from the given resource - * + * * @param resource * the name of the resource to find. * @return an ObjGeometryStore data object containing the scene and other useful elements. */ public ObjGeometryStore load(final ResourceSource resource) { - return load(resource, new GeometryTool()); - } - - /** - * Reads a Wavefront OBJ file from the given resource - * - * @param resource - * the name of the resource to find. - * @param geometryTool - * the geometry tool used to minimize the vertex count. - * @return an ObjGeometryStore data object containing the scene and other useful elements. - */ - public ObjGeometryStore load(final ResourceSource resource, final GeometryTool geometryTool) { try { - final ObjGeometryStore store = new ObjGeometryStore(geometryTool); + final ObjGeometryStore store = new ObjGeometryStore(); long currentSmoothGroup = -1; final BufferedReader reader = new BufferedReader(new InputStreamReader(resource.openStream())); @@ -218,7 +204,7 @@ public class ObjImporter { else if ("cstype".equals(keyword)) { // TODO: Add support for cstype ObjImporter.logger - .warning("ObjModelImporter: cstype not supported. (line " + lineNo + ") " + line); + .warning("ObjModelImporter: cstype not supported. (line " + lineNo + ") " + line); } // if degree @@ -385,7 +371,7 @@ public class ObjImporter { /** * Load a .mtl resource - * + * * @param fileName * the name of the mtl resource to load. * @param modelSource @@ -411,7 +397,7 @@ public class ObjImporter { /** * Load a .mtl resource - * + * * @param resource * the mtl file to load, as a ResourceSource * @param store |