Exemple #1
0
  public int[] rayTrace(Ray ray, int depth) {

    double t = Double.MAX_VALUE;
    RenderObject res = null;
    for (int i = 0; i < s.o.objectsArray.size(); i++) {
      RenderObject curr = s.o.objectsArray.get(i);
      double triceratops = getT(ray, curr);
      if (triceratops != -1 && triceratops < t) {
        t = triceratops;
        res = curr;
      }
    }
    if (res == null) {
      System.out.println("test");
      return s.ac;
    }
    Coord Trex = ray.p0C.add(ray.p0C, ray.uC.multiply(ray.uC, t));
    Coord norm = res.getNormalAt(Trex);
    //		int[] color = new int[3];
    //		int materID = s.o.get_obj_by_id(res.id).matId;
    //		Material w = s.m.materialArray.get(materID);
    //		for (int j = 0; j < 3; j++){
    //			color[j] = (int)(w.rgb[j] * 255);
    //		}
    return rayShade(res, ray, Trex, norm, depth);

    //
    //
    //
    // return color;
  }