00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
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
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 (
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 (
00075 ) {}
00076
00077
00078 void SetScene (
00079 SCENE3D* scene
00080 ) { m_Scene = scene; CheckSet(); return; }
00081
00082
00083 void SetTexture (
00084 TEXTURE* texture
00085 ) { m_Texture = texture; CheckSet(); return; }
00086
00087
00088 void SetScreenPlane (
00089 SCREENPLANE* plane
00090 ) { m_ScreenPlane = plane; CheckSet(); return; }
00091
00092
00093 void SetMode (
00094 const MODE& mode
00095 ) { m_Mode = mode; CheckSet(); return; }
00096
00097
00098
00099
00100 MODE GetMode (
00101 ) const { return m_Mode; }
00102
00103
00104
00105
00106 bool GetColor (
00107 const DPOINT3D& point,
00108 const INT32 line,
00109 const INT32 column,
00110 COLOR& color
00111 );
00112
00113
00114
00115
00116 bool GetColor (
00117 const INT32 line,
00118 const INT32 column,
00119 COLOR & color
00120 );
00121
00122
00123
00124
00125 bool IsSet (
00126 ) { return m_IsSet; }
00127
00128
00129 void SetAnisotropicLimit (
00130 const UINT8 limit
00131 ) { m_AnisotropicLimit = ((limit < 2) ? 2 : ((limit > 64) ? 64 : limit)); return; }
00132
00133
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;
00152 double m_MipMapBluriness;
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
00199 };
00200
00201 };
00202
00203 #endif
00204