/////////////////////////////////////////////////////////////////////////
//                                                                     //
// This file contains the declaration of the CPlane class.             //
//                                                                     //
/////////////////////////////////////////////////////////////////////////
#ifndef __CPLANE_HPP__
#define __CPLANE_HPP__


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


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

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

  // Normal vector of the plane
  CVector m_PropNormal;
  // Constant representing the distance from the origin
  real_t  m_PropConstant;
  // Scaling factor of the plane (size of the plane)
  real_t  m_PropSize;
  // Precision of the GL generated plane in one dimension
  int     m_PropPrecisionU;
  // Precision of the GL generated plane in the other dimension
  int     m_PropPrecisionV;
};




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

#endif // __CPLANE_HPP__
