summaryrefslogtreecommitdiffstats
path: root/src/classes/share
diff options
context:
space:
mode:
authorCurtis Rueden <[email protected]>2015-04-09 13:54:09 -0500
committerCurtis Rueden <[email protected]>2015-11-25 14:16:38 -0600
commit6173452b10842e2f244eea1b44ee1466642b95ce (patch)
tree26140e37f3bdee4dbf77c7867e38a8d45e858753 /src/classes/share
parente884748d57128ba11b4582b66ec6663e0fc0a6bd (diff)
Add GeometryService implementation
This code was migrated from java3d-core's Font3D class, in order to address hharrison/java3d-core#17.
Diffstat (limited to 'src/classes/share')
-rw-r--r--src/classes/share/META-INF/services/javax.media.j3d.GeometryService1
-rw-r--r--src/classes/share/com/sun/j3d/utils/geometry/GeometryServiceImpl.java38
2 files changed, 39 insertions, 0 deletions
diff --git a/src/classes/share/META-INF/services/javax.media.j3d.GeometryService b/src/classes/share/META-INF/services/javax.media.j3d.GeometryService
new file mode 100644
index 0000000..fc954bc
--- /dev/null
+++ b/src/classes/share/META-INF/services/javax.media.j3d.GeometryService
@@ -0,0 +1 @@
+com.sun.j3d.utils.geometry.GeometryServiceImpl
diff --git a/src/classes/share/com/sun/j3d/utils/geometry/GeometryServiceImpl.java b/src/classes/share/com/sun/j3d/utils/geometry/GeometryServiceImpl.java
new file mode 100644
index 0000000..f3b0dff
--- /dev/null
+++ b/src/classes/share/com/sun/j3d/utils/geometry/GeometryServiceImpl.java
@@ -0,0 +1,38 @@
+
+package com.sun.j3d.utils.geometry;
+
+import java.util.ArrayList;
+
+import javax.media.j3d.GeometryArray;
+import javax.media.j3d.GeometryService;
+import javax.vecmath.Point3f;
+
+/**
+ * Default implementation of the {@link GeometryService} service interface.
+ */
+public class GeometryServiceImpl implements GeometryService {
+
+ @Override
+ public int triangulateIslands(final int[][] islandCounts,
+ final Point3f[][] outVerts, final int[] contourCounts,
+ final ArrayList<GeometryArray> triangData)
+ {
+ int vertOffset = 0;
+ final NormalGenerator ng = new NormalGenerator();
+ for (int i = 0; i < islandCounts.length; i++) {
+ contourCounts[0] = islandCounts[i].length;
+ final GeometryInfo gi = new GeometryInfo(GeometryInfo.POLYGON_ARRAY);
+ gi.setCoordinates(outVerts[i]);
+ gi.setStripCounts(islandCounts[i]);
+ gi.setContourCounts(contourCounts);
+ ng.generateNormals(gi);
+
+ final GeometryArray ga = gi.getGeometryArray(false, false, false);
+ vertOffset += ga.getVertexCount();
+
+ triangData.add(ga);
+ }
+ return vertOffset;
+ }
+
+}