Open Source Tomb Raider Engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

RoomData.cpp 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 "RoomData.h"
  12. void StaticModel::display(glm::mat4 view, glm::mat4 projection) {
  13. if (cache < 0) {
  14. for (int i = 0; i < getWorld().sizeStaticMesh(); i++) {
  15. if (getWorld().getStaticMesh(i).getID() == id) {
  16. cache = i;
  17. }
  18. }
  19. assert(cache >= 0);
  20. }
  21. glm::mat4 model = glm::rotate(glm::translate(glm::mat4(1.0f), pos),
  22. angle, glm::vec3(0.0f, 1.0f, 0.0f));
  23. getWorld().getStaticMesh(cache).display(model, view, projection);
  24. }
  25. // ----------------------------------------------------------------------------
  26. void Light::getPos(float p[4]) {
  27. p[0] = pos[0];
  28. p[1] = pos[1];
  29. p[2] = pos[2];
  30. p[3] = pos[3];
  31. }
  32. void Light::getDir(float d[3]) {
  33. d[0] = dir[0];
  34. d[1] = dir[1];
  35. d[2] = dir[2];
  36. }
  37. float Light::getAtt() {
  38. return att;
  39. }
  40. void Light::getColor(float c[4]) {
  41. c[0] = color[0];
  42. c[1] = color[1];
  43. c[2] = color[2];
  44. c[3] = color[3];
  45. }
  46. float Light::getCutoff() {
  47. return cutoff;
  48. }
  49. Light::LightType Light::getType() {
  50. return type;
  51. }
  52. // ----------------------------------------------------------------------------
  53. Portal::Portal(glm::vec3 vert[4], float norm[3], int adj) {
  54. for (unsigned int i = 0; i < 4; i++) {
  55. for (unsigned int j = 0; j < 3; j++) {
  56. vertices[i][j] = vert[i][j];
  57. }
  58. if (i < 3) {
  59. normal[i] = norm[i];
  60. }
  61. }
  62. adjoiningRoom = adj;
  63. }
  64. void Portal::getVertices(float vert[4][3]) {
  65. for (unsigned int i = 0; i < 4; i++) {
  66. for (unsigned int j = 0; j < 3; j++) {
  67. vert[i][j] = vertices[i][j];
  68. }
  69. }
  70. }
  71. int Portal::getAdjoiningRoom() {
  72. return adjoiningRoom;
  73. }
  74. // ----------------------------------------------------------------------------
  75. float Sector::getFloor() {
  76. return floor;
  77. }
  78. float Sector::getCeiling() {
  79. return ceiling;
  80. }
  81. bool Sector::isWall() {
  82. return wall;
  83. }