sphere.h 837 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * DoRayMe - a quick and dirty Raytracer
  3. * Sphere header
  4. *
  5. * Created by Manoël Trapier
  6. * Copyright (c) 2020 986-Studio.
  7. *
  8. */
  9. #ifndef DORAYME_SPHERE_H
  10. #define DORAYME_SPHERE_H
  11. #include <shape.h>
  12. #include <ray.h>
  13. #include <intersect.h>
  14. #include <renderstat.h>
  15. #include <stdio.h>
  16. class Sphere : public Shape
  17. {
  18. protected:
  19. void localIntersect(Ray r, Intersect &xs);
  20. Tuple localNormalAt(Tuple point, Intersection *hit = nullptr);
  21. public:
  22. Sphere() : Shape(Shape::SPHERE) { stats.addSphere(); };
  23. /* All sphere are at (0, 0, 0) and radius 1 in the object space */
  24. void dumpMe(FILE *fp);
  25. };
  26. /* Mostly for test purposes */
  27. class GlassSphere : public Sphere
  28. {
  29. public:
  30. GlassSphere() : Sphere() { this->material.transparency = 1.0; this->material.refractiveIndex = 1.5; };
  31. };
  32. #endif /* DORAYME_SPHERE_H */