Open Source Tomb Raider Engine
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. /*!
  2. * \file include/World.h
  3. * \brief The game world (model)
  4. *
  5. * \author Mongoose
  6. * \author xythobuz
  7. */
  8. #ifndef _WORLD_H_
  9. #define _WORLD_H_
  10. #include <list>
  11. #include <vector>
  12. #define BAD_BLOOD //!< \todo For temp rendering use
  13. #ifdef BAD_BLOOD
  14. #include "SkeletalModel.h"
  15. #endif
  16. #include "WorldData.h"
  17. /*!
  18. * \brief The game world (model)
  19. */
  20. class World {
  21. public:
  22. enum WorldFlag {
  23. fEnableHopping = (1 << 0)
  24. };
  25. /*!
  26. * \brief Constructs an object of World
  27. */
  28. World();
  29. /*!
  30. * \brief Deconstructs an object of World
  31. */
  32. ~World();
  33. /*!
  34. * \brief Find room a location is in.
  35. *
  36. * If it fails to be in a room it gives closest overlapping room.
  37. * \param index Guessed room index
  38. * \param x X coordinate
  39. * \param y Y coordinate
  40. * \param z Z coordinate
  41. * \returns correct room index or -1 for unknown
  42. */
  43. int getRoomByLocation(int index, float x, float y, float z);
  44. /*!
  45. * \brief Find room a location is in.
  46. *
  47. * If it fails to be in a room it gives closest overlapping room.
  48. * \param x X coordinate
  49. * \param y Y coordinate
  50. * \param z Z coordinate
  51. * \returns correct room index or -1 for unknown
  52. */
  53. int getRoomByLocation(float x, float y, float z);
  54. /*!
  55. * \brief Looks for portal crossings from xyz to xyz2 segment
  56. * from room[index]
  57. * \param index valid room index
  58. * \param x X coordinate of first point
  59. * \param y Y coordinate of first point
  60. * \param z Z coordinate of first point
  61. * \param x2 X coordinate of second point
  62. * \param y2 Y coordinate of second point
  63. * \param z2 Z coordinate of second point
  64. * \returns index of adjoined room or -1
  65. */
  66. int getAdjoiningRoom(int index,
  67. float x, float y, float z,
  68. float x2, float y2, float z2);
  69. /*!
  70. * \brief Gets the sector index of the position in room
  71. * \param room valid room index
  72. * \param x X coordinate in room
  73. * \param z Z coordinate in room
  74. * \returns sector index of position in room
  75. */
  76. int getSector(int room, float x, float z);
  77. int getSector(int room, float x, float z, float *floor, float *ceiling);
  78. unsigned int getRoomInfo(int room);
  79. /*!
  80. * \brief Check if sector is a wall
  81. * \param room valid room index
  82. * \param sector valid sector index
  83. * \returns true if this sector is a wall
  84. */
  85. bool isWall(int room, int sector);
  86. /*!
  87. * \brief Get the world height at a position
  88. * \param index valid room index
  89. * \param x X coordinate
  90. * \param y will be set to world height in that room
  91. * \param z Z coordinate
  92. * \returns true if position is in a room
  93. */
  94. bool getHeightAtPosition(int index, float x, float *y, float z);
  95. #ifdef BAD_BLOOD
  96. //! \todo Temp methods for rendering use until more refactoring is done
  97. model_mesh_t *getMesh(int index);
  98. skeletal_model_t *getModel(int index);
  99. room_mesh_t *getRoom(int index);
  100. std::vector<entity_t *> *getEntities();
  101. std::vector<sprite_seq_t *> *getSprites();
  102. std::vector<room_mesh_t *> *getRooms();
  103. #endif
  104. /*!
  105. * \brief Set an option flag
  106. * \param flag flag to set
  107. */
  108. void setFlag(WorldFlag flag);
  109. /*!
  110. * \brief Clear an option flag
  111. * \param flag flag to clear
  112. */
  113. void clearFlag(WorldFlag flag);
  114. /*!
  115. * \brief Clears all data in world
  116. * \todo in future will check if data is in use before clearing
  117. */
  118. void destroy();
  119. /*!
  120. * \brief Adds room to world
  121. * \param room room to add
  122. */
  123. void addRoom(room_mesh_t *room);
  124. /*!
  125. * \brief ADds mesh to world
  126. * \param model mesh to add
  127. */
  128. void addMesh(model_mesh_t *model);
  129. /*!
  130. * \brief Adds entity to world
  131. * \param e entity to add
  132. */
  133. void addEntity(entity_t *e);
  134. /*!
  135. * \brief Adds model to world.
  136. * \param model model to add
  137. * \returns next model ID or -1 on error
  138. */
  139. int addModel(skeletal_model_t *model);
  140. /*!
  141. * \brief Adds sprite to world
  142. * \param sprite sprite to add
  143. */
  144. void addSprite(sprite_seq_t *sprite);
  145. /*!
  146. * \brief Move entity in given direction unless collision occurs
  147. * \param e entity to move
  148. * \param movement direction of movement ('f', 'b', 'l' or 'r')
  149. */
  150. void moveEntity(entity_t *e, char movement);
  151. private:
  152. /*!
  153. * \brief Clears all data in world
  154. */
  155. void clear();
  156. bool mClearLock;
  157. unsigned int mFlags; //!< World flags
  158. std::vector<entity_t *> mEntities; //!< World entities
  159. std::vector<room_mesh_t *> mRooms; //!< Map data and meshes
  160. std::vector<model_mesh_t *> mMeshes; //!< Unanimated meshes
  161. std::vector<sprite_seq_t *> mSprites; //!< Sprites
  162. std::vector<skeletal_model_t *> mModels; //!< Skeletal animation models
  163. };
  164. #endif