00001 #ifndef SPHERE_H_ 00002 #define SPHERE_H_ 00003 00004 #include "Primitive.h" 00005 #include "AABB.h" 00006 00007 namespace rcrt 00008 { 00009 00015 class Sphere : public Primitive 00016 { 00017 private: 00018 Point3D center; 00019 float radius; 00020 AABB box; 00021 void assign(const Sphere& s); 00022 00023 public: 00024 Sphere(const Point3D& c, float r, SolidObject* parent=0); 00025 Sphere(const Sphere& s, SolidObject* parent=0); 00026 virtual ~Sphere(); 00027 00028 virtual Intersection intersect(Ray& ray) const; 00029 virtual const AABB& getBoundingBox() const; 00030 virtual const Point3D& getCentroid() const; 00031 00032 float getRadius() const; 00033 00034 virtual Vec3D getSNormal(float zenith, float azimuth) const; 00035 virtual Vec3D getGNormal(float zenith, float azimuth) const; 00036 virtual Point2D getUV(float zenith, float azimuth) const; 00037 00038 AABB clipBox(AABB& cbox) const; 00039 }; 00040 00041 } 00042 00043 00044 #endif /*SPHERE_H_*/