object.h 842 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * DoRayMe - a quick and dirty Raytracer
  3. * Object header
  4. *
  5. * Created by Manoël Trapier
  6. * Copyright (c) 2020 986-Studio.
  7. *
  8. */
  9. #ifndef DORAYME_OBJECT_H
  10. #define DORAYME_OBJECT_H
  11. class Object;
  12. #include <ray.h>
  13. #include <tuple.h>
  14. #include <matrix.h>
  15. #include <intersect.h>
  16. /* Base class for all object that can be presented in the world */
  17. class Object
  18. {
  19. public:
  20. Matrix transformMatrix;
  21. Matrix inverseTransform;
  22. public:
  23. Object();
  24. virtual Intersect intersect(Ray r);
  25. virtual Tuple normalAt(Tuple point);
  26. void setTransform(Matrix transform);
  27. Ray transform(Ray r) { return Ray(this->transformMatrix * r.origin, this->transformMatrix * r.direction); };
  28. Ray invTransform(Ray r) { return Ray(this->inverseTransform * r.origin, this->inverseTransform * r.direction); };
  29. };
  30. #endif //DORAYME_OBJECT_H