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

RoomData.cpp 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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) {
  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(glm::vec3(0.0f, 1.0f, 0.0f));
  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(glm::vec3(1.0f, 0.0f, 0.0f));
  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 model = glm::rotate(glm::translate(glm::mat4(1.0f), pos),
  57. angle, glm::vec3(0.0f, 1.0f, 0.0f));
  58. getWorld().getStaticMesh(cache).display(model, view, projection);
  59. }
  60. // ----------------------------------------------------------------------------
  61. void Light::getPos(float p[4]) {
  62. p[0] = pos[0];
  63. p[1] = pos[1];
  64. p[2] = pos[2];
  65. p[3] = pos[3];
  66. }
  67. void Light::getDir(float d[3]) {
  68. d[0] = dir[0];
  69. d[1] = dir[1];
  70. d[2] = dir[2];
  71. }
  72. float Light::getAtt() {
  73. return att;
  74. }
  75. void Light::getColor(float c[4]) {
  76. c[0] = color[0];
  77. c[1] = color[1];
  78. c[2] = color[2];
  79. c[3] = color[3];
  80. }
  81. float Light::getCutoff() {
  82. return cutoff;
  83. }
  84. Light::LightType Light::getType() {
  85. return type;
  86. }
  87. // ----------------------------------------------------------------------------
  88. float Sector::getFloor() {
  89. return floor;
  90. }
  91. float Sector::getCeiling() {
  92. return ceiling;
  93. }
  94. bool Sector::isWall() {
  95. return wall;
  96. }