// -*- C++ -*-
#ifndef RIMAYATEXTURE_H
#define RIMAYATEXTURE_H
/* Copyright 1998 
 * Thu Jul 29 10:55:30 1999  Brian Smits  (bes@phoenix.cs.utah.edu)
 * 
 * RiMayaTexture.H
 * 
 *	
 * 
 * $Id: RiMayaTexture.H,v 1.1 1999/10/01 19:33:43 bes Exp $ 
 * 
 */
#ifndef RICOMMON_H
#include <RiCommon.H>
#endif

#ifndef RITEXTURE_H
#include <RiTexture.H>
#endif

#ifndef RIAFFINETMATRIX2_H
#include <RiAffineTMatrix2.H>
#endif

/***************************************************************
CLASS
    RiMayaTexture
     Holds the color modifiers common to all maya textures.

DESCRIPTION
     <Detailed description with any warnings>

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

class RiMayaTexture : public RiTexture {
  public:
				// GROUP: Constructors and assignment
				//// Default Constructor
    RiMayaTexture();
				// GROUP: Accessors
				// GROUP: General Color properties
				//// For when the texture doesn't cover a point
    void SetDefaultColor(const RiVector3 &rgbDefault);
				//// For when the texture doesn't cover a point
    RiVector3 GetDefaultColor();
				//// Multiplied result by this
    void SetColorGain(const RiVector3 &rgbGain);
				//// Add this after gain
    void SetColorOffset(const RiVector3 &rgbOffset);
				//// Invert the result (before color balancing) defaults to OFF
    void SetInvertColor(bool on);
				////  Maya textures live in RGB land. Call the GetVector3 and convert 
    virtual RiSpectrum GetSpectrum(RiMaterialRegion &hit);
  protected:
				////
    RiVector3 DoColorCorrection(RiVector3 rgb);
  private:
				////
    RiVector3 defaultClr, gain, offset;
				////
    bool invertResult;
};



/***************************************************************
CLASS
    Ri2DMayaTexture
     Base class for maya 2d textures (handles 2dtexturePlacement data)

DESCRIPTION
     As of now, noise is not being used.

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

class Ri2DMayaTexture : public RiMayaTexture {
  public:
				// GROUP: Constructors and assignment
				//// Default Constructor
    Ri2DMayaTexture();
				// GROUP: place2DTexture stuff
				//// set the transform for the clipping window
    void SetWindowTransform(const RiAffineTMatrix2 &wTrans);
				//// set the transform on the surface
    void SetPlacementTransform(const RiAffineTMatrix2 &trans);
				//// set the mirror flag (defaults to OFF)
    void SetMirror(bool on);
				//// wrap instead of clip when outside coverage window.
    void SetWrap(bool onU, bool onV);
				//// stagger (offset every other row of V by .5) defaults to OFF
    void SetStagger(bool on);
				//// Not sure exactly what this means (3D noise to UV delta?  2D to UV delta?)
    void SetNoise(const RiVector2 &amount);
  protected:
				//// return false if uv is outside coverage window
    bool DoTransform(RiMaterialRegion &hit, RiVector2 &newUV);
  private:
				////
    RiAffineTMatrix2 trans;
				////
    RiAffineTMatrix2 wTrans;
				////
    bool mirror, stagger, wrapU, wrapV;
				//// not used yet
    RiVector2 noiseDisp;
};


/***************************************************************
CLASS
    Ri3DMayaTexture
     Base class for maya 2d textures (handles 2dtexturePlacement data)

DESCRIPTION
     As of now, noise is not being used.

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

class Ri3DMayaTexture : public RiMayaTexture {
  public:
				// GROUP: Constructors and assignment
				//// Default Constructor
    Ri3DMayaTexture();
				// GROUP: place3DTexture stuff
				//// set the transform on the surface
    void SetPlacementTransform(const RiAffineTMatrix3 &trans);
  protected:
				//// return false if uv is outside coverage window
    RiVector3 DoTransform(RiMaterialRegion &hit);
  private:
				////
    RiAffineTMatrix3 trans;
};


/***************************************************************
CLASS
    Ri2DCheckerTexture
     <one line summary> 

DESCRIPTION
     <Detailed description with any warnings>

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

class Ri2DCheckerTexture : public Ri2DMayaTexture {
  public:
				// GROUP: Constructors and assignment
				//// Default Constructor
    Ri2DCheckerTexture(const RiVector3TextureProxy &color1, const RiVector3TextureProxy &color2,
		       const RiScalarTextureProxy &contrast);
				// GROUP: Members
    				////
    virtual RiReal GetScalar(RiMaterialRegion &hit);
				////
    virtual RiVector2 GetVector2(RiMaterialRegion &hit);
				////
    virtual RiVector3 GetVector3(RiMaterialRegion &hit);
  private:
				////
    RiVector3TextureProxy clr1, clr2;
				////
    RiScalarTextureProxy contrast;
};


/***************************************************************
CLASS
    Ri2DRampTexture
     <one line summary> 

DESCRIPTION
     <Detailed description with any warnings>

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

class Ri2DRampTexture : public Ri2DMayaTexture {
  public:
				// GROUP: Constructors and assignment
				//// Default Constructor  (adopts the two vectors)
    Ri2DRampTexture(int rampType, int interpType,
		    RiReal *positions, RiVector3TextureProxy *colors, int numVals);
				// GROUP: Members
    				////
    virtual RiReal GetScalar(RiMaterialRegion &hit);
				////
    virtual RiVector2 GetVector2(RiMaterialRegion &hit);
				////
    virtual RiVector3 GetVector3(RiMaterialRegion &hit);
  private:
				////
    RiVector3	Interp(RiReal val, RiMaterialRegion &hit);
				////
    int rampType, interpType, numVals;
				////
    RiReal 		  *positions;
				////
    RiVector3TextureProxy *colors;

};


/***************************************************************
CLASS
    RiFileTexture
     <one line summary> 

DESCRIPTION
     <Detailed description with any warnings>

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

class RiFileTexture : public Ri2DMayaTexture {
  public:
				// GROUP: Constructors and assignment
				//// Default Constructor  img is an array of width * height * 4
				// characters (RGBA)
    RiFileTexture(unsigned char *img, int width, int height);
				// GROUP: Members
    				////  Returns the alpha value
    virtual RiReal GetScalar(RiMaterialRegion &hit);
				////  Returns the 2D gradiant value
    virtual RiVector2 GetVector2(RiMaterialRegion &hit);
				////  Returns the color value
    virtual RiVector3 GetVector3(RiMaterialRegion &hit);
  private:
				////
    int width, height;
				////
    unsigned char *img;
};



#ifdef UNDEF
/***************************************************************
CLASS
    RiProjectionTexture
     <one line summary> 

DESCRIPTION
     <Detailed description with any warnings>

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

class RiProjectionTexture : public Ri3DMayaTexture {
  public:
    enum Type = {off};
				// GROUP: Constructors and assignment
				//// Default Constructor
    RiProjectionTexture(const RiVector3TextureProxy &color, RiProjectionTexture::Type type);
				// GROUP: Members
    				////
    virtual RiReal GetScalar(RiMaterialRegion &hit);
				////
    virtual RiVector2 GetVector2(RiMaterialRegion &hit);
				////
    virtual RiVector3 GetVector3(RiMaterialRegion &hit);
  protected:
    void DoProjection(RiMaterialRegion &hit);
  private:
				////
    RiVector3TextureProxy clr1, clr2;
				////
    RiScalarTextureProxy contrast;
};






#endif

#endif /* RIMAYATEXTURE_H */

