Exemplo n.º 1
0
  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();
  }
Exemplo n.º 2
0
  public void loadData() {
    //    if(!dataLoaded){

    scale = 1;
    maxX = 0;
    maxY = 0;
    minX = 640;
    minY = 480;
    numScreens = proj_class.instruments.get_num_objects();

    screens = new Bitmap[numScreens];
    levels = new int[numScreens];

    int i;
    for (i = 0; i < (proj_class.instruments.get_num_objects()); i++) {
      ((instrument) proj_class.instruments.get_object(i)).setLevel(100);
    }

    for (i = 0; i < numScreens; i++) {
      screens[i] = new Bitmap(640, 480, false);
      int x, y;
      for (x = 0; x < 640; x++) {
        for (y = 0; y < 480; y++) {
          screens[i].setPixel(x, y, Color3.BLACK);
        }
      }

      levels[i] = 0;
      int j;
      for (j = 0; j < proj_class.photonmap.getStoredPhotons(); j++) {
        Photon pho = proj_class.photonmap.getPhoton(j);
        if (pho != null) {
          if (pho.lightSource == i) {

            screens[i].setPixel((int) pho.x, 480 - (int) pho.z, new Color3(pho.R, pho.G, pho.B));
            if ((int) pho.x > maxX) {
              maxX = (int) pho.x;
            }
            if ((480 - (int) pho.z) > maxY) {
              maxY = (480 - (int) pho.z);
            }
            if ((int) pho.x < minX) {
              minX = (int) pho.x;
            }
            if ((480 - (int) pho.z) < minY) {
              minY = (480 - (int) pho.z);
            }
          }
        }
      }

      screens[i].save("lightscreen" + i + ".png");
    }
    viewer = new Bitmap(640, 480, false);
    int j;
    for (i = 0; i < viewer.getWidth(); i++) {
      for (j = 0; j < viewer.getHeight(); j++) {
        viewer.setPixel(i, j, Color3.BLACK);
      }
    }
    //            dataLoaded=true;
    //      }
    int tempx = 0;
    int tempy = 0;
    if (maxX != 0) {
      tempx = 640 / maxX;
    }

    if (maxY != 0) {
      tempy = 480 / maxY;
    }

    if (tempx > 0) {
      if (tempx > tempy) {
        scale = tempx;
      }
    }
    if (tempy > 0) {
      if (tempy > tempx) {
        scale = tempy;
      }
    }
  }