
#ifndef __WFX_MATH_SPHERE_H__
#define __WFX_MATH_SPHERE_H__

#include <WFX/WFXIncludes.h>
#include <WFX/scene/BoundingVolume.h>

namespace WFX {

    namespace math {

        class Cube;
        
        /**
         * a sphere in 3D space
         * implements BoundingVolume interface
         */
        class Sphere : public WFX::scene::BoundingVolume {
            public:
                /**
                 * Ctor/Dtor
                 * @param: c - center point
                 * @param: r - radius
                 */
                Sphere(math::Vector3& c, Real r) {
                    Center = c;
                    Radius = r;
                }
                Sphere() {
                    Center = math::Vector3::ZERO;
                    Radius = 0.0f;
                }
                virtual ~Sphere() {} 

                /** implement Boudningvolume interface */
                void transformBy(math::Matrix3& rot, math::Vector3& trans, Real scale);
                void computeFromVertices(UInt count, math::Vector3* verts);
                math::Plane::Side whichSide(const math::Plane& plane) const;
                BoundingVolume* copy();
                void merge(BoundingVolume* bv);
                void mergeMe(BoundingVolume* bv);
                void mergeSphere(math::Sphere& s);
                void mergeCube(math::Cube& c);
                void printDebug();

                /** member access */
                math::Vector3& getCenter() {
                    return Center;
                }
                Real getRadius() {
                    return Radius;
                }
                
                /**  implement Drawable interface */
                void draw(WFX::renderer::Renderer* r);
                /** accept a SceneGraphVisitor */
                void accept(WFX::scene::SceneGraphVisitor* v);
            protected:
                /** Center point */
                math::Vector3 Center;
                /** radius */
                Real Radius;
                 
                
        };

    }

}


#endif //include guard


