/////////////////////////////////////////////////////////////////////////
//                                                                     //
// This file contains the declaration of the CSphere class.            //
//                                                                     //
/////////////////////////////////////////////////////////////////////////
#ifndef __CSPHERE_HPP__
#define __CSPHERE_HPP__


#include "CVector.hpp"
#include "CConcreteSurface.hpp"


/////////////////////////////////////////////////////////////////////////
//                                                                     //
// This class is an implementation of the CSurface interface that      //
// represents a sphere in the scene.                                   //
//                                                                     //
/////////////////////////////////////////////////////////////////////////
class CSphere : public CConcreteSurface
{
public:
  CSphere(const std::string& strName);

  // Interface implementation
  inline virtual CSphere* Copy() const;
  virtual void Preprocess();
  virtual void Normal(const CVector& hit, CVector& normal) const;

  // For shader generation
  virtual void GenerateShaderForObject(std::ostream& o) const;
  static  void generateShaderForClass(std::ostream& o);

protected:
  virtual int  Intersect(const CRay& ray, hitcontainer& hits) const;
  virtual void ConcreteDrawGL() const;

private:
  ////////////////
  // Propreties //
  ////////////////

  // Center of the sphere
  CVector m_PropCenter;
  // Radius of the sphere;
  real_t  m_PropRadius;
  // Precision of the GL generated sphere in one dimension
  int     m_PropPrecisionU;
  // Precision of the GL generated sphere in the other dimension
  int     m_PropPrecisionV;

  // Threshold for comparaison between real values
  real_t  m_PropSmallReal;

  virtual void DrawFace() const;
};




inline CSphere* CSphere::Copy() const
{
  return new CSphere(*this);
}

#endif // __CSPHERE_HPP__
