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.

RoomData.h 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. #include <glm/vec3.hpp>
  12. class BoundingBox {
  13. public:
  14. BoundingBox(glm::vec3 min, glm::vec3 max) : a(min), b(max) { }
  15. bool inBox(glm::vec3 p) {
  16. return ((p.y >= a.y) && (p.y <= b.y) && inBoxPlane(p));
  17. }
  18. bool inBoxPlane(glm::vec3 p) {
  19. return ((p.x >= a.x) && (p.x <= b.x) && (p.z >= a.z) && (p.z <= b.z));
  20. }
  21. glm::vec3 getVertexP(glm::vec3 normal) {
  22. glm::vec3 p = a;
  23. if (normal.x >= 0.0f)
  24. p.x = b.x;
  25. if (normal.y >= 0.0f)
  26. p.y = b.y;
  27. if (normal.z >= 0.0f)
  28. p.z = b.z;
  29. return p;
  30. }
  31. private:
  32. glm::vec3 a, b;
  33. };
  34. // --------------------------------------
  35. class StaticModel {
  36. public:
  37. StaticModel(glm::vec3 p, float a, int i) : pos(p), angle(a), id(i), cache(-1) { }
  38. void display(glm::mat4 view, glm::mat4 projection);
  39. private:
  40. glm::vec3 pos;
  41. float angle;
  42. int id;
  43. int cache;
  44. };
  45. // --------------------------------------
  46. class Portal {
  47. public:
  48. Portal(int adj, glm::vec3 n, glm::vec3 v1, glm::vec3 v2, glm::vec3 v3,
  49. glm::vec3 v4) : adjoiningRoom(adj), normal(n) {
  50. vert[0] = v1; vert[1] = v2;
  51. vert[2] = v3; vert[3] = v4;
  52. }
  53. int getAdjoiningRoom() { return adjoiningRoom; }
  54. glm::vec3 getNormal() { return normal; }
  55. glm::vec3 getVertex(int i) { assert((i >= 0) && (i < 4)); return vert[i]; }
  56. private:
  57. int adjoiningRoom;
  58. glm::vec3 normal;
  59. glm::vec3 vert[4];
  60. };
  61. // --------------------------------------
  62. class Light {
  63. public:
  64. /*!
  65. * \brief Type a light can be of
  66. */
  67. typedef enum {
  68. typePoint = 1, //!< Point light
  69. typeSpot = 2, //!< Spot light
  70. typeDirectional = 3 //!< Directional light
  71. } LightType;
  72. void getPos(float p[4]);
  73. void getDir(float d[3]);
  74. float getAtt();
  75. void getColor(float c[4]);
  76. float getCutoff();
  77. LightType getType();
  78. private:
  79. float pos[4]; //! Light position in 3 space
  80. float dir[3]; //! Light direction
  81. float att;
  82. float color[4]; //! Color of light
  83. float cutoff; //! Fade out distance
  84. LightType type; //! Type of light
  85. };
  86. // --------------------------------------
  87. class Sector {
  88. public:
  89. Sector(float f, float c, bool w) : floor(f), ceiling(c), wall(w) { }
  90. float getFloor();
  91. float getCeiling();
  92. bool isWall();
  93. private:
  94. float floor;
  95. float ceiling;
  96. bool wall;
  97. };
  98. #endif