00001
00023 #ifndef INC_GRE_3DFILTER_H
00024 #define INC_GRE_3DFILTER_H
00025
00026 #ifndef INC_GRE_3DTEXTUR_H
00027 #include <gre/3dtextur.h>
00028 #endif
00029
00030 namespace GRE {
00031
00033 class TEXTUREFILTER {
00034 public:
00035
00036 enum MODE {
00037 MODE_None = 0,
00038 MODE_NearestNeighbor = 1,
00039 MODE_Bilinear = 2,
00040 MODE_UpperMipMapNearestNeighbor = 3,
00041 MODE_LowerMipMapBilinear = 4,
00042 MODE_MipMapTrilinear = 5,
00043 MODE_MipMapAnisotropic = 6
00044 };
00045
00046 TEXTUREFILTER (
00047 ) :
00048 m_IsSet(false),
00049 m_Mode(MODE_None),
00050 m_AnisotropicLimit(2),
00051 m_MipMapSharpness(50),
00052 m_MipMapBluriness(0.50),
00053 m_Texture(0),
00054 m_Scene(0),
00055 m_ScreenPlane(0)
00056 {
00057 }
00058
00059 ~TEXTUREFILTER (
00060 ) {}
00061
00063 void SetScene (
00064 SCENE3D* scene
00065 ) { m_Scene = scene; CheckSet(); return; }
00066
00068 void SetTexture (
00069 TEXTURE* texture
00070 ) { m_Texture = texture; CheckSet(); return; }
00071
00073 void SetScreenPlane (
00074 SCREENPLANE* plane
00075 ) { m_ScreenPlane = plane; CheckSet(); return; }
00076
00078 void SetMode (
00079 const MODE& mode
00080 ) { m_Mode = mode; CheckSet(); return; }
00081
00085 MODE GetMode (
00086 ) const { return m_Mode; }
00087
00091 bool GetColor (
00092 const DPOINT3D& point,
00093 const INT32 line,
00094 const INT32 column,
00095 COLOR& color
00096 );
00097
00101 bool GetColor (
00102 const INT32 line,
00103 const INT32 column,
00104 COLOR & color
00105 );
00106
00110 bool IsSet (
00111 ) { return m_IsSet; }
00112
00114 void SetAnisotropicLimit (
00115 const UINT8 limit
00116 ) { m_AnisotropicLimit = ((limit < 2) ? 2 : ((limit > 64) ? 64 : limit)); return; }
00117
00119 void SetMipMapSharpness (
00120 const UINT8 sharpness
00121 ) {
00122 m_MipMapSharpness = ((sharpness > 100) ? 100 : sharpness);
00123 m_MipMapBluriness = 0.01 * (100 - m_MipMapSharpness);
00124 return;
00125 }
00126
00127 private:
00128 #ifndef GENERATING_DOXYGEN_OUTPUT
00129
00130 MODE m_Mode;
00131 TEXTURE* m_Texture;
00132 SCENE3D* m_Scene;
00133 SCREENPLANE* m_ScreenPlane;
00134
00135 UINT8 m_AnisotropicLimit;
00136 UINT8 m_MipMapSharpness;
00137 double ALIGN8(m_MipMapBluriness);
00138
00139 bool m_IsSet;
00140
00141 void CheckSet (
00142 );
00143
00144 bool GetDepth (
00145 const INT32 line,
00146 const INT32 column,
00147 UINT8& depth,
00148 double& fraction
00149 );
00150
00151 bool CalculateDepth (
00152 const double value,
00153 UINT8& depth,
00154 double& fraction
00155 );
00156
00157 bool GetNearestNeighborColor (
00158 const DPOINT2D& point,
00159 const UINT8 depth,
00160 COLOR& color
00161 );
00162
00163 bool GetBilinearColor (
00164 const DPOINT2D& point,
00165 const UINT8 depth,
00166 COLOR& color
00167 );
00168
00169 bool GetTrilinearColor (
00170 const DPOINT2D& point,
00171 const UINT8 depth,
00172 const double fraction,
00173 COLOR& color
00174 );
00175
00176 bool GetAnisotropicColor (
00177 const INT32 line,
00178 const INT32 column,
00179 const DPOINT2D& point,
00180 COLOR& color
00181 );
00182
00183 #endif
00184 };
00185
00186 };
00187
00188 #endif
00189