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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*!
  2. * \file include/Room.h
  3. * \brief World Room Mesh
  4. *
  5. * \author xythobuz
  6. */
  7. #ifndef _ROOM_H_
  8. #define _ROOM_H_
  9. #include <memory>
  10. #include <vector>
  11. #include <glm/mat4x4.hpp>
  12. #include <glm/vec3.hpp>
  13. #include "Sprite.h"
  14. #include "RoomData.h"
  15. #include "RoomMesh.h"
  16. enum RoomFlags {
  17. RoomFlagUnderWater = (1 << 0)
  18. };
  19. class Room {
  20. public:
  21. Room(glm::vec3 _pos, BoundingBox* _bbox, RoomMesh* _mesh, unsigned int f,
  22. int a, int x, int z)
  23. : pos(_pos), bbox(_bbox), mesh(_mesh), flags(f), alternateRoom(a),
  24. numXSectors(x), numZSectors(z) { }
  25. void prepare() { mesh->prepare(); }
  26. void display(glm::mat4 view, glm::mat4 projection);
  27. bool isWall(unsigned long sector);
  28. long getSector(float x, float z, float* floor, float* ceiling);
  29. long getSector(float x, float z);
  30. void getHeightAtPosition(float x, float* y, float z);
  31. int getAdjoiningRoom(float x, float y, float z,
  32. float x2, float y2, float z2);
  33. BoundingBox& getBoundingBox() { return *bbox; }
  34. RoomMesh& getMesh() { return *mesh; }
  35. unsigned int getNumXSectors() { return numXSectors; }
  36. unsigned int getNumZSectors() { return numZSectors; }
  37. unsigned int getFlags() { return flags; }
  38. unsigned long sizePortals();
  39. Portal& getPortal(unsigned long index);
  40. void addPortal(Portal* p);
  41. unsigned long sizeSectors();
  42. Sector& getSector(unsigned long index);
  43. void addSector(Sector* s);
  44. unsigned long sizeModels();
  45. StaticModel& getModel(unsigned long index);
  46. void addModel(StaticModel* s);
  47. unsigned long sizeLights();
  48. Light& getLight(unsigned long index);
  49. void addLight(Light* l);
  50. unsigned long sizeSprites();
  51. Sprite& getSprite(unsigned long index);
  52. void addSprite(Sprite* s);
  53. private:
  54. glm::vec3 pos;
  55. std::unique_ptr<BoundingBox> bbox;
  56. std::unique_ptr<RoomMesh> mesh;
  57. unsigned int flags;
  58. int numXSectors;
  59. int numZSectors;
  60. int alternateRoom;
  61. std::vector<std::unique_ptr<Sprite>> sprites;
  62. std::vector<std::unique_ptr<StaticModel>> models;
  63. std::vector<std::unique_ptr<Portal>> portals;
  64. std::vector<std::unique_ptr<Sector>> sectors;
  65. std::vector<std::unique_ptr<Light>> lights;
  66. // Was used for "depth sorting" render list, but never assigned...?!
  67. //float dist; // Distance to near plane, move to room?
  68. };
  69. #endif