change MarchingCubes.march() to take a VoxelData rather than a SampledField
[anneal.git] / src / edu / berkeley / qfat / Main.java
index f5a1344..56eeb83 100644 (file)
@@ -295,18 +295,25 @@ public class Main extends InteractiveMeshViewer {
     public void marchingCubes() {
         Mesh mesh = new Mesh(false);
         mesh.coalesce = true;
-        MarchingCubes.march(new SampledField() {
-                                public float getSample(Point p) {
-                                    double x = p.x;
-                                    double y = p.y;
-                                    double z = p.z;
-                                    x-=1.1;
-                                    y-=1.1;
-                                    z-=1.1;
-                                    return (float)(0.8-Math.sqrt(x*x+y*y+z*z));
-                                }
-                            },
-            0, 30, 0.1, mesh);
+        MarchingCubes.march(new VoxelData() {
+                float radius = 1.0f;
+                public float getMaxX()        { return  1.0f; }
+                public float getMinX()        { return -1.0f; }
+                public int   getNumSamplesX() { return   10; }
+                public float getMaxY()        { return  1.0f; }
+                public float getMinY()        { return -1.0f; }
+                public int   getNumSamplesY() { return   10; }
+                public float getMaxZ()        { return  1.0f; }
+                public float getMinZ()        { return -1.0f; }
+                public int   getNumSamplesZ() { return   10; }
+                public float getSample(Point p) {
+                    double x = p.x;
+                    double y = p.y;
+                    double z = p.z;
+                    return (float)(radius-Math.sqrt(x*x+y*y+z*z));
+                }
+            },
+            mesh);
         setTile(mesh);
         //fixupTile();
     }