Open Source Tomb Raider Engine
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

Room.h 3.0KB

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