OpenRaider  0.1.4-dev
Open Source Tomb Raider Game Engine implementation
Room.h
Go to the documentation of this file.
1 
8 #ifndef _ROOM_H_
9 #define _ROOM_H_
10 
11 #include <memory>
12 #include <vector>
13 
14 #include "Sprite.h"
15 #include "RoomData.h"
16 #include "RoomMesh.h"
17 
18 enum RoomFlags {
19  RoomFlagUnderWater = (1 << 0)
20 };
21 
22 class Room {
23  public:
24  Room(glm::vec3 _pos, BoundingBox* _bbox, RoomMesh* _mesh, unsigned int f,
25  int a, int x, int z, int i);
26 
27  void prepare() { mesh->prepare(); }
28  void display(glm::mat4 VP);
29 
30  bool isWall(unsigned long sector);
31  long getSector(float x, float z, float* floor, float* ceiling);
32  long getSector(float x, float z);
33  void getHeightAtPosition(float x, float* y, float z);
34  int getAdjoiningRoom(float x, float y, float z,
35  float x2, float y2, float z2);
36 
38  RoomMesh& getMesh() { return *mesh; }
39 
40  unsigned int getFlags() { return flags; }
41  int getAlternateRoom() { return alternateRoom; }
42  int getNumXSectors() { return numXSectors; }
43  int getNumZSectors() { return numZSectors; }
44  int getIndex() { return roomIndex; }
45 
46  void addSprite(RoomSprite* s) { sprites.emplace_back(s); }
47  void addModel(StaticModel* s) { models.emplace_back(s); }
48  void addSector(Sector* s) { sectors.emplace_back(s); }
49 
50  void addPortal(Portal* p) { portals.emplace_back(p); }
51  unsigned long sizePortals() { return portals.size(); }
52  Portal& getPortal(unsigned long index) { return *portals.at(index); }
53 
54  static void setShowBoundingBox(bool s) { showBoundingBox = s; }
55  static bool getShowBoundingBox() { return showBoundingBox; }
56 
57  static void setShowRoomModels(bool s) { showRoomModels = s; }
58  static bool getShowRoomModels() { return showRoomModels; }
59 
60  static void setShowRoomSprites(bool s) { showRoomSprites = s; }
61  static bool getShowRoomSprites() { return showRoomSprites; }
62 
63  static void setShowRoomGeometry(bool s) { showRoomGeometry = s; }
64  static bool getShowRoomGeometry() { return showRoomGeometry; }
65 
66  private:
67  glm::vec3 pos;
68  glm::mat4 model;
69  std::unique_ptr<BoundingBox> bbox;
70  std::unique_ptr<RoomMesh> mesh;
71 
72  unsigned int flags;
76  int roomIndex;
77 
78  std::vector<std::unique_ptr<RoomSprite>> sprites;
79  std::vector<std::unique_ptr<StaticModel>> models;
80  std::vector<std::unique_ptr<Portal>> portals;
81  std::vector<std::unique_ptr<Sector>> sectors;
82 
83  static bool showBoundingBox;
84  static bool showRoomModels;
85  static bool showRoomSprites;
86  static bool showRoomGeometry;
87 };
88 
89 #endif
90 
int getNumXSectors()
Definition: Room.h:42
int getAlternateRoom()
Definition: Room.h:41
void getHeightAtPosition(float x, float *y, float z)
Definition: Room.cpp:79
2D Billboard Collection
bool isWall(unsigned long sector)
Definition: Room.cpp:48
std::unique_ptr< RoomMesh > mesh
Definition: Room.h:70
void addModel(StaticModel *s)
Definition: Room.h:47
unsigned int getFlags()
Definition: Room.h:40
int numXSectors
Definition: Room.h:74
static bool getShowRoomSprites()
Definition: Room.h:61
int getNumZSectors()
Definition: Room.h:43
static bool showRoomGeometry
Definition: Room.h:86
int getIndex()
Definition: Room.h:44
RoomFlags
Definition: Room.h:18
Portal & getPortal(unsigned long index)
Definition: Room.h:52
static void setShowRoomModels(bool s)
Definition: Room.h:57
static bool getShowRoomModels()
Definition: Room.h:58
std::vector< std::unique_ptr< StaticModel > > models
Definition: Room.h:79
Auxiliary Room classes.
unsigned long sizePortals()
Definition: Room.h:51
static bool showBoundingBox
Definition: Room.h:83
unsigned int flags
Definition: Room.h:72
void addSprite(RoomSprite *s)
Definition: Room.h:46
std::unique_ptr< BoundingBox > bbox
Definition: Room.h:69
long getSector(float x, float z, float *floor, float *ceiling)
Definition: Room.cpp:55
int alternateRoom
Definition: Room.h:73
int roomIndex
Definition: Room.h:76
void prepare()
Definition: Room.h:27
BoundingBox & getBoundingBox()
Definition: Room.h:37
void addPortal(Portal *p)
Definition: Room.h:50
static bool getShowRoomGeometry()
Definition: Room.h:64
Room Mesh Geometry.
glm::mat4 model
Definition: Room.h:68
Definition: Room.h:22
RoomMesh & getMesh()
Definition: Room.h:38
std::vector< std::unique_ptr< Sector > > sectors
Definition: Room.h:81
static void setShowRoomSprites(bool s)
Definition: Room.h:60
std::vector< std::unique_ptr< RoomSprite > > sprites
Definition: Room.h:78
Room(glm::vec3 _pos, BoundingBox *_bbox, RoomMesh *_mesh, unsigned int f, int a, int x, int z, int i)
Definition: Room.cpp:20
void display(glm::mat4 VP)
Definition: Room.cpp:26
void addSector(Sector *s)
Definition: Room.h:48
static bool showRoomModels
Definition: Room.h:84
glm::vec3 pos
Definition: Room.h:67
static void setShowRoomGeometry(bool s)
Definition: Room.h:63
std::vector< std::unique_ptr< Portal > > portals
Definition: Room.h:80
static bool getShowBoundingBox()
Definition: Room.h:55
static void setShowBoundingBox(bool s)
Definition: Room.h:54
int numZSectors
Definition: Room.h:75
int getAdjoiningRoom(float x, float y, float z, float x2, float y2, float z2)
Definition: Room.cpp:85
static bool showRoomSprites
Definition: Room.h:85