Open Source Tomb Raider Engine
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

RoomData.h 2.9KB

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