intersection.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * DoRayMe - a quick and dirty Raytracer
  3. * Intersection header
  4. *
  5. * Created by Manoël Trapier
  6. * Copyright (c) 2020 986-Studio.
  7. *
  8. */
  9. #ifndef DORAYME_INTERSECTION_H
  10. #define DORAYME_INTERSECTION_H
  11. #include <stdlib.h>
  12. #include <ray.h>
  13. class Shape;
  14. struct Computation
  15. {
  16. Computation(Shape *object, double t, Tuple point, Tuple eyev, Tuple normalv, Tuple overHitP, bool inside) :
  17. object(object), t(t), hitPoint(point), eyeVector(eyev), normalVector(normalv), inside(inside), overHitPoint(overHitP) { };
  18. Shape *object;
  19. double t;
  20. Tuple hitPoint;
  21. Tuple overHitPoint;
  22. Tuple eyeVector;
  23. Tuple normalVector;
  24. bool inside;
  25. };
  26. class Intersection
  27. {
  28. public:
  29. double t;
  30. Shape *object;
  31. public:
  32. Intersection(double t, Shape *object) : t(t), object(object) { };
  33. bool nothing() { return (this->object == nullptr); };
  34. Computation prepareComputation(Ray r);
  35. bool operator==(const Intersection &b) const { return ((this->t == b.t) && (this->object == b.object)); };
  36. };
  37. #endif /* DORAYME_INTERSECTION_H */