// Gray - A simple ray tracing program // Copyright (C) 2008-2013 Eric Bechet // // See the COPYING file for contributions and license information. // Please report all bugs and problems to . // /** * Bounding Box : * * 4-----5 * /| /| * 7-----6 | * | | | | * | 3---|-2 * |/ |/ * 0-----1 */ #ifndef BOUNDINGBOX_H_ #define BOUNDINGBOX_H_ #include "models.h" #include "meshmodel.h" #include "modelsList.h" #include "ray.h" #include class Face { public: std::vector points; Point min; Point max; Face(std::vector pointsValue, Point minValue, Point maxValue) : points(pointsValue), min(minValue),max(maxValue) {} }; class BoundingBox { public: BoundingBox(Gmodel*); BoundingBox(BoundingBox*, BoundingBox*); virtual ~BoundingBox() {} void sphereBB(Gsphere*); void discBB(Gdisc*); void meshModelBB(Gmeshmodel*); Gmodel* getModel() { return model; } std::vector getCornerPoints() { return cornerPoints; } std::vector getFaces() { return faces; } Point getBBoxCenter() { return center; } void setModel(Gmodel* newModel) { model = newModel; } void setCornerPoints(std::vector newCornerPoints) { cornerPoints = newCornerPoints; } void setFaces(std::vector newFaces) { faces = newFaces; } void setBBoxCenter(Point newCenter) { center = newCenter; } bool intersect(Ray*); private: Gmodel* model; std::vector cornerPoints; std::vector faces; Point center; double getMinCoordinateX(std::vector); double getMinCoordinateY(std::vector); double getMinCoordinateZ(std::vector); double getMaxCoordinateX(std::vector); double getMaxCoordinateY(std::vector); double getMaxCoordinateZ(std::vector); bool intersectionX(Face, Ray*); bool intersectionY(Face, Ray*); bool intersectionZ(Face, Ray*); void initFaces(); }; #endif /* BOUNDINGBOX_H_ */