Open Source Tomb Raider Engine
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

RoomData.cpp 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*!
  2. * \file src/RoomData.cpp
  3. * \brief World Room Mesh
  4. *
  5. * \author xythobuz
  6. */
  7. #include <glm/gtc/matrix_transform.hpp>
  8. #include "global.h"
  9. #include "SkeletalModel.h"
  10. #include "World.h"
  11. #include "system/Window.h"
  12. #include "RoomData.h"
  13. void BoundingBox::display(glm::mat4 VP, glm::vec3 colorLine, glm::vec3 colorDot) {
  14. std::vector<glm::vec3> verts;
  15. std::vector<glm::vec3> cols;
  16. std::vector<unsigned short> inds;
  17. for (int i = 0; i < 8; i++) {
  18. verts.push_back(corner[i]);
  19. cols.push_back(colorLine);
  20. }
  21. inds.push_back(0);
  22. inds.push_back(2);
  23. inds.push_back(4);
  24. inds.push_back(1);
  25. inds.push_back(6);
  26. inds.push_back(7);
  27. inds.push_back(5);
  28. inds.push_back(3);
  29. inds.push_back(0);
  30. inds.push_back(1);
  31. inds.push_back(4);
  32. inds.push_back(7);
  33. inds.push_back(6);
  34. inds.push_back(3);
  35. inds.push_back(5);
  36. inds.push_back(2);
  37. Window::drawGL(verts, cols, inds, VP, GL_LINE_STRIP);
  38. cols.clear();
  39. inds.clear();
  40. for (int i = 0; i < 8; i++) {
  41. cols.push_back(colorDot);
  42. inds.push_back(i);
  43. }
  44. Window::drawGL(verts, cols, inds, VP, GL_POINTS);
  45. }
  46. // ----------------------------------------------------------------------------
  47. void StaticModel::display(glm::mat4 view, glm::mat4 projection) {
  48. if (cache < 0) {
  49. for (int i = 0; i < getWorld().sizeStaticMesh(); i++) {
  50. if (getWorld().getStaticMesh(i).getID() == id) {
  51. cache = i;
  52. }
  53. }
  54. assert(cache >= 0);
  55. }
  56. glm::mat4 translate = glm::translate(glm::mat4(1.0f), glm::vec3(pos.x, -pos.y, pos.z));
  57. glm::mat4 rotate = glm::rotate(glm::mat4(1.0f), angle, glm::vec3(0.0f, 1.0f, 0.0f));
  58. glm::mat4 model = translate * rotate;
  59. getWorld().getStaticMesh(cache).display(model, view, projection);
  60. }
  61. // ----------------------------------------------------------------------------
  62. void Light::getPos(float p[4]) {
  63. p[0] = pos[0];
  64. p[1] = pos[1];
  65. p[2] = pos[2];
  66. p[3] = pos[3];
  67. }
  68. void Light::getDir(float d[3]) {
  69. d[0] = dir[0];
  70. d[1] = dir[1];
  71. d[2] = dir[2];
  72. }
  73. float Light::getAtt() {
  74. return att;
  75. }
  76. void Light::getColor(float c[4]) {
  77. c[0] = color[0];
  78. c[1] = color[1];
  79. c[2] = color[2];
  80. c[3] = color[3];
  81. }
  82. float Light::getCutoff() {
  83. return cutoff;
  84. }
  85. Light::LightType Light::getType() {
  86. return type;
  87. }
  88. // ----------------------------------------------------------------------------
  89. float Sector::getFloor() {
  90. return floor;
  91. }
  92. float Sector::getCeiling() {
  93. return ceiling;
  94. }
  95. bool Sector::isWall() {
  96. return wall;
  97. }