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
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
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 (
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 (
00078 ) {}
00079
00080
00081 void SetScene (
00082 SCENE3D* scene
00083 ) { m_Scene = scene; CheckSet(); return; }
00084
00085
00086 void SetTexture (
00087 TEXTURE* texture
00088 ) { m_Texture = texture; CheckSet(); return; }
00089
00090
00091 void SetScreenPlane (
00092 SCREENPLANE* plane
00093 ) { m_ScreenPlane = plane; CheckSet(); return; }
00094
00095
00096 void SetMode (
00097 const MODE& mode
00098 ) { m_Mode = mode; CheckSet(); return; }
00099
00100
00101
00102
00103 MODE GetMode (
00104 ) const { return m_Mode; }
00105
00106
00107
00108
00109 bool GetColor (
00110 const DPOINT3D& point,
00111 const INT32 line,
00112 const INT32 column,
00113 COLOR& color
00114 );
00115
00116
00117
00118
00119 bool GetColor (
00120 const INT32 line,
00121 const INT32 column,
00122 COLOR & color
00123 );
00124
00125
00126
00127
00128 bool IsSet (
00129 ) { return m_IsSet; }
00130
00131
00132 void SetAnisotropicLimit (
00133 const UINT8 limit
00134 ) { m_AnisotropicLimit = ((limit < 2) ? 2 : ((limit > 64) ? 64 : limit)); return; }
00135
00136
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;
00155 double ALIGN8(m_MipMapBluriness);
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
00202 };
00203
00204 };
00205
00206 #endif
00207