Open Source Tomb Raider Engine
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

WorldData.h 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. /*!
  2. * \file include/WorldData.h
  3. * \brief Structs and enums for the game world (model)
  4. *
  5. * \author Mongoose
  6. * \author xythobuz
  7. */
  8. #ifndef _WORLDDATA_H_
  9. #define _WORLDDATA_H_
  10. #include "math/math.h"
  11. // Mirrors TombRaider class' room flags really
  12. typedef enum {
  13. roomFlag_underWater = 0x0001
  14. } room_flags_t;
  15. typedef enum {
  16. worldMoveType_walkNoSwim = -1,
  17. worldMoveType_walk = 0,
  18. worldMoveType_noClipping = 1,
  19. worldMoveType_fly = 2,
  20. worldMoveType_swim = 3
  21. } worldMoveType;
  22. typedef struct {
  23. vec3_t pos;
  24. } vertex_t;
  25. /*
  26. typedef struct {
  27. vec2_t uv;
  28. } uv_t;
  29. typedef struct {
  30. vec4_t rgba;
  31. } color_t;
  32. */
  33. typedef struct {
  34. vec2_t st;
  35. } texel_t;
  36. typedef struct {
  37. int num_verts; //!< 4 == Quad, 3 == Triangle, rendered as triangles
  38. vertex_t vertex[4];
  39. texel_t texel[4];
  40. float pos[3];
  41. float radius; //!< \fixme yeah, I know
  42. int texture;
  43. } sprite_t;
  44. typedef struct {
  45. int num_sprites;
  46. sprite_t *sprite;
  47. } sprite_seq_t;
  48. /*! \fixme For now shaders are textures on tex objects
  49. * and materials on color objects. If -1
  50. * then it doesn't have that information yet.
  51. */
  52. typedef struct {
  53. int index[3];
  54. vec_t st[6];
  55. int texture;
  56. unsigned short transparency;
  57. } texture_tri_t;
  58. typedef struct {
  59. std::vector<texture_tri_t *> texturedTriangles;
  60. std::vector<texture_tri_t *> coloredTriangles;
  61. std::vector<texture_tri_t *> texturedRectangles;
  62. std::vector<texture_tri_t *> coloredRectangles;
  63. vec3_t center;
  64. float radius;
  65. unsigned int vertexCount;
  66. vec_t *vertices;
  67. unsigned int colorCount;
  68. vec_t *colors;
  69. unsigned int normalCount;
  70. vec_t *normals;
  71. } model_mesh_t;
  72. typedef struct entity_s {
  73. int id; //!< Unique identifier
  74. float pos[3]; //!< World position
  75. float angles[3]; //!< Euler angles (pitch, yaw, roll)
  76. int type; //!< {(0x00, item), (0x01, ai), (0x02, player)}
  77. int room; //!< Current room entity is in
  78. worldMoveType moveType; //!< Type of motion/clipping
  79. bool moving; //!< In motion?
  80. struct entity_s *master; //!< Part of entity chain?
  81. int state; //!< State of the Player, AI, or object
  82. int objectId; //!< What kind of entity?
  83. int modelId; //!< Animation model
  84. void *tmpHook;
  85. bool animate;
  86. /*
  87. float time, lastTime;
  88. int state, lastState;
  89. int event, lastEvent;
  90. int goal;
  91. */
  92. } entity_t;
  93. typedef struct {
  94. int index; //!< model_mesh index
  95. float yaw; //!< angle of rotation on Y
  96. float pos[3]; //!< position
  97. //vec3_t bboxMax;
  98. //vec3_t bboxMin;
  99. } static_model_t;
  100. typedef struct {
  101. float vertices[4][3];
  102. float normal[3];
  103. int adjoining_room;
  104. } portal_t;
  105. typedef struct {
  106. vertex_t a;
  107. vertex_t b;
  108. vertex_t c;
  109. vertex_t d;
  110. } box_t;
  111. typedef struct {
  112. vec_t floor;
  113. vec_t ceiling;
  114. bool wall;
  115. } sector_t;
  116. //! \fixme No room mesh list or sprites and etc
  117. typedef struct {
  118. std::vector<int> adjacentRooms;
  119. std::vector<portal_t *> portals;
  120. std::vector<static_model_t *> models;
  121. std::vector<sprite_t *> sprites;
  122. std::vector<box_t *> boxes;
  123. std::vector<sector_t *> sectors;
  124. int id;
  125. unsigned int flags;
  126. unsigned int numXSectors;
  127. unsigned int numZSectors;
  128. float pos[3];
  129. vec3_t bbox_min;
  130. vec3_t bbox_max;
  131. } room_mesh_t;
  132. // Workout generic entity and a client class from these entities
  133. typedef struct world_entity_s {
  134. vec3_t pos;
  135. vec3_t lastPos;
  136. vec3_t angle;
  137. vec_t ttl;
  138. int type;
  139. int state;
  140. //struct world_entity_s *master;
  141. } world_entity_t;
  142. typedef struct {
  143. vec3_t pos;
  144. vec3_t lastPos;
  145. vec3_t angle;
  146. char clipping;
  147. float time, eventTime, eventTimer;
  148. int state, nextState;
  149. float health;
  150. // Client
  151. unsigned int uid;
  152. char name[32];
  153. int actor, enemy;
  154. // Render
  155. unsigned int model;
  156. unsigned int skin;
  157. unsigned int animFrame;
  158. } actor_entity_t;
  159. enum OpenRaiderEvent {
  160. eNone = 0,
  161. eWeaponDischarge,
  162. eDying,
  163. eDead,
  164. eWounded,
  165. eRunForward,
  166. eRunBackward,
  167. eJump,
  168. eCrouchWalk,
  169. eIdle,
  170. eTaunt,
  171. eTurn,
  172. eRespawn,
  173. eLand
  174. };
  175. #endif