Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

AState.h

Go to the documentation of this file.
00001 /*
00002 CS Senior Project 2003
00003 Team : Leftfield
00004 Project : ModernWarfare
00005 Members :
00006 - Russ Christensen              <rchriste@cs.utah.edu>
00007 - Todd Smith                    <tcsmith@cs.utah.edu>
00008 - Usit Duongsaa                 <duongsaa@cs.utah.edu>
00009 Copyright 2003 Russ Christensen, Usit Duongsaa, and Todd Smith. All rights reserved.
00010 
00011 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
00012 
00013 Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 
00014 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 
00015 THIS SOFTWARE IS PROVIDED BY RUSS CHRISTENSEN, USIT DUONGSAA, AND TODD SMITH ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RUSS, USIT, TODD OR OTHER CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00016 */
00017 
00018 
00023 #ifndef INCLUDE_ASTATE
00024 #define INCLUDE_ASTATE
00025 
00026 #include "ExternalLibs.h"
00027 #include "ATypes.h"
00028 #include "AVertexTypes.h"
00029 
00030 const int MAX_CONSOLE_LINES             =       30;
00031 const int MAX_KEY                               =       300;
00032 
00033 const int MAX_STATE_TYPE        =       256;
00034 const int MAX_STREAM            =       32;
00035 const int MAX_TEXTURE           =       4;
00036 const int MAX_LOCAL_RANDON_NUM          =       512;
00037 const int MAX_LOCAL_RANDON_FLOAT        =       1024;
00038 
00039 
00040 //------------------------------------------------------------------------------------
00042 struct AState
00043 {
00044         // system stuffs.  handle to system resource
00045         HINSTANCE                               hInst;
00046         HWND                                    hWnd;
00047         LPDIRECT3D8                             pD3D;
00048         LPDIRECT3DDEVICE8               pDevice;
00049 
00050         // window spec
00051         int                                             windowWidth, windowHeight, colorDepth;
00052         bool                                    isFullScreen;
00053         DWORD                                   clearFlags;                     // flags indicating which bits of the video buffer should be cleared
00054 
00055         // game loop call-back functions & control values       
00056         AierraInitFunc                  initFunc;
00057         AierraUpdateFunc                updateFunc;
00058         AierraRenderFunc                renderFunc;
00059         AierraShutdownFunc              shutdownFunc;
00060         DWORD                                   idealMS;                        // ideally(running at 62.5Hz), this would be the time in millisec
00061         DWORD                                   lastCountResetMS;       // time when we last reset updateCount
00062         DWORD                                   updateCount;            // number of updates's since last reset
00063         FLOAT                                   updateRate;                     // rate (updates/sec)
00064         DWORD                                   renderCount;
00065         FLOAT                                   renderRate;
00066         DWORD                                   excessCount;            // if we update&render too fast, this keeps track of excess time
00067         FLOAT                                   excessRate;
00068         bool                                    showFPS;
00069         int                                             renderNumber;           // +=1 every time we try to render (skipped or not)
00070         int                                             skipRate;                       // normally 0.  2 means render once skip twice
00071         int                                             fastForwardAmount;      // when you call sys_fastForwardUpdate, we store the number of times here
00072 
00073 
00074         // console
00075         bool                                    showConsole;
00076         ofstream                                *pConsoleLogFile;
00077         ostringstream                   *pConsoleStream;
00078         string                                  consoleLines[MAX_CONSOLE_LINES];        // each line of the console window
00079         int                                             consoleLineIndex;
00080         
00081         // input
00082         NDX_Input                               ndxInput;                                       // NukeDX Wrapper of Direct Input
00083         bool                                    keyDownLastCycle[MAX_KEY];      // Whether each of the keys was down last cycle
00084         bool                                    keyDownThisCycle[MAX_KEY];
00085         int                                             VKmapping[MAX_KEY];                     // keyCode = mapping[VKeyCode]
00086         FLOAT                                   input_mouseWheel;
00087         Vec2D                                   input_lastTickMousePos;
00088         int                                             input_mouseIdleTickCount;
00089 
00090         // rendering device     
00091         DWORD device_renderStates[MAX_STATE_TYPE];
00092         DWORD device_vsh, device_psh;
00093         void *device_vb[MAX_STREAM];
00094         void *device_ib;
00095         IDirect3DBaseTexture8 *device_texture[MAX_TEXTURE];
00096 
00097         // shaders
00098         DWORD vshader_overlay;
00099         DWORD pshader_overlay;
00100         DWORD pshader_textureConstAlpha;
00101         DWORD pshader_texturePixelAlpha;
00102         DWORD vshader_mesh;
00103         DWORD pshader_mesh;
00104         DWORD vshader_terrain;
00105         DWORD pshader_terrain;
00106         DWORD vshader_lerpParticle;
00107         DWORD pshader_lerpParticle;
00108         DWORD vshader_sprite;
00109         DWORD pshader_sprite;
00110 
00111         // overlay
00112         LPDIRECT3DVERTEXBUFFER8         overlay_pVB;
00113         vector<OverlayEntry>            overlay_entries;
00114         ostringstream                           *overlay_pTextStream;
00115 
00116         // resource
00117         vector<CD3DFont*>                       res_fonts;
00118         vector<LPDIRECT3DTEXTURE8>      res_textures;
00119         vector<MeshEntry>                       res_meshes;
00120         vector<TerrainEntry>            res_terrains;
00121         vector<int>                                     res_localRandomNums;
00122         int                                                     res_localRandomNumIndex;
00123         vector<float>                           res_localRandomFloats;
00124         int                                                     res_localRandomFloatIndex;
00125 
00126         // mesh support
00127         vector<MeshRenderRequestEntry>          mesh_renderList;
00128         LPDIRECT3DVERTEXBUFFER8         mesh_vb;
00129         LPDIRECT3DINDEXBUFFER8          mesh_ib;
00130         vector<MeshVertex>                      mesh_raw_vb;
00131         vector<USHORT>                          mesh_raw_ib;
00132 
00133         // camera
00134         Vec3D           camera_pos;
00135         Vec3D           camera_target;
00136         D3DXMATRIX      camera_viewMatrix, camera_projMatrix;
00137         D3DXMATRIX      camera_world2projMatrix;
00138         FLOAT           camera_screenSize;
00139         FLOAT           camera_vibratePos;                      // with position and speed, we will simulate underdamped vibration
00140         FLOAT           camera_vibrateSpeed;
00141 
00142         // particle systems
00143         // lerp-flare
00144         LPDIRECT3DVERTEXBUFFER8         flare_vb;
00145         ATexture                                        flare_texture;
00146         int                                                     flare_startRenderingIndex;
00147         int                                                     flare_renderCount;
00148         int                                                     flare_reservedCount;                    // how much the user reserved (via flare_begin())
00149         LerpParticleVertex                      *flare_pVertex;
00150         // general point sprites
00151         LPDIRECT3DVERTEXBUFFER8         sprite_vb;
00152         int                                                     sprite_startRenderingIndex;     
00153         vector<SpriteRenderRequestEntry>        sprite_renderList;
00154 
00155 
00156 
00157         // profiler
00158         map<string,__int64>             profiler_startTime, profiler_totalTime;
00159         vector<string>                  profiler_names;
00160         __int64                                 profiler_RDTSClastReset;        // rdtsc time when we last reset total time
00161         int                                             profiler_MSlastReset;           // MilliSec when we last reset total time
00162 
00163         // networking
00164         NDX_Connect                             net_ndxConnect;
00165         bool                                    net_isInit;                                     // whether the whole network system was init'ed
00166         bool                                    net_isServer;                           // am I a server?
00167         list<string>                    net_serverSendQueue;            // msgs in server still waiting to be sent
00168         string                                  net_myName;
00169         bool                                    net_gameFinalized;
00170         int                                             net_myPlayerNum;
00171         DPID                                    net_serverDPID;
00172         bool                                    net_isFakeServer;
00173         map<int,string>                 net_mapNumToName;                       // map playerName <--> playerNumber
00174         map<string,int>                 net_mapNameToNum;
00175 };
00176 //------------------------------------------------------------------------------------
00177 
00178 extern AState AS;
00179 
00180 #endif

Generated on Wed Apr 23 05:50:14 2003 for Modern Warfare by doxygen1.3-rc2