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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*!
  2. * \file include/RoomData.h
  3. * \brief World Room Mesh
  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. assert((i >= 0) && (i < 8));
  33. return corner[i];
  34. }
  35. void display(glm::mat4 VP, glm::vec3 colorLine, glm::vec3 colorDot);
  36. private:
  37. glm::vec3 corner[8];
  38. };
  39. // --------------------------------------
  40. class StaticModel {
  41. public:
  42. StaticModel(glm::vec3 pos, float angle, int i);
  43. void display(glm::mat4 VP);
  44. private:
  45. int id;
  46. int cache;
  47. glm::mat4 model;
  48. };
  49. // --------------------------------------
  50. class RoomSprite {
  51. public:
  52. RoomSprite(glm::vec3 p, int s) : pos(p), sprite(s) { }
  53. void display(glm::mat4 VP);
  54. private:
  55. glm::vec3 pos;
  56. int sprite;
  57. };
  58. // --------------------------------------
  59. class Portal {
  60. public:
  61. Portal(int adj, glm::vec3 n, glm::vec3 v1, glm::vec3 v2, glm::vec3 v3,
  62. glm::vec3 v4) : adjoiningRoom(adj), normal(n) {
  63. vert[0] = v1; vert[1] = v2;
  64. vert[2] = v3; vert[3] = v4;
  65. }
  66. int getAdjoiningRoom() { return adjoiningRoom; }
  67. glm::vec3 getNormal() { return normal; }
  68. glm::vec3 getVertex(int i) { assert((i >= 0) && (i < 4)); return vert[i]; }
  69. private:
  70. int adjoiningRoom;
  71. glm::vec3 normal;
  72. glm::vec3 vert[4];
  73. };
  74. // --------------------------------------
  75. class Light {
  76. public:
  77. /*!
  78. * \brief Type a light can be of
  79. */
  80. typedef enum {
  81. typePoint = 1, //!< Point light
  82. typeSpot = 2, //!< Spot light
  83. typeDirectional = 3 //!< Directional light
  84. } LightType;
  85. void getPos(float p[4]);
  86. void getDir(float d[3]);
  87. float getAtt();
  88. void getColor(float c[4]);
  89. float getCutoff();
  90. LightType getType();
  91. private:
  92. float pos[4]; //! Light position in 3 space
  93. float dir[3]; //! Light direction
  94. float att;
  95. float color[4]; //! Color of light
  96. float cutoff; //! Fade out distance
  97. LightType type; //! Type of light
  98. };
  99. // --------------------------------------
  100. class Sector {
  101. public:
  102. Sector(float f, float c, bool w) : floor(f), ceiling(c), wall(w) { }
  103. float getFloor();
  104. float getCeiling();
  105. bool isWall();
  106. private:
  107. float floor;
  108. float ceiling;
  109. bool wall;
  110. };
  111. #endif