summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;
+ }
+
+}