/** Reallocates and resets all matrices */ public void resetMatrices() { /* Store material for a particular accessed face */ Material faceMaterial = new Material(); int n = scene.getNumFaces(); for (int j = 0; j < 3; j++) { F[j] = new FlexCompRowMatrix(n, n); B[j] = new DenseVector(n); E[j] = new DenseVector(n); // make the matrix the identity... for (int i = 0; i < n; i++) { F[j].set(i, i, 1); /* TODO! Emission for each face /* Initialize face/patch based on whether luminous * if lit, set E to diffuse lighting for each colour * (since surface radiance == diffuse material properties) */ faceMaterial = scene.getObject().getFaceMaterial(i); /* If lit patch, initialize to amount of light based on diffuse parameter */ if (faceMaterial.emission) { E[j].add(i, faceMaterial.kd[j]); // Set light for each colour for each face } } } }
/** * 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]); } } }