Open Source Tomb Raider Engine
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

RoomData.h 3.1KB

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