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.

Room.h 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*!
  2. * \file include/Room.h
  3. * \brief Room in World
  4. *
  5. * \author xythobuz
  6. */
  7. #ifndef _ROOM_H_
  8. #define _ROOM_H_
  9. #include <memory>
  10. #include <vector>
  11. #include "BoundingBox.h"
  12. #include "Sprite.h"
  13. #include "RoomData.h"
  14. #include "RoomMesh.h"
  15. enum RoomFlags {
  16. RoomFlagUnderWater = (1 << 0)
  17. };
  18. class Room {
  19. public:
  20. Room(glm::vec3 _pos, BoundingBox* _bbox, RoomMesh* _mesh, unsigned int f,
  21. int a, int x, int z, int i);
  22. void prepare() { mesh->prepare(); }
  23. void display(glm::mat4 VP);
  24. bool isWall(unsigned long sector);
  25. long getSector(float x, float z, float* floor, float* ceiling);
  26. long getSector(float x, float z);
  27. void getHeightAtPosition(float x, float* y, float z);
  28. int getAdjoiningRoom(float x, float y, float z,
  29. float x2, float y2, float z2);
  30. BoundingBox& getBoundingBox() { return *bbox; }
  31. RoomMesh& getMesh() { return *mesh; }
  32. unsigned int getFlags() { return flags; }
  33. int getAlternateRoom() { return alternateRoom; }
  34. int getNumXSectors() { return numXSectors; }
  35. int getNumZSectors() { return numZSectors; }
  36. int getIndex() { return roomIndex; }
  37. void addSector(Sector* s) { sectors.emplace_back(s); }
  38. void addSprite(RoomSprite* s) { sprites.emplace_back(s); }
  39. unsigned long sizeSprites() { return sprites.size(); }
  40. RoomSprite& getSprite(unsigned long index) { return *sprites.at(index); }
  41. void addModel(StaticModel* s) { models.emplace_back(s); }
  42. unsigned long sizeModels() { return models.size(); }
  43. StaticModel& getModel(unsigned long index) { return *models.at(index); }
  44. void addPortal(Portal* p) { portals.emplace_back(p); }
  45. unsigned long sizePortals() { return portals.size(); }
  46. Portal& getPortal(unsigned long index) { return *portals.at(index); }
  47. void displayUI();
  48. static void setShowBoundingBox(bool s) { showBoundingBox = s; }
  49. static bool getShowBoundingBox() { return showBoundingBox; }
  50. static void setShowRoomModels(bool s) { showRoomModels = s; }
  51. static bool getShowRoomModels() { return showRoomModels; }
  52. static void setShowRoomSprites(bool s) { showRoomSprites = s; }
  53. static bool getShowRoomSprites() { return showRoomSprites; }
  54. static void setShowRoomGeometry(bool s) { showRoomGeometry = s; }
  55. static bool getShowRoomGeometry() { return showRoomGeometry; }
  56. private:
  57. glm::vec3 pos;
  58. glm::mat4 model;
  59. std::unique_ptr<BoundingBox> bbox;
  60. std::unique_ptr<RoomMesh> mesh;
  61. unsigned int flags;
  62. int alternateRoom;
  63. int numXSectors;
  64. int numZSectors;
  65. int roomIndex;
  66. std::vector<std::unique_ptr<RoomSprite>> sprites;
  67. std::vector<std::unique_ptr<StaticModel>> models;
  68. std::vector<std::unique_ptr<Portal>> portals;
  69. std::vector<std::unique_ptr<Sector>> sectors;
  70. static bool showBoundingBox;
  71. static bool showRoomModels;
  72. static bool showRoomSprites;
  73. static bool showRoomGeometry;
  74. };
  75. #endif