mod_sim_world.hh

Go to the documentation of this file.
00001 /*
00008  * LEGAL:   COPYRIGHT (C) 2004 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 #ifndef MOD_SIM_WORLD_HH
00014 #define MOD_SIM_WORLD_HH 1
00015 
00016 #include "eng_world.hh"
00017 using namespace eng;
00018 
00019 namespace mod_sim {
00020 
00024 class SimWorld : public World
00025 {
00026 
00027 typedef World Parent;
00028 friend class World;  // base is a friend because eng includes this
00029 friend class Locus;
00030 friend class Quadrant;
00031 friend class ModuleSim;
00032 
00033 // world.conf:
00034 private:
00038     struct Conf
00039     {
00040         Conf( void );
00041 
00043         struct World
00044         {
00045             World( void );
00046             bool    mValid;
00047             Int3    mWorldDim;
00048             Int3    mLocusDim;
00049             fp      mQuadrantEdge;
00050             fp      mWorldMargin;
00051         };
00052 
00054         struct BSP
00055         {
00056             BSP( void );
00057             bool    mValid;
00058             uint    mRecursionLimit;
00059             int     mNodeLimit;
00060         };
00061 
00063         struct Misc
00064         {
00065             Misc( void );
00066             bool        mValid;
00067             WorldVertex mInitialPosition;
00068             Degree      mInitialRotation[3];
00069             fp          mCraftScale;
00070         };
00071 
00073         struct Terrain
00074         {
00075             Terrain( void );
00076             bool            mValid;
00077             int             mTilesInQuadrantEdge;
00078             int             mSubtilesInTileEdge;
00079             int             mHeightmapWidth;
00080             int             mHeightmapHeightOffset;
00081             fp              mHeightmapNoiseInc;
00082             fp              mRandomHeight;
00083             int             mRandomColor;  // byte of RGBA
00084             uint            mElevationMin;
00085             uint            mElevationMax;
00086             uint            mElevationWatermark;
00087         };
00088 
00090         struct Sky
00091         {
00092             Sky( void );
00093             bool            mValid;
00094             fp              mCloudDensity;
00095             fp              mCloudLayerLow;
00096             fp              mCloudLayerHigh;
00097         };
00098 
00099         bool        mValid;
00100         World       mWorld;
00101         BSP         mBSP;
00102         Misc        mMisc;
00103         Terrain     mTerrain;
00104         Sky         mSky;
00105     };
00106     friend ostream& operator<<( ostream& strm, const SimWorld::Conf& conf );
00107 
00108 private:
00110     class WorldConfReader : public ConfReader
00111     {
00112     public:
00113         void ProcessField( string& field, ifstream& config );
00114     };
00115 
00116 // Make world:
00117 public:
00118                     SimWorld( void );  // substituted by Make()
00119                     ~SimWorld();
00120     bool            IfMade( void ) { return mMade; }
00121     void            Make( void );
00122 
00123     // Sizes:
00124     fp              GetFighterAircraftWidth( void );
00125     fp              GetMissileWidth( void );
00126 
00127 private:
00128     void            Populate( QuadrantPtr q );  // part of Template Method
00129 
00130 // Misc:
00131 public:
00132     WorldVertex     GetCenter( void ) { return mCenter; }
00133     bool            IfEdge( const WorldVertex& pos );
00134 
00135 // World configuration:
00136 public:
00137     Conf&           GetConf( void ) { ASSERT(mConf.mValid); return mConf; }  // for clients (not World itself)
00138 private:
00139     void            ReadWorldConf( void );
00140     void            ComputeWorldConf( void );
00141     void            CheckWorldConf( void );
00142 
00143 // Data:
00144 private:
00145     Conf            mConf;
00146     bool            mMade;          
00147     WorldVertex     mCenter;
00148 };
00149 
00150 ostream& operator<<( ostream& strm, const SimWorld::Conf& conf );
00151 
00152 } // namespace mod_sim
00153 
00154 #endif // MOD_SIM_WORLD_HH
Palomino 3D Engine documents generated by doxygen 1.5.3 on Fri Nov 23 11:26:13 2007