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.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. // Compares distance to ViewVolume for depth sorting
  37. bool operator<(const StaticModel &other);
  38. private:
  39. int index;
  40. vec_t yaw;
  41. vec3_t pos;
  42. // ?
  43. //vec3_t bbox[2];
  44. };
  45. class Portal {
  46. public:
  47. Portal(vec3_t _vertices[4], vec3_t _normal, int _adjoiningRoom);
  48. vec3_t *getVertices();
  49. int getAdjoiningRoom();
  50. private:
  51. vec3_t vertices[4];
  52. vec3_t normal;
  53. int adjoiningRoom;
  54. };
  55. class Box {
  56. public:
  57. Box(vec3_t _a, vec3_t _b, vec3_t _c, vec3_t _d);
  58. private:
  59. vec3_t a;
  60. vec3_t b;
  61. vec3_t c;
  62. vec3_t d;
  63. };
  64. class Sector {
  65. public:
  66. Sector(vec_t _floor, vec_t _ceiling, bool _wall);
  67. vec_t getFloor();
  68. vec_t getCeiling();
  69. bool isWall();
  70. private:
  71. vec_t floor;
  72. vec_t ceiling;
  73. bool wall;
  74. };
  75. typedef enum {
  76. RoomFlagUnderWater = (1 << 0)
  77. } RoomFlags;
  78. class Room {
  79. public:
  80. Room(int _id);
  81. ~Room();
  82. void setFlags(unsigned int f);
  83. unsigned int getFlags();
  84. void setNumXSectors(unsigned int n);
  85. unsigned int getNumXSectors();
  86. void setNumZSectors(unsigned int n);
  87. unsigned int getNumZSectors();
  88. void setPos(vec3_t p);
  89. void getPos(vec3_t p);
  90. void setBoundingBox(vec3_t box[2]);
  91. bool inBox(vec_t x, vec_t y, vec_t z);
  92. bool inBoxPlane(vec_t x, vec_t z);
  93. void addAdjacentRoom(int r);
  94. unsigned int sizePortals();
  95. Portal &getPortal(unsigned int index);
  96. void addPortal(Portal &p);
  97. unsigned int sizeSectors();
  98. Sector &getSector(unsigned int index);
  99. void addSector(Sector &s);
  100. void addBox(Box &b);
  101. void addModel(StaticModel &m);
  102. void addSprite(Sprite &s);
  103. void addLight(Light &l);
  104. Mesh &getMesh();
  105. private:
  106. int id;
  107. unsigned int flags;
  108. unsigned int numXSectors;
  109. unsigned int numZSectors;
  110. vec3_t pos;
  111. vec3_t bbox[2];
  112. std::vector<int> adjacentRooms;
  113. std::vector<Sprite *> sprites;
  114. std::vector<StaticModel *> models;
  115. std::vector<Portal *> portals;
  116. std::vector<Box *> boxes;
  117. std::vector<Sector *> sectors;
  118. // Was previously stored in RenderRoom
  119. vec_t dist; //!< Distance to near plane, move to room?
  120. std::vector<Light *> lights; //!< List of lights in this room
  121. Mesh mesh; //!< OpenGL mesh that represents this room
  122. };
  123. #endif