/////////////////////////////////////////////////////////////////////////
//                                                                     //
// This file contains the declaration of the CQuadric class.           //
//                                                                     //
/////////////////////////////////////////////////////////////////////////
#ifndef __CQUADRIC_HPP__
#define __CQUADRIC_HPP__


#include "CConcreteSurface.hpp"


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

  // Interface implementation
  inline virtual CQuadric* 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 //
  ////////////////

  // Quadratic factors of the quadric
  CVector m_PropQuadratic;
  // Linear factors of the quadric
  CVector m_PropLinear;
  // Mix factors of the quadric
  CVector m_PropMix;
  // Constant factor of the quadric
  real_t  m_PropConstant;

  // Threshold for comparaison between real values
  real_t  m_PropSmallReal;
};




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

#endif // __CQUADRIC_HPP__
