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.

World.h 4.0KB

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