OpenRaider  0.1.4-dev
Open Source Tomb Raider Game Engine implementation
RoomData.h
Go to the documentation of this file.
1 
8 #ifndef _ROOM_DATA_H_
9 #define _ROOM_DATA_H_
10 
11 #include <memory>
12 #include <vector>
13 
14 class BoundingBox {
15  public:
16  BoundingBox(glm::vec3 min, glm::vec3 max) {
17  corner[0] = glm::vec3(min.x, min.y, min.z);
18  corner[1] = glm::vec3(max.x, min.y, min.z);
19  corner[2] = glm::vec3(min.x, max.y, min.z);
20  corner[3] = glm::vec3(min.x, min.y, max.z);
21  corner[4] = glm::vec3(max.x, max.y, min.z);
22  corner[5] = glm::vec3(min.x, max.y, max.z);
23  corner[6] = glm::vec3(max.x, min.y, max.z);
24  corner[7] = glm::vec3(max.x, max.y, max.z);
25  }
26 
27  bool inBox(glm::vec3 p) {
28  return ((p.y >= corner[0].y) && (p.y <= corner[7].y)
29  && inBoxPlane(p));
30  }
31 
32  bool inBoxPlane(glm::vec3 p) {
33  return ((p.x >= corner[0].x) && (p.x <= corner[7].x)
34  && (p.z >= corner[0].z) && (p.z <= corner[7].z));
35  }
36 
37  glm::vec3 getCorner(int i) {
39  assertLessThan(i, 8);
40  return corner[i];
41  }
42 
43  void display(glm::mat4 VP, glm::vec3 colorLine, glm::vec3 colorDot);
44 
45  private:
46  glm::vec3 corner[8];
47 };
48 
49 // --------------------------------------
50 
51 class StaticModel {
52  public:
53  StaticModel(glm::vec3 pos, float angle, int i);
54  void display(glm::mat4 VP);
55 
56  private:
57  int id;
58  int cache;
59  glm::mat4 model;
60 };
61 
62 // --------------------------------------
63 
64 class RoomSprite {
65  public:
66  RoomSprite(glm::vec3 p, int s) : pos(p), sprite(s) { }
67  void display(glm::mat4 VP);
68 
69  private:
70  glm::vec3 pos;
71  int sprite;
72 };
73 
74 // --------------------------------------
75 
76 class Portal {
77  public:
78  Portal(int adj, glm::vec3 n, glm::vec3 v1, glm::vec3 v2, glm::vec3 v3,
79  glm::vec3 v4) : adjoiningRoom(adj), normal(n) {
80  vert[0] = v1; vert[1] = v2;
81  vert[2] = v3; vert[3] = v4;
82  }
83  int getAdjoiningRoom() { return adjoiningRoom; }
84  glm::vec3 getNormal() { return normal; }
85 
86  glm::vec3 getVertex(int i) {
88  assertLessThan(i, 4);
89  return vert[i];
90  }
91 
92  private:
94  glm::vec3 normal;
95  glm::vec3 vert[4];
96 };
97 
98 // --------------------------------------
99 
100 class Sector {
101  public:
102  Sector(float f, float c, bool w) : floor(f), ceiling(c), wall(w) { }
103  float getFloor();
104  float getCeiling();
105  bool isWall();
106 
107  private:
108  float floor;
109  float ceiling;
110  bool wall;
111 };
112 
113 #endif
114 
BoundingBox(glm::vec3 min, glm::vec3 max)
Definition: RoomData.h:16
void display(glm::mat4 VP, glm::vec3 colorLine, glm::vec3 colorDot)
Definition: RoomData.cpp:16
Sector(float f, float c, bool w)
Definition: RoomData.h:102
bool isWall()
Definition: RoomData.cpp:106
void display(glm::mat4 VP)
Definition: RoomData.cpp:87
float getFloor()
Definition: RoomData.cpp:98
glm::vec3 getNormal()
Definition: RoomData.h:84
int cache
Definition: RoomData.h:58
int adjoiningRoom
Definition: RoomData.h:93
glm::vec3 corner[8]
Definition: RoomData.h:46
glm::vec3 getCorner(int i)
Definition: RoomData.h:37
glm::vec3 vert[4]
Definition: RoomData.h:95
bool wall
Definition: RoomData.h:110
Portal(int adj, glm::vec3 n, glm::vec3 v1, glm::vec3 v2, glm::vec3 v3, glm::vec3 v4)
Definition: RoomData.h:78
void display(glm::mat4 VP)
Definition: RoomData.cpp:72
glm::vec3 normal
Definition: RoomData.h:94
int sprite
Definition: RoomData.h:71
float ceiling
Definition: RoomData.h:109
RoomSprite(glm::vec3 p, int s)
Definition: RoomData.h:66
StaticModel(glm::vec3 pos, float angle, int i)
Definition: RoomData.cpp:66
glm::vec3 getVertex(int i)
Definition: RoomData.h:86
#define assertGreaterThanEqual(x, y)
Definition: global.h:170
bool inBox(glm::vec3 p)
Definition: RoomData.h:27
glm::mat4 model
Definition: RoomData.h:59
glm::vec3 pos
Definition: RoomData.h:70
float getCeiling()
Definition: RoomData.cpp:102
int getAdjoiningRoom()
Definition: RoomData.h:83
#define assertLessThan(x, y)
Definition: global.h:146
float floor
Definition: RoomData.h:108
bool inBoxPlane(glm::vec3 p)
Definition: RoomData.h:32