summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCurtis Rueden <[email protected]>2015-04-09 13:38:21 -0500
committerCurtis Rueden <[email protected]>2015-10-06 07:00:54 -0500
commita67d7b847a21150a2f19968ee7e2ed85513481da (patch)
treee08e79377f8ab7f06cd7838f4b5d6eef41cdafba
parentaf0c5a2f9bdb2c79f132a2108bc42fbf9a569422 (diff)
Font3D: refactor island triangulation logic
This moves the logic into a dedicated private method, which will be subsequently externalized into a service interface.
-rw-r--r--src/javax/media/j3d/Font3D.java44
1 files changed, 27 insertions, 17 deletions
diff --git a/src/javax/media/j3d/Font3D.java b/src/javax/media/j3d/Font3D.java
index b9011e8..65566ea 100644
--- a/src/javax/media/j3d/Font3D.java
+++ b/src/javax/media/j3d/Font3D.java
@@ -468,23 +468,8 @@ private static class IntVector {
for (i = 0; i < islandCounts.length; i++) {
numPoints += outVerts[i].length;
}
- //Now loop thru each island, calling triangulator once per island.
- //Combine triangle data for all islands together in one object.
- int vertOffset = 0;
- NormalGenerator ng = new NormalGenerator();
- for (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);
- }
+ int vertOffset =
+ 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)
@@ -959,6 +944,31 @@ 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;
+ }
static boolean getNormal(Point3f p1, Point3f p2, Point3f p3, Vector3f normal) {
Vector3f v1 = new Vector3f();