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 #ifndef INC_GRE_3DDRYTER_H
00028 #define INC_GRE_3DDRYTER_H
00029
00030 #ifndef INC_GRE_3DTERRA_H
00031 #include <gre/3dterra.h>
00032 #endif
00033
00034 #ifndef INC_GRE_3DSCENE_H
00035 #include <gre/3dscene.h>
00036 #endif
00037
00038 #ifndef INC_MI32_ASURFACE_H
00039 #include <mi32/asurface.h>
00040 #endif
00041
00042 #ifndef INC_MI32_SIMPLEAR_H
00043 #include <mi32/simplear.h>
00044 #endif
00045
00046 #ifndef INC_RVC_OBJECT_H
00047 #include <rvc/object.h>
00048 #endif
00049
00050 #ifndef INC_RVC_GEOREFER_H
00051 #include <rvc/georefer.h>
00052 #endif
00053
00054 namespace GRE {
00055
00056
00057 class DENSERAYCASTING : public TERRAIN {
00058 public:
00059
00060 DENSERAYCASTING (
00061 );
00062
00063 ~DENSERAYCASTING (
00064 );
00065
00066 private:
00067 #ifndef GENERATING_DOXYGEN_OUTPUT
00068
00069 struct ORDER {
00070 INT32 index;
00071 float distance;
00072 };
00073
00074 struct INTERSECTION {
00075 const DOUBLE_ARRAY<double>& m_Buffer;
00076 const INT32 m_NumCells;
00077 const DPOINT3D m_Min;
00078 const DPOINT3D m_Max;
00079 const bool m_HasNullValue;
00080 const double m_NullValue;
00081 const DPOINT3D& m_Viewer;
00082 const DPOINT3D& m_Direction;
00083 const bool m_IsPerspective;
00084
00085 POLYLINE m_Polyline;
00086
00087 INTERSECTION (
00088 const DOUBLE_ARRAY<double>& buffer,
00089 const INT32 numCells,
00090 const DPOINT3D min,
00091 const DPOINT3D max,
00092 const bool hasNullValue,
00093 const double nullValue,
00094 const DPOINT3D& viewer,
00095 const DPOINT3D& direction,
00096 const bool isPerspective
00097 ) :
00098 m_Buffer(buffer),
00099 m_NumCells(numCells),
00100 m_Min(min),
00101 m_Max(max),
00102 m_HasNullValue(hasNullValue),
00103 m_NullValue(nullValue),
00104 m_Viewer(viewer),
00105 m_Direction(direction),
00106 m_IsPerspective(isPerspective)
00107 {
00108 };
00109
00110 };
00111
00112 #define NUMPIXELS 4096
00113
00114 #define NUMCORNERS 8
00115 #define NUMSEGMENTS 12
00116
00117 static const INT32 s_Segments[NUMSEGMENTS][2];
00118
00119 ABSTRACT_SURFACE *m_Surface;
00120 DRECT3D m_Extents;
00121 MAPPROJPARM m_MapProjParm;
00122 TRANS2D_MAPGEN m_Transformation;
00123
00124 RVC::RASTER m_Raster;
00125 DOUBLE_ARRAY<double> m_Buffer;
00126
00127 INT32 m_XBlocks;
00128 INT32 m_YBlocks;
00129 INT32 m_BlockSize;
00130 DOUBLE_ARRAY<DRECT3D> m_Blocks;
00131 INT32 m_Index;
00132 bool m_BlockIsLoaded;
00133 double m_CoverAreaFactor;
00134
00135 SIMPLE_ARRAY<ORDER> m_Orders;
00136
00137 BITSET m_ScreenBits;
00138 INT32 m_ScreenWidth;
00139 INT32 m_ScreenHeight;
00140 INT32 m_ScreenX;
00141 INT32 m_ScreenY;
00142
00143 SIMPLE_ARRAY<DPOINT3D> m_Points;
00144 SIMPLE_ARRAY<LPOINT2D> m_Pixels;
00145
00146 PIXALIZATION m_Pixalization;
00147 TRIANGULATION m_Triangulation;
00148
00149 SCENE3D *m_Scene;
00150 CONTROLLER *m_Controller;
00151 DRAWINGCONTEXT3D *m_Drawing;
00152
00153 DPOINT3D m_Viewer;
00154 DPOINT3D m_Direction;
00155
00156 double m_ZMin;
00157 double m_ZMax;
00158 bool m_HasNullValue;
00159 double m_NullValue;
00160
00161 DENSERAYCASTING& operator= (
00162 const DENSERAYCASTING& rhs
00163 );
00164
00165 static int OrderSort (
00166 ORDER* item1,
00167 ORDER* item2,
00168 void*
00169 ) { if (item1->distance < item2->distance) return 1; return 0; };
00170
00171 static void GetCorners (
00172 const DRECT3D& rect,
00173 DPOINT3DH points[8]
00174 );
00175
00176 static void GetCorners (
00177 const DRECT3D& rect,
00178 DPOINT3D points[8]
00179 );
00180
00181 static double CalculateElevation (
00182 INTERSECTION& intersection,
00183 const DPOINT3D& pt,
00184 const int type
00185 );
00186
00187 static bool GetIntersection (
00188 INTERSECTION& intersection,
00189 const DPOINT3D& lookAt,
00190 DPOINT3D& result
00191 );
00192
00193 static void GetTriangle (
00194 INTERSECTION& intersection,
00195 const DPOINT3D& point,
00196 DPOINT3D points[3]
00197 );
00198
00199 TERRAIN* v_CreateInstance (
00200 ) { return new DENSERAYCASTING(); };
00201
00202 ERRVALUE v_Build (
00203 const GRE_LAYER *layer
00204 );
00205
00206 bool v_IsObjectTypeSupported (
00207 const RVC::OBJTYPE objtype
00208 ) const { return (objtype == RVC::OBJTYPE_Raster); };
00209
00210 void v_Free (
00211 );
00212
00213 ERRVALUE Create (
00214 const GRE_LAYER *layer
00215 );
00216
00217 void Delete (
00218 );
00219
00220 ERRVALUE v_GetDefaultScene (
00221 SCENE3D& scene
00222 ) const;
00223
00224 ERRVALUE v_SetScene (
00225 const SCENE3D& scene,
00226 const SIMPLE_ARRAY<TEXTURE*> &textures
00227 );
00228
00229 ERRVALUE v_DrawScene (
00230 CONTROLLER &controller,
00231 DRAWINGCONTEXT3D& drawing,
00232 TEXTURE* texture,
00233 TEXTUREFILTER* texturefilter
00234 );
00235
00236 float v_GetElevation (
00237 const float x,
00238 const float y
00239 ) const;
00240
00241 float v_GetAngleToNorth (
00242 const float x,
00243 const float y
00244 ) const;
00245
00246 const ABSTRACT_SURFACE* v_GetAbstractSurface (
00247 ) { return m_Surface; }
00248
00249 void v_SetMapProjParm (
00250 const MAPPROJPARM& mapprojparm
00251 );
00252
00253 const MAPPROJPARM v_GetMapProjParm (
00254 ) const { return m_MapProjParm; };
00255
00256 const DRECT3D& v_GetExtents (
00257 ) { return m_Extents; };
00258
00259 bool v_HasNull (
00260 ) const { return m_HasNullValue; };
00261
00262 bool v_IsNull (
00263 const float x,
00264 const float y
00265 ) const;
00266
00267 ERRVALUE CreateBlocks (
00268 const TRANS2D_MAPGEN& transformation
00269 );
00270
00271 void DeleteBlocks (
00272 );
00273 ERRVALUE SetSceneForBlocks (
00274 const SCENE3D& scene,
00275 const SIMPLE_ARRAY<TEXTURE*> &textures
00276 );
00277
00278 ERRVALUE DrawSceneForBlocks (
00279 CONTROLLER &controller,
00280 DRAWINGCONTEXT3D& drawing,
00281 TEXTURE* texture,
00282 TEXTUREFILTER* texturefilter
00283 );
00284
00285 void TransformBlocks (
00286 const TRANS2D_MAPGEN& transformation
00287 );
00288
00289 void FillSpan (
00290 const INT32 col1,
00291 const INT32 col2,
00292 const INT32 lin
00293 );
00294
00295 void DrawPixels (
00296 );
00297
00298 #endif
00299 };
00300
00301 };
00302
00303 #endif
00304