Ejemplo n.º 1
0
  /**
   * Collects Form Factor and possibly fist bounce Emission data. Note that if you call collect
   * twice, the form factors will be increased! (i.e., only want to call collect once per hemicube
   * draw... not collect on draw, unless you simply want to see sparsity)
   *
   * @param which
   * @param collectF
   * @param collectE
   */
  private void collectData(int which) {

    /* Find material for the specified face */
    Material faceMaterial = scene.getObject().getFaceMaterial(which);

    for (int i = 0; i < divisions * divisions * 12; i++) {
      byte r = pixelData[i * 4 + 0];
      byte g = pixelData[i * 4 + 1];
      byte b = pixelData[i * 4 + 2];
      int id = ObjectScene.colourBytesToInt(r, g, b);

      if (id > 0 && id < scene.getNumFaces()) {

        // TODO -- Part 2 - Collecting FFs!
        /* Collect form factors for each face based on
         * diffuse material (kd), weight (data) */
        F[0].add(which, id, -faceMaterial.kd[0] * data[i]);
        F[1].add(which, id, -faceMaterial.kd[1] * data[i]);
        F[2].add(which, id, -faceMaterial.kd[2] * data[i]);
      }
    }
  }