group.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * DoRayMe - a quick and dirty Raytracer
  3. * Group header
  4. *
  5. * Created by Manoël Trapier
  6. * Copyright (c) 2020 986-Studio.
  7. *
  8. */
  9. #ifndef DORAYME_GROUP_H
  10. #define DORAYME_GROUP_H
  11. #include <shape.h>
  12. #include <stdio.h>
  13. /* TODO: Add a way to force(?) material from group to be applied on childs */
  14. class Group : public Shape
  15. {
  16. private:
  17. uint32_t allocatedObjectCount;
  18. Shape* *objectList;
  19. uint32_t objectCount;
  20. uint32_t allocatedUnboxableObjectCount;
  21. Shape* *unboxableObjectList;
  22. uint32_t unboxableObjectCount;
  23. protected:
  24. Intersect localIntersect(Ray r);
  25. Tuple localNormalAt(Tuple point, Intersection *hit = nullptr);
  26. BoundingBox bounds;
  27. public:
  28. bool isEmpty();
  29. void addObject(Shape *s);
  30. Shape *operator[](const int p) { return this->objectList[p]; }
  31. Intersect intersect(Ray r);
  32. BoundingBox getLocalBounds();
  33. BoundingBox getBounds();
  34. void updateBoundingBox();
  35. void updateTransform();
  36. bool includes(Shape *b);
  37. Group();
  38. void dumpMe(FILE * fp);
  39. };
  40. #endif /* DORAYME_GROUP_H */