aboutsummaryrefslogtreecommitdiffstats
path: root/ardor3d-extras
diff options
context:
space:
mode:
authorJoshua Slack <[email protected]>2013-12-12 18:27:04 -0800
committerJoshua Slack <[email protected]>2013-12-12 18:27:04 -0800
commitbff55974a6ede4c7f94082b3178eed05cf598882 (patch)
tree805daf3c7f095917a202e5161aaa2336dbc07781 /ardor3d-extras
parent31cb7e51fa8309b4e717cb3a7f2ef02e213df9d7 (diff)
parentf42a71f07c73cdfb4bb85a39a7b18a4bd8e0232d (diff)
Merge pull request #65 from gouessej/master
Allows to override GeometryTool
Diffstat (limited to 'ardor3d-extras')
-rw-r--r--ardor3d-extras/src/main/java/com/ardor3d/extension/model/obj/ObjGeometryStore.java17
-rw-r--r--ardor3d-extras/src/main/java/com/ardor3d/extension/model/obj/ObjImporter.java16
2 files changed, 29 insertions, 4 deletions
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 e472bad..cac72f6 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
@@ -58,6 +58,17 @@ 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() {
return materialLibrary;
}
@@ -188,7 +199,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);
@@ -236,7 +247,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);
@@ -315,7 +326,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 e41cae6..f7b7c28 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
@@ -21,6 +21,7 @@ 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;
@@ -130,8 +131,21 @@ public class ObjImporter {
* @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();
+ final ObjGeometryStore store = new ObjGeometryStore(geometryTool);
long currentSmoothGroup = -1;
final BufferedReader reader = new BufferedReader(new InputStreamReader(resource.openStream()));