Open Source Tomb Raider Engine
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

RoomData.h 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*!
  2. * \file include/RoomData.h
  3. * \brief Auxiliary Room classes
  4. *
  5. * \author xythobuz
  6. */
  7. #ifndef _ROOM_DATA_H_
  8. #define _ROOM_DATA_H_
  9. #include <memory>
  10. #include <vector>
  11. class BoundingBox {
  12. public:
  13. BoundingBox(glm::vec3 min, glm::vec3 max) {
  14. corner[0] = glm::vec3(min.x, min.y, min.z);
  15. corner[1] = glm::vec3(max.x, min.y, min.z);
  16. corner[2] = glm::vec3(min.x, max.y, min.z);
  17. corner[3] = glm::vec3(min.x, min.y, max.z);
  18. corner[4] = glm::vec3(max.x, max.y, min.z);
  19. corner[5] = glm::vec3(min.x, max.y, max.z);
  20. corner[6] = glm::vec3(max.x, min.y, max.z);
  21. corner[7] = glm::vec3(max.x, max.y, max.z);
  22. }
  23. bool inBox(glm::vec3 p) {
  24. return ((p.y >= corner[0].y) && (p.y <= corner[7].y)
  25. && inBoxPlane(p));
  26. }
  27. bool inBoxPlane(glm::vec3 p) {
  28. return ((p.x >= corner[0].x) && (p.x <= corner[7].x)
  29. && (p.z >= corner[0].z) && (p.z <= corner[7].z));
  30. }
  31. glm::vec3 getCorner(int i) {
  32. orAssertGreaterThanEqual(i, 0);
  33. orAssertLessThan(i, 8);
  34. return corner[i];
  35. }
  36. void display(glm::mat4 VP, glm::vec3 colorLine, glm::vec3 colorDot);
  37. private:
  38. glm::vec3 corner[8];
  39. };
  40. // --------------------------------------
  41. class StaticModel {
  42. public:
  43. StaticModel(glm::vec3 pos, float angle, int i);
  44. void display(glm::mat4 VP);
  45. void displayUI();
  46. private:
  47. int id;
  48. int cache;
  49. glm::mat4 model;
  50. };
  51. // --------------------------------------
  52. class RoomSprite {
  53. public:
  54. RoomSprite(glm::vec3 p, int s) : pos(p), sprite(s) { }
  55. void display(glm::mat4 VP);
  56. private:
  57. glm::vec3 pos;
  58. int sprite;
  59. };
  60. // --------------------------------------
  61. class Portal {
  62. public:
  63. Portal(int adj, glm::vec3 n,
  64. glm::vec3 v1, glm::vec3 v2, glm::vec3 v3, glm::vec3 v4);
  65. int getAdjoiningRoom() { return adjoiningRoom; }
  66. glm::vec3 getNormal() { return normal; }
  67. BoundingBox getBoundingBox() { return bbox; }
  68. void display(glm::mat4 VP);
  69. void displayUI();
  70. glm::vec3 getVertex(int i) {
  71. orAssertGreaterThanEqual(i, 0);
  72. orAssertLessThan(i, 4);
  73. return vert[i];
  74. }
  75. static void setShowBoundingBox(bool s) { showBoundingBox = s; }
  76. static bool getShowBoundingBox() { return showBoundingBox; }
  77. private:
  78. int adjoiningRoom;
  79. glm::vec3 normal;
  80. glm::vec3 vert[4];
  81. BoundingBox bbox, bboxNormal;
  82. static bool showBoundingBox;
  83. };
  84. // --------------------------------------
  85. class Sector {
  86. public:
  87. Sector(float f, float c, bool w) : floor(f), ceiling(c), wall(w) { }
  88. float getFloor();
  89. float getCeiling();
  90. bool isWall();
  91. private:
  92. float floor;
  93. float ceiling;
  94. bool wall;
  95. };
  96. #endif