Open Source Tomb Raider Engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

World.h 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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. /*!
  23. * \brief Constructs an object of World
  24. */
  25. World();
  26. /*!
  27. * \brief Deconstructs an object of World
  28. */
  29. ~World();
  30. /*!
  31. * \brief Find room a location is in.
  32. *
  33. * If it fails to be in a room it gives closest overlapping room.
  34. * \param index Guessed room index
  35. * \param x X coordinate
  36. * \param y Y coordinate
  37. * \param z Z coordinate
  38. * \returns correct room index or -1 for unknown
  39. */
  40. int getRoomByLocation(int index, float x, float y, float z);
  41. /*!
  42. * \brief Find room a location is in.
  43. *
  44. * If it fails to be in a room it gives closest overlapping room.
  45. * \param x X coordinate
  46. * \param y Y coordinate
  47. * \param z Z coordinate
  48. * \returns correct room index or -1 for unknown
  49. */
  50. int getRoomByLocation(float x, float y, float z);
  51. /*!
  52. * \brief Looks for portal crossings from xyz to xyz2 segment
  53. * from room[index]
  54. * \param index valid room index
  55. * \param x X coordinate of first point
  56. * \param y Y coordinate of first point
  57. * \param z Z coordinate of first point
  58. * \param x2 X coordinate of second point
  59. * \param y2 Y coordinate of second point
  60. * \param z2 Z coordinate of second point
  61. * \returns index of adjoined room or -1
  62. */
  63. int getAdjoiningRoom(int index,
  64. float x, float y, float z,
  65. float x2, float y2, float z2);
  66. /*!
  67. * \brief Gets the sector index of the position in room
  68. * \param room valid room index
  69. * \param x X coordinate in room
  70. * \param z Z coordinate in room
  71. * \returns sector index of position in room
  72. */
  73. int getSector(int room, float x, float z);
  74. int getSector(int room, float x, float z, float *floor, float *ceiling);
  75. unsigned int getRoomInfo(int room);
  76. /*!
  77. * \brief Check if sector is a wall
  78. * \param room valid room index
  79. * \param sector valid sector index
  80. * \returns true if this sector is a wall
  81. */
  82. bool isWall(int room, int sector);
  83. /*!
  84. * \brief Get the world height at a position
  85. * \param index valid room index
  86. * \param x X coordinate
  87. * \param y will be set to world height in that room
  88. * \param z Z coordinate
  89. * \returns true if position is in a room
  90. */
  91. bool getHeightAtPosition(int index, float x, float *y, float z);
  92. #ifdef BAD_BLOOD
  93. //! \todo Temp methods for rendering use until more refactoring is done
  94. model_mesh_t *getMesh(int index);
  95. skeletal_model_t *getModel(int index);
  96. room_mesh_t *getRoom(int index);
  97. std::vector<entity_t *> *getEntities();
  98. std::vector<sprite_seq_t *> *getSprites();
  99. std::vector<room_mesh_t *> *getRooms();
  100. #endif
  101. /*!
  102. * \brief Clears all data in world
  103. * \todo in future will check if data is in use before clearing
  104. */
  105. void destroy();
  106. /*!
  107. * \brief Adds room to world
  108. * \param room room to add
  109. */
  110. void addRoom(room_mesh_t *room);
  111. /*!
  112. * \brief ADds mesh to world
  113. * \param model mesh to add
  114. */
  115. void addMesh(model_mesh_t *model);
  116. /*!
  117. * \brief Adds entity to world
  118. * \param e entity to add
  119. */
  120. void addEntity(entity_t *e);
  121. /*!
  122. * \brief Adds model to world.
  123. * \param model model to add
  124. * \returns next model ID or -1 on error
  125. */
  126. int addModel(skeletal_model_t *model);
  127. /*!
  128. * \brief Adds sprite to world
  129. * \param sprite sprite to add
  130. */
  131. void addSprite(sprite_seq_t *sprite);
  132. /*!
  133. * \brief Move entity in given direction unless collision occurs
  134. * \param e entity to move
  135. * \param movement direction of movement ('f', 'b', 'l' or 'r')
  136. */
  137. void moveEntity(entity_t *e, char movement);
  138. private:
  139. std::vector<entity_t *> mEntities; //!< World entities
  140. std::vector<room_mesh_t *> mRooms; //!< Map data and meshes
  141. std::vector<model_mesh_t *> mMeshes; //!< Unanimated meshes
  142. std::vector<sprite_seq_t *> mSprites; //!< Sprites
  143. std::vector<skeletal_model_t *> mModels; //!< Skeletal animation models
  144. };
  145. #endif