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