diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/javax/media/j3d/Font3D.java | 43 |
1 files changed, 15 insertions, 28 deletions
diff --git a/src/javax/media/j3d/Font3D.java b/src/javax/media/j3d/Font3D.java index 65566ea..0d7c631 100644 --- a/src/javax/media/j3d/Font3D.java +++ b/src/javax/media/j3d/Font3D.java @@ -37,14 +37,13 @@ import java.awt.geom.Rectangle2D; import java.util.ArrayList; import java.util.Arrays; import java.util.Hashtable; +import java.util.Iterator; +import java.util.ServiceLoader; import javax.vecmath.Point3d; import javax.vecmath.Point3f; import javax.vecmath.Vector3f; -import com.sun.j3d.utils.geometry.GeometryInfo; -import com.sun.j3d.utils.geometry.NormalGenerator; - /** * The Font3D object is used to store extruded 2D glyphs. These * 3D glyphs can then be used to construct Text3D NodeComponent @@ -468,8 +467,11 @@ private static class IntVector { for (i = 0; i < islandCounts.length; i++) { numPoints += outVerts[i].length; } + + final GeometryService gs = newGeometryService(); int vertOffset = - triangulateIslands(islandCounts, outVerts, contourCounts, triangData); + gs.triangulateIslands(islandCounts, outVerts, contourCounts, triangData); + // Multiply by 2 since we create 2 faces of the font // Second term is for side-faces along depth of the font if (fontExtrusion == null) @@ -944,30 +946,15 @@ private static class IntVector { return geo; } - /** - * Loops through each island, calling triangulator once per island. Combines - * triangle data for all islands together in one object. - */ - private int triangulateIslands(final int[][] islandCounts, - final Point3f[][] outVerts, final int[] contourCounts, - final ArrayList<GeometryArray> triangData) - { - int vertOffset = 0; - NormalGenerator ng = new NormalGenerator(); - for (int i = 0; i < islandCounts.length; i++) { - contourCounts[0] = islandCounts[i].length; - GeometryInfo gi = new GeometryInfo(GeometryInfo.POLYGON_ARRAY); - gi.setCoordinates(outVerts[i]); - gi.setStripCounts(islandCounts[i]); - gi.setContourCounts(contourCounts); - ng.generateNormals(gi); - - GeometryArray ga = gi.getGeometryArray(false, false, false); - vertOffset += ga.getVertexCount(); - - triangData.add(ga); - } - return vertOffset; + private GeometryService newGeometryService() { + final ServiceLoader<GeometryService> gsLoader = + ServiceLoader.load(GeometryService.class); + + final Iterator<GeometryService> iter = gsLoader.iterator(); + if (iter.hasNext()) return iter.next(); + + throw new IllegalStateException("No GeometryService implementation found. " + + "Please add j3d-core-utils to the classpath."); } static boolean getNormal(Point3f p1, Point3f p2, Point3f p3, Vector3f normal) { |