Open Source Tomb Raider Engine
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

OpenRaider.h 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
  2. /*================================================================
  3. *
  4. * Project : OpenRaider
  5. * Author : Mongoose
  6. * Website : http://www.westga.edu/~stu7440/
  7. * Email : stu7440@westga.edu
  8. * Object : OpenRaider
  9. * License : No use w/o permission (C) 2001 Mongoose
  10. * Comments: This is the main class for OpenRaider
  11. *
  12. *
  13. * This file was generated using Mongoose's C++
  14. * template generator script. <stu7440@westga.edu>
  15. *
  16. *-- History ------------------------------------------------
  17. *
  18. * 2002.08.24:
  19. * Mongoose - Finally made into Singleton
  20. *
  21. * 2001.05.21:
  22. * Mongoose - Created
  23. ================================================================*/
  24. #ifndef _OPENRAIDER_H_
  25. #define _OPENRAIDER_H_
  26. #include <List.h>
  27. #include <Map.h>
  28. #include <Vector.h>
  29. #include <TombRaider.h>
  30. #include <Camera.h>
  31. #include <Render.h>
  32. #include <Sound.h>
  33. #include <SDLSystem.h>
  34. #include <Network.h>
  35. #include <World.h>
  36. typedef enum
  37. {
  38. OpenRaiderKey_console = 1, // Reserved 0 event for console in System
  39. OpenRaiderKey_attack,
  40. OpenRaiderKey_forward,
  41. OpenRaiderKey_left,
  42. OpenRaiderKey_right,
  43. OpenRaiderKey_backward,
  44. OpenRaiderKey_jump,
  45. OpenRaiderKey_tiltUp,
  46. OpenRaiderKey_tiltDown,
  47. OpenRaiderKey_panLeft,
  48. OpenRaiderKey_panRight,
  49. OpenRaiderKey_crouch
  50. } OpenRaider_KeyEvent;
  51. typedef enum
  52. {
  53. OpenRaider_ShowFPS = 1,
  54. OpenRaider_DebugMap = 2,
  55. OpenRaider_DebugModel = 4,
  56. OpenRaider_EnableSound = 8,
  57. OpenRaider_DumpTexture = 16,
  58. OpenRaider_FullScreen = 32,
  59. OpenRaider_Loading = 64,
  60. OpenRaider_GameRunning = 128
  61. } OpenRaiderFlags;
  62. typedef enum
  63. {
  64. OpenRaiderSound_Ambient = 1
  65. } OpenRaider_SoundEventType;
  66. class OpenRaider : public SDLSystem
  67. {
  68. public:
  69. ////////////////////////////////////////////////////////////
  70. // Constructors ( Singleton )
  71. ////////////////////////////////////////////////////////////
  72. static OpenRaider *Instance();
  73. /*------------------------------------------------------
  74. * Pre :
  75. * Post : Constructs the object of OpenRaider or
  76. * returns pointer to it if previously allocated
  77. *
  78. *-- History ------------------------------------------
  79. *
  80. * 2001.08.24:
  81. * Mongoose - Created
  82. ------------------------------------------------------*/
  83. ~OpenRaider();
  84. /*------------------------------------------------------
  85. * Pre : OpenRaider object is allocated
  86. * Post : Deconstructs an object of OpenRaider
  87. *
  88. *-- History ------------------------------------------
  89. *
  90. * 2001.05.21:
  91. * Mongoose - Created
  92. ------------------------------------------------------*/
  93. ////////////////////////////////////////////////////////////
  94. // Public Accessors
  95. ////////////////////////////////////////////////////////////
  96. ////////////////////////////////////////////////////////////
  97. // Public Mutators
  98. ////////////////////////////////////////////////////////////
  99. void start();
  100. /*------------------------------------------------------
  101. * Pre :
  102. * Post : Init the Game
  103. *
  104. *-- History ------------------------------------------
  105. *
  106. * 2001.05.21:
  107. * Mongoose - Created
  108. ------------------------------------------------------*/
  109. void handleMouseMotionEvent(float x, float y);
  110. /*------------------------------------------------------
  111. * Pre :
  112. * Post : Mouse motion input used
  113. *
  114. *-- History ------------------------------------------
  115. *
  116. * 2001.06.04:
  117. * Mongoose - Created
  118. ------------------------------------------------------*/
  119. void handleBoundKeyPressEvent(unsigned int key);
  120. /*------------------------------------------------------
  121. * Pre : <Key> is a valid keyboard code
  122. *
  123. * Post : Recieves <Event> bound to <Cmd> from <Key> press
  124. *
  125. *-- History ------------------------------------------
  126. *
  127. * 2003.06.03:
  128. * Mongoose - Created
  129. ------------------------------------------------------*/
  130. void handleBoundKeyReleaseEvent(unsigned int key);
  131. /*------------------------------------------------------
  132. * Pre : <Key> is a valid keyboard code
  133. *
  134. * Post : Recieves <Event> bound to <Cmd> from <Key> release
  135. *
  136. *-- History ------------------------------------------
  137. *
  138. * 2003.06.03:
  139. * Mongoose - Created
  140. ------------------------------------------------------*/
  141. void handleCommand(char *command, unsigned int mode);
  142. /*------------------------------------------------------
  143. * Pre : <Command> is valid keyword optionally followed
  144. * by ' ' (space) seperated and argument(s)
  145. *
  146. * <Mode> is the current type or resource mode
  147. *
  148. * Post : Executes valid command based on keyword
  149. *
  150. *-- History ------------------------------------------
  151. *
  152. * 2002.03.23:
  153. * Mongoose - Created
  154. ------------------------------------------------------*/
  155. void handleConsoleKeyPressEvent(unsigned int key, unsigned int mod);
  156. /*------------------------------------------------------
  157. * Pre : <Key> is a valid keyboard code
  158. *
  159. * Post : Recieves <Key> code from text input in console mode
  160. *
  161. *-- History ------------------------------------------
  162. *
  163. * 2003.06.03:
  164. * Mongoose - Created
  165. ------------------------------------------------------*/
  166. void handleKeyPressEvent(unsigned int key, unsigned int mod);
  167. void handleKeyReleaseEvent(unsigned int key, unsigned int mod);
  168. /*------------------------------------------------------
  169. * Pre : key and mod are valid key command
  170. * Post : executes command acc with key, if any
  171. *
  172. *-- History ------------------------------------------
  173. *
  174. * 2001.05.27:
  175. * Mongoose - Created
  176. ------------------------------------------------------*/
  177. void initGL();
  178. /*------------------------------------------------------
  179. * Pre :
  180. * Post :
  181. *
  182. *-- History ------------------------------------------
  183. *
  184. * 2002.08.13:
  185. * Mongoose - Created
  186. ------------------------------------------------------*/
  187. void gameFrame();
  188. /*------------------------------------------------------
  189. * Pre :
  190. * Post : One game physics/time frame passes
  191. * Also renders one frame per call
  192. *
  193. *-- History ------------------------------------------
  194. *
  195. * 2001.05.21:
  196. * Mongoose - Created
  197. ------------------------------------------------------*/
  198. void print(bool dump_stdout, const char *format, ...);
  199. /*------------------------------------------------------
  200. * Pre : Use like printf
  201. *
  202. * Post : Outputs message in game console
  203. *
  204. * If dump_stdout is true, print to stdout also
  205. *
  206. *-- History ------------------------------------------
  207. *
  208. * 2002.08.13:
  209. * Mongoose - Created
  210. ------------------------------------------------------*/
  211. protected:
  212. ////////////////////////////////////////////////////////////
  213. // Constructors ( Singleton )
  214. ////////////////////////////////////////////////////////////
  215. OpenRaider();
  216. /*------------------------------------------------------
  217. * Pre :
  218. * Post : Constructs an object of OpenRaider
  219. *
  220. *-- History ------------------------------------------
  221. *
  222. * 2001.05.21:
  223. * Mongoose - Created
  224. ------------------------------------------------------*/
  225. private:
  226. ////////////////////////////////////////////////////////////
  227. // Private Accessors
  228. ////////////////////////////////////////////////////////////
  229. ////////////////////////////////////////////////////////////
  230. // Private Mutators
  231. ////////////////////////////////////////////////////////////
  232. void consoleCommand(char *cmd);
  233. /*------------------------------------------------------
  234. * Pre :
  235. * Post :
  236. *
  237. *-- History ------------------------------------------
  238. *
  239. * ????.??.??:
  240. * Mongoose - Created
  241. ------------------------------------------------------*/
  242. void soundEvent(int type, int id, vec3_t pos, vec3_t angles);
  243. /*------------------------------------------------------
  244. * Pre :
  245. * Post :
  246. *
  247. *-- History ------------------------------------------
  248. *
  249. * 2002.06.16:
  250. * Mongoose - Created
  251. ------------------------------------------------------*/
  252. // void entityEvent(entity_t &e, RaiderEvent event);
  253. /*------------------------------------------------------
  254. * Pre :
  255. * Post :
  256. *
  257. *-- History ------------------------------------------
  258. *
  259. * 2002.06.16:
  260. * Mongoose - Created
  261. ------------------------------------------------------*/
  262. void processPakSounds();
  263. /*------------------------------------------------------
  264. * Pre :
  265. * Post :
  266. *
  267. *-- History ------------------------------------------
  268. *
  269. * 2001.06.04:
  270. * Mongoose - Created
  271. ------------------------------------------------------*/
  272. void initSound();
  273. /*------------------------------------------------------
  274. * Pre : Sound system has been init
  275. * Post : Loads and positions level sounds and music
  276. *
  277. *-- History ------------------------------------------
  278. *
  279. * 2001.06.04:
  280. * Mongoose - Created
  281. ------------------------------------------------------*/
  282. void initTextures();
  283. /*------------------------------------------------------
  284. * Pre :
  285. * Post : Generates all textures or mipmaps
  286. * needed for fonts, splash, ext particles
  287. *
  288. *-- History ------------------------------------------
  289. *
  290. * 2001.05.28:
  291. * Mongoose - Created
  292. ------------------------------------------------------*/
  293. void processTextures();
  294. /*------------------------------------------------------
  295. * Pre :
  296. * Post : Generates tombraider textures or mipmaps
  297. * needed for sprites, rooms, and models
  298. *
  299. *-- History ------------------------------------------
  300. *
  301. * 2001.05.28:
  302. * Mongoose - Created
  303. ------------------------------------------------------*/
  304. void processSprites();
  305. /*------------------------------------------------------
  306. * Pre :
  307. * Post : Generates render sprite sequences
  308. *
  309. *-- History ------------------------------------------
  310. *
  311. * 2001.06.06:
  312. * Mongoose - All new functionality
  313. *
  314. * 2001.05.28:
  315. * Mongoose - Created
  316. ------------------------------------------------------*/
  317. void processMoveables();
  318. /*------------------------------------------------------
  319. * Pre :
  320. * Post :
  321. *
  322. *-- History ------------------------------------------
  323. *
  324. * 2001.06.08:
  325. * Mongoose - Created
  326. ------------------------------------------------------*/
  327. void processMoveable(int index, int i, int *ent, List <skeletal_model_t *> &cache2, List <unsigned int> &cache, int object_id);
  328. /*------------------------------------------------------
  329. * Pre :
  330. * Post :
  331. *
  332. *-- History ------------------------------------------
  333. *
  334. * 2002.04.06:
  335. * Mongoose - Created
  336. ------------------------------------------------------*/
  337. void processModel(int index);
  338. /*------------------------------------------------------
  339. * Pre : valid model index
  340. * Post : Generates render mesh and any textures
  341. * needed for model[index]
  342. *
  343. *-- History ------------------------------------------
  344. *
  345. * 2001.05.26:
  346. * Mongoose - Created
  347. ------------------------------------------------------*/
  348. void processRoom(int index);
  349. /*------------------------------------------------------
  350. * Pre : valid room index
  351. * Post : Generates render mesh and any textures
  352. * needed for room[index]
  353. *
  354. *-- History ------------------------------------------
  355. *
  356. * 2001.05.21:
  357. * Mongoose - Created
  358. ------------------------------------------------------*/
  359. void loadLevel(char *filename);
  360. /*------------------------------------------------------
  361. * Pre :
  362. * Post : Loads validated level pak from diskfile
  363. * using maplist
  364. *
  365. *-- History ------------------------------------------
  366. *
  367. * 2001.05.21:
  368. * Mongoose - Created
  369. ------------------------------------------------------*/
  370. static OpenRaider *mInstance; /* Singleton use */
  371. TombRaider m_tombraider; /* Tombraider data support */
  372. Sound mSound; /* 3d Audio support */
  373. Render m_render; /* Rendering support */
  374. Camera m_camera; /* Client camera support */
  375. GLString *mText; /* Hook to textbox like output */
  376. int mNoClipping; /* 0 - Clipping, 1 - No Clipping,
  377. 2 - No Clipping w/o gravity */
  378. // RC vars //////////////////
  379. unsigned int mMode[8]; /* Translate System's mode ids to OR's */
  380. unsigned int m_flags; /* Set options by flags */
  381. int m_testSFX; /* Used for mixed channel sound tests */
  382. float m_mouseX, m_mouseY; /* XY axis rotation deltas */
  383. unsigned int m_texOffset; /* Offset of TombRaider textures in list */
  384. unsigned int mLevelTextureOffset;
  385. // Game vars //////////////
  386. Vector <char *> mMusicList; /* List of game level music */
  387. Vector <char *> mMapList; /* List of game maps */
  388. char m_mapName[32]; /* Current map filename */
  389. char *m_pakDir; /* Current pak directory */
  390. char *m_audioDir; /* Current audio directory */
  391. char *m_homeDir; /* Current home directory */
  392. Vector<entity_t *> mClients; /* Player entity/clients */
  393. unsigned int mMaxClients; /* Max number of clients */
  394. };
  395. #endif