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

Room.h 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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 "Mesh.h"
  13. #include "Sprite.h"
  14. class Light {
  15. public:
  16. /*!
  17. * \brief Type a light can be of
  18. */
  19. typedef enum {
  20. typePoint = 1, //!< Point light
  21. typeSpot = 2, //!< Spot light
  22. typeDirectional = 3 //!< Directional light
  23. } LightType;
  24. Light(vec4_t pos, vec3_t dir, vec_t att, vec4_t color, vec_t cutoff, LightType type);
  25. //private:
  26. vec4_t mPos; //! Light position in 3 space
  27. vec3_t mDir; //! Light direction
  28. vec_t mAtt;
  29. vec4_t mColor; //! Color of light
  30. vec_t mCutoff; //! Fade out distance
  31. LightType mType; //! Type of light
  32. };
  33. class StaticModel {
  34. public:
  35. StaticModel(int _index, vec_t _yaw, vec3_t _pos);
  36. void display();
  37. // Compares distance to ViewVolume for depth sorting
  38. bool operator<(const StaticModel &other);
  39. private:
  40. int index;
  41. vec_t yaw;
  42. vec3_t pos;
  43. // ?
  44. //vec3_t bbox[2];
  45. };
  46. class Portal {
  47. public:
  48. Portal(vec3_t _vertices[4], vec3_t _normal, int _adjoiningRoom);
  49. void getVertices(vec3_t vert[4]);
  50. int getAdjoiningRoom();
  51. private:
  52. vec3_t vertices[4];
  53. vec3_t normal;
  54. int adjoiningRoom;
  55. };
  56. class Box {
  57. public:
  58. Box(vec3_t _a, vec3_t _b, vec3_t _c, vec3_t _d);
  59. private:
  60. vec3_t a;
  61. vec3_t b;
  62. vec3_t c;
  63. vec3_t d;
  64. };
  65. class Sector {
  66. public:
  67. Sector(vec_t _floor, vec_t _ceiling, bool _wall);
  68. vec_t getFloor();
  69. vec_t getCeiling();
  70. bool isWall();
  71. private:
  72. vec_t floor;
  73. vec_t ceiling;
  74. bool wall;
  75. };
  76. typedef enum {
  77. RoomFlagUnderWater = (1 << 0)
  78. } RoomFlags;
  79. class Room {
  80. public:
  81. Room(int _id);
  82. ~Room();
  83. void setFlags(unsigned int f);
  84. unsigned int getFlags();
  85. void setNumXSectors(unsigned int n);
  86. unsigned int getNumXSectors();
  87. void setNumZSectors(unsigned int n);
  88. unsigned int getNumZSectors();
  89. void setPos(vec3_t p);
  90. void getPos(vec3_t p);
  91. void getBoundingBox(vec3_t box[2]);
  92. void setBoundingBox(vec3_t box[2]);
  93. bool inBox(vec_t x, vec_t y, vec_t z);
  94. bool inBoxPlane(vec_t x, vec_t z);
  95. unsigned int sizeAdjacentRooms();
  96. int getAdjacentRoom(unsigned int index);
  97. void addAdjacentRoom(int r);
  98. unsigned int sizePortals();
  99. Portal &getPortal(unsigned int index);
  100. void addPortal(Portal &p);
  101. unsigned int sizeSectors();
  102. Sector &getSector(unsigned int index);
  103. void addSector(Sector &s);
  104. unsigned int sizeBox();
  105. Box &getBox(unsigned int index);
  106. void addBox(Box &b);
  107. unsigned int sizeModels();
  108. StaticModel &getModel(unsigned int index);
  109. void addModel(StaticModel &m);
  110. void sortModels();
  111. unsigned int sizeLights();
  112. Light &getLight(unsigned int index);
  113. void addLight(Light &l);
  114. unsigned int sizeSprites();
  115. Sprite &getSprite(unsigned int index);
  116. void addSprite(Sprite &s);
  117. Mesh &getMesh();
  118. private:
  119. int id;
  120. unsigned int flags;
  121. unsigned int numXSectors;
  122. unsigned int numZSectors;
  123. vec3_t pos;
  124. vec3_t bbox[2];
  125. std::vector<int> adjacentRooms;
  126. std::vector<Sprite *> sprites;
  127. std::vector<StaticModel *> models;
  128. std::vector<Portal *> portals;
  129. std::vector<Box *> boxes;
  130. std::vector<Sector *> sectors;
  131. // Was previously stored in RenderRoom
  132. //vec_t dist; //!< Distance to near plane, move to room?
  133. std::vector<Light *> lights; //!< List of lights in this room
  134. Mesh mesh; //!< OpenGL mesh that represents this room
  135. };
  136. #endif