Example #1
0
  private void raytrace(Ray ray) {
    double[] nearfar = new double[2];
    enterBlock(ray, nearfar);
    double tNear = nearfar[0];
    double tFar = nearfar[1];

    ray.color.set(1, 1, 1, 1);

    if (tNear <= tFar && tFar >= 0) {
      ray.o.scaleAdd(tNear, ray.d);
      ray.distance += tNear;

      if (blockId == -1) {
        renderTestModel(ray);
      } else {
        if (showCompass) {
          renderCompass(ray);
        }

        ray.setPrevMat(Block.AIR, 0);
        Block theBlock = Block.get(blockId);
        ray.setCurrentMat(theBlock, blockId);
        theBlock.intersect(ray, scene);
      }
    }
  }