示例#1
0
 public boolean update(ParameterList pl, SunflowAPI api) {
   {
     int[] quads = pl.getIntArray("quads");
     if (quads != null) {
       this.quads = quads;
     }
   }
   if (quads == null) {
     UI.printError(Module.GEOM, "Unable to update mesh - quad indices are missing");
     return false;
   }
   if (quads.length % 4 != 0)
     UI.printWarning(
         Module.GEOM, "Quad index data is not a multiple of 4 - some quads may be missing");
   pl.setFaceCount(quads.length / 4);
   {
     FloatParameter pointsP = pl.getPointArray("points");
     if (pointsP != null)
       if (pointsP.interp != InterpolationType.VERTEX)
         UI.printError(
             Module.GEOM,
             "Point interpolation type must be set to \"vertex\" - was \"%s\"",
             pointsP.interp.name().toLowerCase(Locale.ENGLISH));
       else {
         points = pointsP.data;
       }
   }
   if (points == null) {
     UI.printError(Module.GEOM, "Unabled to update mesh - vertices are missing");
     return false;
   }
   pl.setVertexCount(points.length / 3);
   pl.setFaceVertexCount(4 * (quads.length / 4));
   FloatParameter normals = pl.getVectorArray("normals");
   if (normals != null) this.normals = normals;
   FloatParameter uvs = pl.getTexCoordArray("uvs");
   if (uvs != null) this.uvs = uvs;
   int[] faceShaders = pl.getIntArray("faceshaders");
   if (faceShaders != null && faceShaders.length == quads.length / 4) {
     this.faceShaders = new byte[faceShaders.length];
     for (int i = 0; i < faceShaders.length; i++) {
       int v = faceShaders[i];
       if (v > 255) UI.printWarning(Module.GEOM, "Shader index too large on quad %d", i);
       this.faceShaders[i] = (byte) (v & 0xFF);
     }
   }
   return true;
 }