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.

Room.h 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /*!
  2. * \file include/Room.h
  3. * \brief World Room Mesh
  4. *
  5. * \author xythobuz
  6. */
  7. #ifndef _ROOM_H_
  8. #define _ROOM_H_
  9. #include <vector>
  10. #include <memory>
  11. #include "math/math.h"
  12. #include "math/Matrix.h"
  13. #include "Mesh.h"
  14. #include "Sprite.h"
  15. #include "TombRaider.h"
  16. class Light {
  17. public:
  18. /*!
  19. * \brief Type a light can be of
  20. */
  21. typedef enum {
  22. typePoint = 1, //!< Point light
  23. typeSpot = 2, //!< Spot light
  24. typeDirectional = 3 //!< Directional light
  25. } LightType;
  26. Light(TombRaider &tr, unsigned int room, unsigned int index);
  27. void getPos(vec4_t p);
  28. void getDir(vec3_t d);
  29. vec_t getAtt();
  30. void getColor(vec4_t c);
  31. vec_t getCutoff();
  32. LightType getType();
  33. private:
  34. vec4_t pos; //! Light position in 3 space
  35. vec3_t dir; //! Light direction
  36. vec_t att;
  37. vec4_t color; //! Color of light
  38. vec_t cutoff; //! Fade out distance
  39. LightType type; //! Type of light
  40. };
  41. class StaticModel {
  42. public:
  43. StaticModel(TombRaider &tr, unsigned int room, unsigned int i);
  44. void display();
  45. // Compares distance to ViewVolume for depth sorting
  46. bool operator<(const StaticModel &other);
  47. private:
  48. int index;
  49. vec_t yaw;
  50. vec3_t pos;
  51. // ?
  52. //vec3_t bbox[2];
  53. };
  54. class Portal {
  55. public:
  56. Portal(TombRaider &tr, unsigned int room, unsigned int index, Matrix &transform);
  57. void getVertices(vec3_t vert[4]);
  58. int getAdjoiningRoom();
  59. private:
  60. vec3_t vertices[4];
  61. vec3_t normal;
  62. int adjoiningRoom;
  63. };
  64. class Box {
  65. public:
  66. Box(TombRaider &tr, unsigned int room, unsigned int index);
  67. private:
  68. vec3_t a;
  69. vec3_t b;
  70. vec3_t c;
  71. vec3_t d;
  72. };
  73. class Sector {
  74. public:
  75. Sector(TombRaider &tr, unsigned int room, unsigned int index);
  76. vec_t getFloor();
  77. vec_t getCeiling();
  78. bool isWall();
  79. private:
  80. vec_t floor;
  81. vec_t ceiling;
  82. bool wall;
  83. };
  84. typedef enum {
  85. RoomFlagUnderWater = (1 << 0)
  86. } RoomFlags;
  87. class Room {
  88. public:
  89. Room(TombRaider &tr, unsigned int index);
  90. ~Room();
  91. void setFlags(unsigned int f);
  92. unsigned int getFlags();
  93. unsigned int getNumXSectors();
  94. unsigned int getNumZSectors();
  95. void getPos(vec3_t p);
  96. void getBoundingBox(vec3_t box[2]);
  97. bool inBox(vec_t x, vec_t y, vec_t z);
  98. bool inBoxPlane(vec_t x, vec_t z);
  99. unsigned int sizeAdjacentRooms();
  100. int getAdjacentRoom(unsigned int index);
  101. unsigned int sizePortals();
  102. Portal &getPortal(unsigned int index);
  103. unsigned int sizeSectors();
  104. Sector &getSector(unsigned int index);
  105. unsigned int sizeBox();
  106. Box &getBox(unsigned int index);
  107. unsigned int sizeModels();
  108. StaticModel &getModel(unsigned int index);
  109. void sortModels();
  110. unsigned int sizeLights();
  111. Light &getLight(unsigned int index);
  112. unsigned int sizeSprites();
  113. Sprite &getSprite(unsigned int index);
  114. Mesh &getMesh();
  115. private:
  116. unsigned int flags;
  117. unsigned int numXSectors;
  118. unsigned int numZSectors;
  119. vec3_t pos;
  120. vec3_t bbox[2];
  121. Mesh mesh;
  122. std::vector<int> adjacentRooms;
  123. std::vector<Sprite *> sprites;
  124. std::vector<StaticModel *> models;
  125. std::vector<Portal *> portals;
  126. std::vector<Box *> boxes;
  127. std::vector<Sector *> sectors;
  128. std::vector<Light *> lights;
  129. // Was used for "depth sorting" render list, but never assigned...?!
  130. //vec_t dist; // Distance to near plane, move to room?
  131. };
  132. #endif