예제 #1
0
 @Override
 public void randomize() {
   super.randomize();
   radiusX.calculate();
   radiusY.calculate();
   radiusZ.calculate();
 }
예제 #2
0
 @Override
 public void draw() {
   final int px = (int) x.getValue();
   final int py = (int) y.getValue();
   final int pz = (int) z.getValue();
   final double rx = radiusX.getValue() + 0.5;
   final double ry = radiusY.getValue() + 0.5;
   final double rz = radiusZ.getValue() + 0.5;
   final double invRadiusX = 1 / rx;
   final double invRadiusY = 1 / ry;
   final double invRadiusZ = 1 / rz;
   final int ceilRadiusX = (int) Math.ceil(rx);
   final int ceilRadiusY = (int) Math.ceil(ry);
   final int ceilRadiusZ = (int) Math.ceil(rz);
   double nextXn = 0;
   forX:
   for (int xx = 0; xx <= ceilRadiusX; xx++) {
     final double xn = nextXn;
     nextXn = (xx + 1) * invRadiusX;
     double nextYn = 0;
     forY:
     for (int yy = 0; yy <= ceilRadiusY; yy++) {
       final double yn = nextYn;
       nextYn = (yy + 1) * invRadiusY;
       double nextZn = 0;
       forZ:
       for (int zz = 0; zz <= ceilRadiusZ; zz++) {
         final double zn = nextZn;
         nextZn = (zz + 1) * invRadiusZ;
         if (lengthSq(xn, yn, zn) > 1) {
           if (zz == 0) {
             if (yy == 0) {
               break forX;
             }
             break forY;
           }
           break forZ;
         }
         final boolean outer =
             lengthSq(nextXn, yn, zn) > 1
                 || lengthSq(xn, nextYn, zn) > 1
                 || lengthSq(xn, yn, nextZn) > 1;
         setter.setMaterial(iwgo.transform(px + xx, py + yy, pz + zz), outer);
         setter.setMaterial(iwgo.transform(px - xx, py + yy, pz + zz), outer);
         setter.setMaterial(iwgo.transform(px + xx, py - yy, pz + zz), outer);
         setter.setMaterial(iwgo.transform(px + xx, py + yy, pz - zz), outer);
         setter.setMaterial(iwgo.transform(px - xx, py - yy, pz + zz), outer);
         setter.setMaterial(iwgo.transform(px + xx, py - yy, pz - zz), outer);
         setter.setMaterial(iwgo.transform(px - xx, py + yy, pz - zz), outer);
         setter.setMaterial(iwgo.transform(px - xx, py - yy, pz - zz), outer);
       }
     }
   }
 }