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