group.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. char name[32 + 1];
  24. protected:
  25. Intersect localIntersect(Ray r);
  26. Tuple localNormalAt(Tuple point, Intersection *hit = nullptr);
  27. BoundingBox bounds;
  28. public:
  29. bool isEmpty();
  30. void addObject(Shape *s);
  31. Shape *operator[](const int p) { return this->objectList[p]; }
  32. Intersect intersect(Ray r);
  33. BoundingBox getLocalBounds();
  34. BoundingBox getBounds();
  35. void updateBoundingBox();
  36. void updateTransform();
  37. bool includes(Shape *b);
  38. uint32_t getObjectCount() { return this->objectCount + this->unboxableObjectCount; };
  39. Group(const char *name = nullptr);
  40. const char *getName() { return this->name; };
  41. void dumpMe(FILE * fp);
  42. };
  43. #endif /* DORAYME_GROUP_H */