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
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076 #ifndef INC_GRE_3DTEXTUR_H
00077 #define INC_GRE_3DTEXTUR_H
00078
00079 #ifndef INC_GRE_BASE_H
00080 #include <gre/base.h>
00081 #endif
00082
00083 #ifndef INC_GRE_3DUTILS_H
00084 #include <gre/3dutils.h>
00085 #endif
00086
00087 #ifndef INC_GRE_3DSCENE_H
00088 #include <gre/3dscene.h>
00089 #endif
00090
00091 #ifndef INC_MI32_MGD2_H
00092 #include <mi32/mgd2.h>
00093 #endif
00094
00095 namespace GRE {
00096
00097 #ifndef GENERATING_DOXYGEN_OUTPUT
00098 class TEXTURE_IMPL_FACTORY;
00099 class TEXTUREFILTER;
00100 class CONTROLLER;
00101 class TERRAIN;
00102 class DRAWINGCONTEXT3D;
00103 class BOUNDPARM;
00104 #endif // GENERATING_DOXYGEN_OUTPUT
00105
00106
00107 class TEXTURE {
00108 public:
00109
00110 class IMPL_FACTORY {
00111 public:
00112 virtual TEXTURE *v_ConstructImpl () = 0;
00113 };
00114
00115 #define DECLARE_TEXTURE_IMPL_FACTORY(name,model) \
00116 class TEXTURE_IMPL_FACTORY_##name : public GRE::TEXTURE::IMPL_FACTORY { \
00117 public: \
00118 TEXTURE_IMPL_FACTORY_##name ( \
00119 ) { GRE::TEXTURE::Register(this,model); } \
00120 virtual GRE::TEXTURE *v_ConstructImpl () { \
00121 return (new GRE::name); \
00122 } \
00123 }; \
00124 static TEXTURE_IMPL_FACTORY_##name s_TextureImplFactory_##name;
00125
00126 enum MODEL {
00127 MODEL_Default = 0,
00128 MODEL_SimpleRaster = 0,
00129 MODEL_Formula = 1,
00130 MODEL_Count = 2
00131 };
00132
00133
00134 static void Register (
00135 IMPL_FACTORY* factory,
00136 const MODEL model
00137 );
00138
00139
00140
00141
00142 static const char* GetName (
00143 MODEL model
00144 );
00145
00146
00147
00148
00149 static const char* GetDescription (
00150 MODEL model
00151 );
00152
00153
00154
00155
00156 static TEXTURE* GetInstance (
00157 MODEL model
00158 );
00159
00160 virtual ~TEXTURE (
00161 );
00162
00163
00164
00165
00166 const char* GetName (
00167 ) const;
00168
00169
00170
00171
00172 const char* GetDescription (
00173 ) const;
00174
00175
00176
00177
00178 const MODEL GetModel (
00179 ) const {return m_Model; };
00180
00181
00182
00183
00184 TEXTURE* CreateInstance (
00185 ) { return v_CreateInstance(); };
00186
00187
00188
00189
00190 ERRVALUE Build (
00191 const GRE_LAYER* layer
00192 ) { return v_Build(layer); };
00193
00194
00195 void Free (
00196 ) { v_Free(); return; };
00197
00198
00199
00200
00201 bool IsBuilt (
00202 );
00203
00204
00205 void Begin (
00206 const SCENE3D& scene
00207 ) { v_Begin(scene); return; };
00208
00209
00210 void End (
00211 ) { v_End(); return; };
00212
00213
00214
00215
00216 const DRECT2D& GetExtents (
00217 ) { return v_GetExtents(); };
00218
00219
00220 void SetCoordRefSys (
00221 const SPATREF::COORDREFSYS& CoordRefSys
00222 ) { SetPedestalCoordRefSys(CoordRefSys); v_SetCoordRefSys(CoordRefSys); return; };
00223
00224
00225 const SPATREF::COORDREFSYS GetCoordRefSys (
00226 ) { return v_GetCoordRefSys(); };
00227
00228
00229
00230
00231 bool GetColor (
00232 const INT32 line,
00233 const INT32 column,
00234 const UINT8 depth,
00235 COLOR& color
00236 ) { return v_GetColor(line, column, depth, color); };
00237
00238
00239
00240
00241 bool GetColor (
00242 const DPOINT2D& point,
00243 const UINT8 depth,
00244 COLOR& color
00245 ) { return v_GetColor(point, depth, color); };
00246
00247
00248
00249
00250 UINT8 CheckDepth (
00251 const UINT8 depth
00252 ) { return v_CheckDepth(depth); };
00253
00254
00255
00256
00257 const TRANS2D_MAPGEN& GetTransformationInternalToModel (
00258 ) { return v_GetTransformationInternalToModel(); };
00259
00260
00261
00262
00263 ERRVALUE SetBoundaryWall (
00264 const SCENE3D& scene,
00265 TERRAIN* terrain
00266 );
00267
00268
00269
00270
00271 ERRVALUE DrawBoundaryWall (
00272 CONTROLLER &controller,
00273 DRAWINGCONTEXT3D& drawing,
00274 GRE::BOUNDPARM& boundparm
00275 );
00276
00277 const REGION2D& GetBoundary (
00278 ) {
00279 if (m_Boundary.IsEmpty()) v_CreateBoundary(m_Boundary);
00280 return m_Boundary;
00281 };
00282
00283
00284 void ClearPedestal (
00285 ) {
00286 m_PolyLineList.Clear();
00287 return;
00288 };
00289
00290
00291 void ClearBoundary (
00292 ) {
00293 m_Boundary.Clear();
00294 return;
00295 };
00296
00297 bool IsBoundaryChanged (
00298 ) const {
00299 return m_Boundary.IsEmpty();
00300 };
00301
00302 protected:
00303
00304 TEXTURE (
00305 const char* name,
00306 const char* desc,
00307 const MODEL model
00308 );
00309
00310
00311 void SetBuilt (
00312 const bool built
00313 );
00314
00315 private:
00316
00317 #ifndef GENERATING_DOXYGEN_OUTPUT
00318
00319 typedef SIMPLE_ARRAY<INT32> BASEINDEX;
00320 typedef MILIST<BASEINDEX> BASEINDEXLIST;
00321
00322 static IMPL_FACTORY* s_ImplFactories[MODEL_Count];
00323
00324 const char* m_Name;
00325 const char* m_Description;
00326 const MODEL m_Model;
00327
00328 bool m_Built;
00329
00330 REGION2D m_Boundary;
00331
00332 REGION2D m_FinalBoundary;
00333 POLYLINELIST m_PolyLineList;
00334 BASEINDEXLIST m_BaseIndexList;
00335 SPATREF::COORDREFSYS m_PolyLineCoordRefSys;
00336 TRIANGULATION m_Triangulation;
00337 SCENE3D *m_Scene;
00338
00339 TEXTURE (
00340 );
00341
00342 TEXTURE (
00343 const TEXTURE &rhs
00344 );
00345
00346 TEXTURE& operator= (
00347 const TEXTURE& rhs
00348 );
00349
00350 #endif // GENERATING_DOXYGEN_OUTPUT
00351
00352 void SetPedestalCoordRefSys (
00353 const SPATREF::COORDREFSYS& CoordRefSys
00354 );
00355
00356 virtual TEXTURE* v_CreateInstance (
00357 ) = 0;
00358
00359 virtual ERRVALUE v_Build (
00360 const GRE_LAYER *layer
00361 ) = 0;
00362
00363 virtual void v_Free (
00364 ) = 0;
00365
00366 virtual void v_Begin (
00367 const SCENE3D& scene
00368 ) = 0;
00369
00370 virtual void v_End (
00371 ) = 0;
00372
00373 virtual const DRECT2D& v_GetExtents (
00374 ) = 0;
00375
00376 virtual void v_CreateBoundary (
00377 REGION2D& boundary
00378 ) = 0;
00379
00380 virtual void v_SetCoordRefSys (
00381 const SPATREF::COORDREFSYS& CoordRefSys
00382 ) = 0;
00383
00384 virtual const SPATREF::COORDREFSYS v_GetCoordRefSys (
00385 ) = 0;
00386
00387 virtual bool v_GetColor (
00388 const INT32 line,
00389 const INT32 column,
00390 const UINT8 depth,
00391 COLOR& color
00392 ) = 0;
00393
00394 virtual bool v_GetColor (
00395 const DPOINT2D& point,
00396 const UINT8 depth,
00397 COLOR& color
00398 ) = 0;
00399
00400 virtual UINT8 v_CheckDepth (
00401 const UINT8 depth
00402 ) = 0;
00403
00404 virtual const TRANS2D_MAPGEN& v_GetTransformationInternalToModel (
00405 ) = 0;
00406
00407 };
00408
00409 }
00410
00411 #endif
00412
00413
00414