object.h 959 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. #include <material.h>
  17. /* Base class for all object that can be presented in the world */
  18. class Object
  19. {
  20. public:
  21. Matrix transformMatrix;
  22. Matrix inverseTransform;
  23. Material material;
  24. public:
  25. Object();
  26. virtual Intersect intersect(Ray r);
  27. virtual Tuple normalAt(Tuple point);
  28. void setTransform(Matrix transform);
  29. void setMaterial(Material material) { this->material = material; };
  30. Ray transform(Ray r) { return Ray(this->transformMatrix * r.origin, this->transformMatrix * r.direction); };
  31. Ray invTransform(Ray r) { return Ray(this->inverseTransform * r.origin, this->inverseTransform * r.direction); };
  32. };
  33. #endif //DORAYME_OBJECT_H