123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- /*
- * DoRayMe - a quick and dirty Raytracer
- * Group header
- *
- * Created by Manoël Trapier
- * Copyright (c) 2020 986-Studio.
- *
- */
- #ifndef DORAYME_GROUP_H
- #define DORAYME_GROUP_H
- #include <shape.h>
- #include <stdio.h>
- /* TODO: Add a way to force(?) material from group to be applied on childs */
- class Group : public Shape
- {
- private:
- uint32_t allocatedObjectCount;
- Shape* *objectList;
- uint32_t objectCount;
- uint32_t allocatedUnboxableObjectCount;
- Shape* *unboxableObjectList;
- uint32_t unboxableObjectCount;
- char name[32 + 1];
- protected:
- void localIntersect(Ray r, Intersect &xs);
- Tuple localNormalAt(Tuple point, Intersection *hit = nullptr);
- BoundingBox bounds;
- public:
- bool isEmpty();
- void addObject(Shape *s);
- void removeObject(Shape *s);
- Shape *operator[](const int p) { return this->getObject(p); };
- Shape *getObject(const int p) { return this->objectList[p]; };
- Shape *getUnboxable(const int p) { return this->unboxableObjectList[p]; };
- void intersect(Ray &r, Intersect &xs);
- BoundingBox getLocalBounds();
- BoundingBox getBounds();
- void updateBoundingBox();
- void updateTransform();
- bool includes(Shape *b);
- uint32_t getObjectCount() { return this->objectCount; };
- uint32_t getUnboxableCount() { return this->unboxableObjectCount; };
- Group(const char *name = nullptr);
- void lock();
- void setBounds(BoundingBox &bb) { this->bounds | bb; };
- const char *getName() { return this->name; };
- void dumpMe(FILE * fp);
- };
- #endif /* DORAYME_GROUP_H */
|