diff options
Diffstat (limited to 'ardor3d-extras')
-rw-r--r-- | ardor3d-extras/src/main/java/com/ardor3d/extension/model/obj/ObjGeometryStore.java | 17 | ||||
-rw-r--r-- | ardor3d-extras/src/main/java/com/ardor3d/extension/model/obj/ObjImporter.java | 16 |
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())); |