public Color3 getColorAt(int a, int b) { Color3 endColor = Color3.BLACK; int i; for (i = 0; i < proj_class.photonmap.getStoredPhotons(); i++) { Photon pho = proj_class.photonmap.getPhoton(i); if (pho != null) { if (((int) pho.x == a) && ((int) pho.z == b)) { float tempr = ((float) pho.R) * (((instrument) proj_class.instruments.get_object(pho.lightSource)).getLevel() / 100); float tempg = ((float) pho.G) * (((instrument) proj_class.instruments.get_object(pho.lightSource)).getLevel() / 100); float tempb = ((float) pho.B) * (((instrument) proj_class.instruments.get_object(pho.lightSource)).getLevel() / 100); if (tempr != 0) { int fake = 0; fake++; } endColor = endColor.add(new Color3(tempr, tempg, tempb)); float newr = (float) endColor.getR(); float newg = (float) endColor.getG(); float newb = (float) endColor.getB(); if (newr > 1) { newr = 1; } if (newg > 1) { newg = 1; } if (newb > 1) { newb = 1; } endColor = new Color3(newr, newg, newb); } } } return endColor; }
void render() { Color3 endColor = Color3.BLACK; System.out.println("RE calculating the image"); int i, j, k; for (i = 0; i < viewer.getWidth(); i++) { for (j = 0; j < viewer.getHeight(); j++) { endColor = Color3.BLACK; for (k = 0; k < numScreens; k++) { float tempr = ((float) screens[k].getPixel(i, j).getR()) * ((float) ((instrument) proj_class.instruments.get_object(k)).getLevel() / (float) 100.0); float tempg = ((float) screens[k].getPixel(i, j).getG()) * ((float) ((instrument) proj_class.instruments.get_object(k)).getLevel() / (float) 100.0); float tempb = ((float) screens[k].getPixel(i, j).getB()) * ((float) ((instrument) proj_class.instruments.get_object(k)).getLevel() / (float) 100.0); if ((tempr != 0) || (tempg != 0) || (tempb != 0)) { float newr = tempr + (float) endColor.getR(); float newg = tempg + (float) endColor.getG(); float newb = tempb + (float) endColor.getB(); if (newr > 1) { newr = 1; } if (newg > 1) { newg = 1; } if (newb > 1) { newb = 1; } endColor = new Color3(newr, newg, newb); } } viewer.setPixel(i, j, endColor.toRGB()); } } newRender = true; repaint(); }