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

Generated on Tue Dec 14 13:18:11 2004 for TNTsdk by  doxygen 1.3.8-20040913