mod_sim_terrain_tile.hh

Go to the documentation of this file.
00001 /*
00008  * LEGAL:   COPYRIGHT (C) 2007 JIM E. BROOKS
00009  *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
00010  *          OF THE GNU GENERAL PUBLIC LICENSE VERSION 2 (GPL 2).
00011  *****************************************************************************/
00012 
00013 #if COMPILING_MODULE
00014 #ifndef MOD_SIM_TERRAIN_TILE_HH
00015 #define MOD_SIM_TERRAIN_TILE_HH 1
00016 
00017 #include "eng_graph_maker.hh"
00018 
00019 namespace mod_sim {
00020 
00038 class TileFactory
00039 {
00040 
00041 public:
00042                     TileFactory( void );
00043                     ~TileFactory();
00044     void            Populate( const BoxVolume& quadrantBoxVolume, SharedPtr<Heightmap> heightmap );
00045 
00046 private:
00047     void            Reset( void );
00048     void            MakeTile( void );
00049     void            MakeLocalVertexs( void );
00050     void            MakeNormals( void );
00051     void            MakeTexture( void );
00052     void            MakeTriangles( void );
00053     void            MakeTrianglesTexCoords( const fp worldLat, const fp worldLon );
00054     void            MakeTileObject( void );
00055     NormalVertex    ComputePolygonNormalOfTriangle0( const fp worldLat, const fp worldLon );
00056     NormalVertex    ComputePolygonNormalOfTriangle1( const fp worldLat, const fp worldLon );
00057     NormalVertex    ComputeVertexNormal( const fp worldLat, const fp worldLon );
00058 
00059 private:
00061     struct TileArgs
00062     {
00063     
00064     public:
00065         TileArgs( const fp quadrantEdge );
00066         ~TileArgs();
00067 
00068         // Edge equals N = sqrt(NxN) of a rectangle.
00069         int     mTilesInQuadrantEdge;       
00070         int     mSubtilesInTileEdge;        
00071         int     mSubtilesInQuadrantEdge;
00072         fp      mTileWidthInWorld;          
00073         fp      mSubtileWidthInWorld;       
00074         fp      mSubtileWidthInWorldHalf;
00075         fp      mTileWidthInWorld_plus_subtileWidthInWorld;  
00076     };
00077 
00078 private:
00080     struct TileGraph
00081     {
00082                 TileGraph( void );
00083                 ~TileGraph();
00084         void    Reset( void );
00085 
00086         GraphMaker*                     mGraphMaker;
00087         GraphMaker::NodePredecessors*   mNodePredecessors;
00088         Array2D<LocalVertex>            mLocalVertexs2D;  
00089         Array2D<NormalVertex>           mTriangle0PolygonNormals2D;  
00090         Array2D<NormalVertex>           mTriangle1PolygonNormals2D;  
00091         Array2D<NormalVertex>           mVertexNormals2D;
00092         vector<TexCoord>                mTexCoords0;
00093         vector<TexCoord>                mTexCoords1;
00094     };
00095 
00096     // Each tile subdivision has a pair of opposing triangles that form a rectangle.
00097     // Each triangle has 3 vixs.
00098     enum
00099     {
00100         TRI0_VIX0_LAT = 0, TRI0_VIX0_LON = 0,  // vix[0] old comments
00101         TRI0_VIX1_LAT = 1, TRI0_VIX1_LON = 0,  // vix[1] that pertain to
00102         TRI0_VIX2_LAT = 0, TRI0_VIX2_LON = 1,  // vix[3] flat vix[]
00103 
00104         TRI1_VIX0_LAT = 1, TRI1_VIX0_LON = 0,  // vix[1]
00105         TRI1_VIX1_LAT = 1, TRI1_VIX1_LON = 1,  // vix[2]
00106         TRI1_VIX2_LAT = 0, TRI1_VIX2_LON = 1,  // vix[3]
00107     };
00108 
00109 private:
00110     CLASS_VAR uint      msMedianHeight;         
00111     TileArgs            mTileArgs;
00112     shptr<Heightmap>    mHeightmap;             
00113     fp                  mWorldLat, mWorldLon;   
00114     WorldVertex         mPosition;
00115     TileGraph           mTileGraph;
00116 };
00117 
00123 class Tile : public Object
00124 {
00125 
00126 public:
00127                     Tile( SharedPtr<Graph> graph, const WorldVertex& position )
00128                     : Object(graph,position) { }
00129                     ~Tile() { }
00130     bool            Reproducible( void ) { return true; }
00131     const string    GetName( void ) { return "Tile"; }
00132 };
00133 
00134 } // namespace mod_sim
00135 
00136 #endif // MOD_SIM_TERRAIN_TILE_HH
00137 #endif // COMPILING_MODULE
Palomino 3D Engine documents generated by doxygen 1.5.3 on Fri Nov 23 11:26:13 2007