From a6b0283809187413e7f0294d2d57ad153b70f64c Mon Sep 17 00:00:00 2001 From: Julien Gouesse Date: Wed, 5 Feb 2014 22:24:57 +0100 Subject: Allows to override the geometry tool when a string is passed to the loader --- .../extension/model/collada/jdom/ColladaImporter.java | 18 +++++++++++++++++- .../com/ardor3d/extension/model/obj/ObjImporter.java | 15 ++++++++++++++- 2 files changed, 31 insertions(+), 2 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..c8bf84f 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 @@ -180,6 +180,22 @@ public class ColladaImporter { * if the resource can not be located or loaded for some reason. */ public ColladaStorage load(final String 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. ResourceLocatorTool will be used with TYPE_MODEL to find the + * resource. + * @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 located or loaded for some reason. + */ + public ColladaStorage load(final String resource, final GeometryTool geometryTool) throws IOException { final ResourceSource source; if (_modelLocator == null) { source = ResourceLocatorTool.locateResource(ResourceLocatorTool.TYPE_MODEL, resource); @@ -191,7 +207,7 @@ public class ColladaImporter { throw new IOException("Unable to locate '" + resource + "'"); } - return load(source); + return load(source, geometryTool); } /** 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..c42564a 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 @@ -109,6 +109,19 @@ public class ObjImporter { * @return an ObjGeometryStore data object containing the scene and other useful elements. */ public ObjGeometryStore load(final String 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 String resource, final GeometryTool geometryTool) { final ResourceSource source; if (_modelLocator == null) { source = ResourceLocatorTool.locateResource(ResourceLocatorTool.TYPE_MODEL, resource); @@ -120,7 +133,7 @@ public class ObjImporter { throw new Error("Unable to locate '" + resource + "'"); } - return load(source); + return load(source, geometryTool); } /** -- cgit v1.2.3