#ifndef RITHINLENSCAMERA_H
#define RITHINLENSCAMERA_H


#ifndef RICAMERA_H
#include <RiCamera.H>
#endif

#ifndef RIRAY3_H
#include <RiRay3.H>
#endif

#ifndef RIVECTOR2_H
#include <RiVector2.H>
#endif

#ifndef RIONB3_H
#include <RiONB3.H>
#endif


/***************************************************************
CLASS
    RiThinLensCamera
    A simple thin-lens camera which generates rays.

DESCRIPTION
    Given a lens center, diameter, ONB, and a distance to the plane where
    all things are in focus, along with a coordinate bound on that plane,
    gives machinery to generate a ray.

****************************************************************/



class RiThinLensCamera : public RiRayCamera {
  public:

                                //// General constructor
				// [lCenter] lens center (eye point)
				// [uvw] the ONB, where V is the up-vector and W points opposite the
                                //    view-plane normal (towards the eye)
				// [distanceToFoc] is the distance to the plane where objects are in focus
				// [uvmin,uvmax] are the bounds of the image in the plane of focus.
				// [lensDiam] is the diameter of the lens.
    RiThinLensCamera( const RiVector3 &lCenter,  const RiONB3 &uvw,   RiReal distanceToFoc,
		      const RiVector2 &uvmin, const RiVector2 &uvmax, RiReal lensDiam = 0, RiReal front = 0);
				//// More natural constructor.  Up is +Y direction.  This should
				// probably be a parameter.
				// [lCenter] eye point or center of the lens
				// [lookAt] Point being looked at.  Defines the distance to focal plane
				// [fovDeg] Total viewing angle in degrees for the width of the film plane.
				// [aspectRation] ratio of width to height
				// [lensDiam]  The diameter of the lens
				// [front]  Distance to front clipping plane
    RiThinLensCamera(const RiVector3 &lCenter, const RiVector3 &lookAt,
		     RiReal fovDeg = 45, RiReal aspectRatio = 1.0,
		     RiReal lensDiam = 0.0, RiReal front = 0.0);
				//// Constructor for real camera emulation.
				// []lCenter eye point or center of the lens
				// []uvw the ONB, where V is the up-vector and W points opposite the
                                //    view-plane normal (towards the eye)
				// []distanceToFoc is the distance to the plane where objects are in focus
				// []focalLength  focalLength of lens
				// []fnumber  Ratio of focal-length to the diameter of the lens
				// []wfilm,hfilm  width and height of film
				// []cxfilm,cyfilm offset of optical axis from film center (0.2,0.3) would
				// []front  Distance to front clipping plane
                                //    be to the right and up in the final viewed picture
    RiThinLensCamera(const RiVector3 &lCenter,  const RiONB3 &uvw,   RiReal distanceToFoc,
		     RiReal focalLength = 0.05, RiReal fnumber = 11,
                     RiReal wfilm = 0.036, RiReal hfilm = 0.24,
                     RiReal cxfilm = 0.0, RiReal cyfilm = 0.0, RiReal front = 0.0);
				//// Screen coord is in the range[0,1]^2.
				//  (0,0) is lower-left corner.  lensCoord
				// is a seed in [0,1]^2 for lens sampling.
    RiRay3 GetRay( const RiVector2& screenCoord, const RiVector2& lensCoord ) const;
				//// General manipulation of the camera.  Some cameras may
				// not allow a scale or perhaps even a rotation (Cylindrical panoramic),
				// these need to catch or ignore this component of the matrix.
    virtual void Transform(const RiAffineTMatrix3 &);
   protected:
      
      RiONB3 basis;
      RiVector3 cop;  // center-of-projection
      RiReal distanceToFocus;
      RiReal lensRadius;
      RiVector2 uvMin, uvMax, uvSize;
      RiReal frontClip;
};


#endif

