gre/3dfilter.h

Go to the documentation of this file.
00001 /**
00002  * \file 3dfilter.h <gre/3dfilter.h>
00003  * \brief 
00004  *
00005  * \if NODOC
00006  * $Id: 3dfilter.h_v 1.7 2004/12/01 16:26:05 vdronov Exp $
00007  *
00008  * $Log: 3dfilter.h_v $
00009  * Revision 1.7  2004/12/01 16:26:05  vdronov
00010  *       double ALIGN8(m_MipMapBluriness);   //!< 0.50
00011  *
00012  * Revision 1.6  2004/08/11 22:59:51  vdronov
00013  * *** empty log message ***
00014  *
00015  * Revision 1.5  2003/09/15 13:48:59  fileserver!dwilliss
00016  * Doxygen
00017  *
00018  * Revision 1.4  2003/08/15 20:33:13  vdronov
00019  * add docs.
00020  *
00021  * Revision 1.3  2003/07/30 13:45:09  mju
00022  * Check inclusion guards.
00023  * Ignore private section.
00024  *
00025  * Revision 1.2  2003/04/10 17:51:48  vdronov
00026  * added MipMapSharpness
00027  *
00028  * Revision 1.1  2003/03/10 15:05:32  vdronov
00029  * Initial revision
00030  * \endif
00031 **/ 
00032 
00033 #ifndef  INC_GRE_3DFILTER_H
00034 #define  INC_GRE_3DFILTER_H
00035 
00036 #ifndef  INC_GRE_3DUTILS_H
00037 #include <gre/3dutils.h>
00038 #endif
00039 
00040 #ifndef  INC_GRE_3DSCENE_H
00041 #include <gre/3dscene.h>
00042 #endif
00043 
00044 #ifndef  INC_GRE_3DTEXTUR_H
00045 #include <gre/3dtextur.h>
00046 #endif
00047 
00048 namespace GRE {
00049 
00050 //! TEXTUREFILTER class provides several texture filter algorithms
00051 class TEXTUREFILTER {
00052    public:
00053 
00054       enum MODE {
00055          MODE_None = 0,
00056          MODE_NearestNeighbor = 1,
00057          MODE_Bilinear = 2,
00058          MODE_UpperMipMapNearestNeighbor = 3,
00059          MODE_LowerMipMapBilinear = 4,
00060          MODE_MipMapTrilinear = 5,
00061          MODE_MipMapAnisotropic = 6
00062          };
00063 
00064       TEXTUREFILTER (                                 //! Constructor 
00065          ) :
00066          m_IsSet(false),
00067          m_Mode(MODE_None),
00068          m_AnisotropicLimit(2),
00069          m_MipMapSharpness(50),
00070          m_MipMapBluriness(0.50),
00071          m_Texture(0),
00072          m_Scene(0),
00073          m_ScreenPlane(0)
00074          {
00075          }
00076 
00077       ~TEXTUREFILTER (                                //! Destructor 
00078          ) {}
00079 
00080       //! Set scene
00081       void SetScene (
00082          SCENE3D* scene
00083          ) { m_Scene = scene; CheckSet(); return; }
00084 
00085       //! Set texture to be filtered
00086       void SetTexture (
00087          TEXTURE* texture
00088          ) { m_Texture = texture; CheckSet(); return; }
00089 
00090       //! Set screen plane
00091       void SetScreenPlane (
00092          SCREENPLANE* plane
00093          ) { m_ScreenPlane = plane; CheckSet(); return; }
00094 
00095       //! Set texture filter mode
00096       void SetMode (
00097          const MODE& mode
00098          ) { m_Mode = mode; CheckSet(); return; }
00099 
00100       //! Get texture filter mode
00101       //!
00102       //! @return current texture filter mode
00103       MODE GetMode (
00104          ) const { return m_Mode; }
00105 
00106       //! Get color for given screen pixel and its corresponding model point
00107       //!
00108       //! @return true if color was retrived
00109       bool GetColor (
00110          const DPOINT3D& point,
00111          const INT32 line,
00112          const INT32 column,
00113          COLOR& color
00114          );
00115 
00116       //! Get color for given screen pixel
00117       //!
00118       //! @return true if color was retrived
00119       bool GetColor (
00120          const INT32 line,
00121          const INT32 column,
00122          COLOR & color
00123          );
00124 
00125       //! Is texture filter set
00126       //!
00127       //! @return true if texture filter is set
00128       bool IsSet (
00129          ) { return m_IsSet; }
00130 
00131       //! Set anisatropic filter limit in range [2, 64]
00132       void SetAnisotropicLimit (
00133          const UINT8 limit
00134          ) { m_AnisotropicLimit = ((limit < 2) ? 2 : ((limit > 64) ? 64 : limit)); return; }
00135 
00136       //! Set mipmap sharpnes in range [0, 100]
00137       void SetMipMapSharpness (
00138          const UINT8 sharpness
00139          ) { 
00140          m_MipMapSharpness = ((sharpness > 100) ? 100 : sharpness); 
00141          m_MipMapBluriness = 0.01 * (100 - m_MipMapSharpness);
00142          return; 
00143          }
00144 
00145    private:
00146       #ifndef GENERATING_DOXYGEN_OUTPUT
00147 
00148       MODE m_Mode;
00149       TEXTURE* m_Texture;
00150       SCENE3D* m_Scene;
00151       SCREENPLANE* m_ScreenPlane;
00152 
00153       UINT8 m_AnisotropicLimit;
00154       UINT8 m_MipMapSharpness;         //!< 50
00155       double ALIGN8(m_MipMapBluriness);   //!< 0.50
00156 
00157       bool m_IsSet;
00158 
00159       void CheckSet (
00160          );
00161 
00162       bool GetDepth (
00163          const INT32 line,
00164          const INT32 column,
00165          UINT8& depth,
00166          double& fraction
00167          );
00168 
00169       bool CalculateDepth (
00170          const double value,
00171          UINT8& depth,
00172          double& fraction
00173          );
00174 
00175       bool GetNearestNeighborColor (
00176          const DPOINT2D& point,
00177          const UINT8 depth,
00178          COLOR& color 
00179          );
00180 
00181       bool GetBilinearColor (
00182          const DPOINT2D& point,
00183          const UINT8 depth,
00184          COLOR& color 
00185          );
00186 
00187       bool GetTrilinearColor (
00188          const DPOINT2D& point,
00189          const UINT8 depth,
00190          const double fraction,
00191          COLOR& color 
00192          );
00193 
00194       bool GetAnisotropicColor (
00195          const INT32 line,
00196          const INT32 column,
00197          const DPOINT2D& point,
00198          COLOR& color 
00199          );
00200 
00201    #endif //!< GENERATING_DOXYGEN_OUTPUT
00202    };
00203 
00204 };    //! End of namespace
00205 
00206 #endif
00207 

Generated on Thu Apr 26 04:03:28 2007 for TNTsdk by  doxygen 1.5.2