#ifndef SPHERE_H #define SPHERE_H #include "entity.h" class Sphere : public Entity { public: Sphere(const vector3d¢er, double radius) {c = center; r = radius;} virtual ~Sphere() {} virtual RayIntersect CalcRayIntersect(Ray ray, int flags, int special=-1); virtual vector3d CalcNormal(Ray ray, RayIntersect& ri); virtual void PathCompress(const Transform&, queue >&, vector&); virtual int IntersectionTest(Ray ray, int flags, int special=-1); virtual void GridCollect(vector& vec) { EntityWrapBound ewb; ewb.E = this; ewb.lo = c - vec_one * r; ewb.hi = c + vec_one * r; vec.push_back(ewb); } void SetCenter(const vector3d& v) {c = v;} void SetRadius(double v) {r = v;} private: vector3d c; double r; }; inline void Sphere::PathCompress(const Transform&T, queue >&Q, vector&V) { Sphere * sp = new Sphere(*this); sp->c = T * c; sp->r = r * pow(fabs(T.rot.Det()), 1.0/3.0); V.push_back(sp); } #endif