Exemplo n.º 1
0
 private static int findColor(Intersection hit, Camera cam, Model model) {
   if (hit.isMatch()) {
     RealVector light = LightCalculations.computeLight(cam.getFrom3(), model, hit, 0);
     return toColour(light);
   }
   return 0;
 }
Exemplo n.º 2
0
 private static Camera getCamera(Model model) {
   Camera result = new Camera();
   result.setFrom(model.getFrom());
   result.setTo(model.getTo());
   result.setUp(model.getUp());
   result.setFov(model.getFov());
   result.setWidth(model.getW());
   result.setHeight(model.getH());
   result.init();
   return result;
 }
Exemplo n.º 3
0
  private static Ray rayThruPixel(Camera cam, int xi, int yi) {
    Ray result = new Ray();
    float x = xi + .5f;
    float y = yi + .5f;
    final int halfW = cam.getHalfW();
    float alpha = (float) (cam.getTanHalfFovX()) * ((x - halfW) / halfW);
    final int halfH = cam.getHalfH();
    float beta = (float) (cam.getTanHalfFovY() * (halfH - y) / halfH);
    Vector3D p13 =
        cam.getU().scalarMultiply(alpha).add(cam.getV().scalarMultiply(beta)).subtract(cam.getW());

    result.setP0(cam.getFrom());
    result.setP1(VectorUtils.toRealVector(p13));

    return result;
  }