cylinder.h 899 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * DoRayMe - a quick and dirty Raytracer
  3. * Cylinder header
  4. *
  5. * Created by Manoël Trapier
  6. * Copyright (c) 2020 986-Studio.
  7. *
  8. */
  9. #ifndef DORAYME_CYLINDER_H
  10. #define DORAYME_CYLINDER_H
  11. #include <shape.h>
  12. #include <ray.h>
  13. #include <intersect.h>
  14. #include <renderstat.h>
  15. #include <stdio.h>
  16. class Cylinder : public Shape {
  17. protected:
  18. Intersect localIntersect(Ray r);
  19. Tuple localNormalAt(Tuple point, Intersection *hit = nullptr);
  20. bool checkCap(Ray r, double t);
  21. void intersectCaps(Ray r, Intersect &xs);
  22. public:
  23. bool isClosed;
  24. double minCap;
  25. double maxCap;
  26. Cylinder() : minCap(-INFINITY), maxCap(INFINITY), isClosed(false), Shape(SHAPE_CYLINDER) { stats.addCylinder(); };
  27. BoundingBox getLocalBounds();
  28. bool haveFiniteBounds() { return !(isinf(this->minCap) || isinf(this->maxCap)); };
  29. void dumpMe(FILE *fp);
  30. };
  31. #endif //DORAYME_CYLINDER_H