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.cpp 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /*!
  2. * \file src/RoomData.cpp
  3. * \brief World Room Mesh
  4. *
  5. * \author xythobuz
  6. */
  7. #include "global.h"
  8. #include "SkeletalModel.h"
  9. #include "World.h"
  10. #include "RoomData.h"
  11. BoundingBox::BoundingBox(glm::vec3 min, glm::vec3 max) : a(min), b(max) { }
  12. bool BoundingBox::inBox(float x, float y, float z) {
  13. return ((y > a.y) && (y < b.y) && inBoxPlane(x, z));
  14. }
  15. bool BoundingBox::inBoxPlane(float x, float z) {
  16. return ((x > a.x) && (x < b.x)
  17. && (z > a.z) && (z < b.z));
  18. }
  19. void BoundingBox::display(bool points, const unsigned char c1[4], const unsigned char c2[4]) {
  20. /*
  21. // Bind before entering now
  22. //glBindTexture(GL_TEXTURE_2D, 1);
  23. glPointSize(4.0);
  24. //glLineWidth(1.25);
  25. //! \fixme Need to make custom color key for this
  26. glColor3ubv(c1);
  27. glBegin(GL_POINTS);
  28. glVertex3f(b[0], b[1], b[2]);
  29. glVertex3f(a[0], a[1], a[2]);
  30. if (points) {
  31. glVertex3f(b[0], a[1], b[2]);
  32. glVertex3f(a[0], b[1], b[2]);
  33. glVertex3f(b[0], b[1], a[2]);
  34. glVertex3f(a[0], a[1], b[2]);
  35. glVertex3f(a[0], b[1], a[2]);
  36. glVertex3f(b[0], a[1], a[2]);
  37. }
  38. glEnd();
  39. glColor3ubv(c2);
  40. glBegin(GL_LINES);
  41. // max, top quad
  42. glVertex3f(b[0], b[1], b[2]);
  43. glVertex3f(b[0], a[1], b[2]);
  44. glVertex3f(b[0], b[1], b[2]);
  45. glVertex3f(a[0], b[1], b[2]);
  46. glVertex3f(b[0], b[1], b[2]);
  47. glVertex3f(b[0], b[1], a[2]);
  48. // max-min, vertical quads
  49. glVertex3f(a[0], b[1], b[2]);
  50. glVertex3f(a[0], b[1], a[2]);
  51. glVertex3f(b[0], a[1], b[2]);
  52. glVertex3f(b[0], a[1], a[2]);
  53. glVertex3f(b[0], a[1], b[2]);
  54. glVertex3f(a[0], a[1], b[2]);
  55. // min-max, vertical quads
  56. glVertex3f(b[0], b[1], a[2]);
  57. glVertex3f(b[0], a[1], a[2]);
  58. glVertex3f(b[0], b[1], a[2]);
  59. glVertex3f(a[0], b[1], a[2]);
  60. glVertex3f(a[0], b[1], b[2]);
  61. glVertex3f(a[0], a[1], b[2]);
  62. // min, bottom quad
  63. glVertex3f(a[0], a[1], a[2]);
  64. glVertex3f(a[0], b[1], a[2]);
  65. glVertex3f(a[0], a[1], a[2]);
  66. glVertex3f(b[0], a[1], a[2]);
  67. glVertex3f(a[0], a[1], a[2]);
  68. glVertex3f(a[0], a[1], b[2]);
  69. glEnd();
  70. glPointSize(1.0);
  71. //glLineWidth(1.0);
  72. */
  73. }
  74. // ----------------------------------------------------------------------------
  75. void Light::getPos(float p[4]) {
  76. p[0] = pos[0];
  77. p[1] = pos[1];
  78. p[2] = pos[2];
  79. p[3] = pos[3];
  80. }
  81. void Light::getDir(float d[3]) {
  82. d[0] = dir[0];
  83. d[1] = dir[1];
  84. d[2] = dir[2];
  85. }
  86. float Light::getAtt() {
  87. return att;
  88. }
  89. void Light::getColor(float c[4]) {
  90. c[0] = color[0];
  91. c[1] = color[1];
  92. c[2] = color[2];
  93. c[3] = color[3];
  94. }
  95. float Light::getCutoff() {
  96. return cutoff;
  97. }
  98. Light::LightType Light::getType() {
  99. return type;
  100. }
  101. // ----------------------------------------------------------------------------
  102. void StaticModel::display() {
  103. StaticMesh& mesh = getWorld().getStaticMesh(index);
  104. //if (!getRender().isVisible(pos[0], pos[1], pos[2], mesh.getRadius()))
  105. // return;
  106. /*
  107. glPushMatrix();
  108. glTranslated(pos[0], pos[1], pos[2]);
  109. glRotated(yaw, 0, 1, 0);
  110. mesh.display();
  111. glPopMatrix();
  112. */
  113. }
  114. // ----------------------------------------------------------------------------
  115. Portal::Portal(glm::vec3 vert[4], float norm[3], int adj) {
  116. for (unsigned int i = 0; i < 4; i++) {
  117. for (unsigned int j = 0; j < 3; j++) {
  118. vertices[i][j] = vert[i][j];
  119. }
  120. if (i < 3) {
  121. normal[i] = norm[i];
  122. }
  123. }
  124. adjoiningRoom = adj;
  125. }
  126. void Portal::getVertices(float vert[4][3]) {
  127. for (unsigned int i = 0; i < 4; i++) {
  128. for (unsigned int j = 0; j < 3; j++) {
  129. vert[i][j] = vertices[i][j];
  130. }
  131. }
  132. }
  133. int Portal::getAdjoiningRoom() {
  134. return adjoiningRoom;
  135. }
  136. // ----------------------------------------------------------------------------
  137. float Sector::getFloor() {
  138. return floor;
  139. }
  140. float Sector::getCeiling() {
  141. return ceiling;
  142. }
  143. bool Sector::isWall() {
  144. return wall;
  145. }