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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. #include "Entity.h"
  13. #include "Room.h"
  14. #include "SkeletalModel.h"
  15. #include "Sprite.h"
  16. #include "WorldData.h"
  17. /*!
  18. * \brief The game world (model)
  19. */
  20. class World {
  21. public:
  22. /*!
  23. * \brief Deconstructs an object of World
  24. */
  25. ~World();
  26. /*!
  27. * \brief Clears all data in world
  28. */
  29. void destroy();
  30. void addRoom(Room &room);
  31. unsigned int sizeRoom();
  32. Room &getRoom(unsigned int index);
  33. void addSprite(SpriteSequence &sprite);
  34. unsigned int sizeSprite();
  35. SpriteSequence &getSprite(unsigned int index);
  36. void addEntity(Entity &entity);
  37. unsigned int sizeEntity();
  38. Entity &getEntity(unsigned int index);
  39. void addSkeletalModel(SkeletalModel &model);
  40. unsigned int sizeSkeletalModel();
  41. SkeletalModel &getSkeletalModel(unsigned int index);
  42. /*!
  43. * \brief Adds mesh to world
  44. * \param model mesh to add
  45. */
  46. void addMesh(model_mesh_t *model);
  47. model_mesh_t *getMesh(int index);
  48. /*!
  49. * \brief Find room a location is in.
  50. *
  51. * If it fails to be in a room it gives closest overlapping room.
  52. * \param index Guessed room index
  53. * \param x X coordinate
  54. * \param y Y coordinate
  55. * \param z Z coordinate
  56. * \returns correct room index or -1 for unknown
  57. */
  58. int getRoomByLocation(int index, float x, float y, float z);
  59. /*!
  60. * \brief Find room a location is in.
  61. *
  62. * If it fails to be in a room it gives closest overlapping room.
  63. * \param x X coordinate
  64. * \param y Y coordinate
  65. * \param z Z coordinate
  66. * \returns correct room index or -1 for unknown
  67. */
  68. int getRoomByLocation(float x, float y, float z);
  69. /*!
  70. * \brief Looks for portal crossings from xyz to xyz2 segment
  71. * from room[index]
  72. * \param index valid room index
  73. * \param x X coordinate of first point
  74. * \param y Y coordinate of first point
  75. * \param z Z coordinate of first point
  76. * \param x2 X coordinate of second point
  77. * \param y2 Y coordinate of second point
  78. * \param z2 Z coordinate of second point
  79. * \returns index of adjoined room or -1
  80. */
  81. int getAdjoiningRoom(int index,
  82. float x, float y, float z,
  83. float x2, float y2, float z2);
  84. /*!
  85. * \brief Gets the sector index of the position in room
  86. * \param room valid room index
  87. * \param x X coordinate in room
  88. * \param z Z coordinate in room
  89. * \returns sector index of position in room
  90. */
  91. int getSector(int room, float x, float z);
  92. int getSector(int room, float x, float z, float *floor, float *ceiling);
  93. unsigned int getRoomInfo(int room);
  94. /*!
  95. * \brief Check if sector is a wall
  96. * \param room valid room index
  97. * \param sector valid sector index
  98. * \returns true if this sector is a wall
  99. */
  100. bool isWall(int room, int sector);
  101. /*!
  102. * \brief Get the world height at a position
  103. * \param index valid room index
  104. * \param x X coordinate
  105. * \param y will be set to world height in that room
  106. * \param z Z coordinate
  107. */
  108. void getHeightAtPosition(int index, float x, float *y, float z);
  109. private:
  110. // Old World
  111. std::vector<model_mesh_t *> mMeshes; //!< Unanimated meshes
  112. // New World
  113. std::vector<Room *> mRooms;
  114. std::vector<SpriteSequence *> mSprites;
  115. std::vector<Entity *> mEntities;
  116. std::vector<SkeletalModel *> mModels;
  117. };
  118. World &getWorld();
  119. #endif