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 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 <memory>
  10. #include <vector>
  11. #include <glm/mat4x4.hpp>
  12. #include <glm/vec3.hpp>
  13. #include "Sprite.h"
  14. #include "RoomData.h"
  15. #include "RoomMesh.h"
  16. enum RoomFlags {
  17. RoomFlagUnderWater = (1 << 0)
  18. };
  19. class Room {
  20. public:
  21. Room(glm::vec3 _pos, BoundingBox* _bbox, RoomMesh* _mesh, unsigned int f)
  22. : pos(_pos), bbox(_bbox), mesh(_mesh), flags(f) { }
  23. void prepare() { mesh->prepare(); }
  24. void display(glm::mat4 view, glm::mat4 projection);
  25. bool isWall(unsigned long sector);
  26. long getSector(float x, float z, float* floor, float* ceiling);
  27. long getSector(float x, float z);
  28. void getHeightAtPosition(float x, float* y, float z);
  29. int getAdjoiningRoom(float x, float y, float z,
  30. float x2, float y2, float z2);
  31. BoundingBox& getBoundingBox() { return *bbox; }
  32. RoomMesh& getMesh() { return *mesh; }
  33. void setNumXSectors(unsigned int n) { numXSectors = n; }
  34. unsigned int getNumXSectors() { return numXSectors; }
  35. void setNumZSectors(unsigned int n) { numZSectors = n; }
  36. unsigned int getNumZSectors() { return numZSectors; }
  37. unsigned int getFlags() { return flags; }
  38. unsigned long sizeAdjacentRooms();
  39. long getAdjacentRoom(unsigned long index);
  40. void addAdjacentRoom(long r);
  41. unsigned long sizePortals();
  42. Portal& getPortal(unsigned long index);
  43. void addPortal(Portal* p);
  44. unsigned long sizeSectors();
  45. Sector& getSector(unsigned long index);
  46. void addSector(Sector* s);
  47. unsigned long sizeModels();
  48. StaticModel& getModel(unsigned long index);
  49. void addModel(StaticModel* s);
  50. unsigned long sizeLights();
  51. Light& getLight(unsigned long index);
  52. void addLight(Light* l);
  53. unsigned long sizeSprites();
  54. Sprite& getSprite(unsigned long index);
  55. void addSprite(Sprite* s);
  56. private:
  57. glm::vec3 pos;
  58. std::unique_ptr<BoundingBox> bbox;
  59. std::unique_ptr<RoomMesh> mesh;
  60. unsigned int flags;
  61. unsigned int numXSectors;
  62. unsigned int numZSectors;
  63. std::vector<long> adjacentRooms;
  64. std::vector<std::unique_ptr<Sprite>> sprites;
  65. std::vector<std::unique_ptr<StaticModel>> models;
  66. std::vector<std::unique_ptr<Portal>> portals;
  67. std::vector<std::unique_ptr<Sector>> sectors;
  68. std::vector<std::unique_ptr<Light>> lights;
  69. // Was used for "depth sorting" render list, but never assigned...?!
  70. //float dist; // Distance to near plane, move to room?
  71. };
  72. #endif