/** \defgroup Rendering Rendering classes */

/** @addtogroup Rendering
    @{
*/

/** @file CVectBase.h
    \brief This file contains the declaration of the CVectBase class.

    It represents a normalized vector base which will be used to
    ray-trace.
*/

#ifndef CVECTBASE_H
#define CVECTBASE_H

/**
   \brief This class represents a normalized vector base which will be
   used to ray-trace.

   It contains 3 vectors. One goes from the eye of the viewer to the
   center of the bounding box of the surface; another one is in the
   horizontal direction of the plane that represents the picture and
   throught which all the rays go; the last one is in the vertical
   direction of the plane that represents the picture and throught
   which all the rays go.  The radius of the bounding sphere is the
   radius of the smallest sphere that can hold the bounding box.
*/
class CVectBase
{
 public:
  /**
     \brief The CVectBase default constructor.
  */
  CVectBase();

  /**
     \brief The CVectBase constructor by parameters.
  */
  CVectBase(const CVector3f& viewerpos,
            const CVector3f& boxpos,
            float radius, bool update = true);


  /**
     \brief This function returns the first vector of the base.
  */
  inline const CVector3f& getB1() const { return m_B1; }

  /**
     \brief This function returns the second vector of the base.
  */
  inline const CVector3f& getB2() const { return m_B2; }

  /**
     \brief This function returns the third vector of the base.
  */
  inline const CVector3f& getB3() const { return m_B3; }

  /**
     \brief This function returns the radius of the bounding sphere.
  */
  inline float getRadius() const { return m_Radius; }

  /**
     \brief This function sets the position of the viewer.
  */
  void setViewerPos(const CVector3f& viewerpos, bool update = true)
    {
      m_ViewerPos = viewerpos;
      if (update)
        Update();
    }

  /**
     \brief This function sets the position of the center of the box.
  */
  void setBoxPos(const CVector3f& boxpos, bool update = true)
    {
      m_BoxPos = boxpos;
      if (update)
        Update();
    }

  /**
     \brief This function sets the radius of the bounding sphere
     of the surface.
  */
  void setRadius(float radius) { m_Radius = radius; }

  /**
     \brief This function recalculate the three vectors of the base.
  */
  void Update(void);

 private:
  CVector3f m_B1;  /**< Direction of the looking vector. */
  CVector3f m_B2;  /**< Horizontal picture vector. */
  CVector3f m_B3;  /**< Vertical picture vector. */
  float m_Radius;  /**< Radius of the bounding sphere of the surface. */

  CVector3f m_ViewerPos;  /**< Position of the viewer. */
  CVector3f m_BoxPos;     /**< Position of the center of the box. */
};

#endif

/** @} */
