12 #include <glm/gtc/matrix_transform.hpp>
13 #include <glm/gtx/intersect.hpp>
21 int a,
int x,
int z,
int i) : pos(_pos), bbox(_bbox), mesh(_mesh), flags(f),
22 alternateRoom(a), numXSectors(x), numZSectors(z), roomIndex(i) {
23 model = glm::translate(glm::mat4(1.0f),
pos);
27 glm::mat4 MVP = VP *
model;
45 bbox->display(VP, glm::vec3(0.0f, 1.0f, 0.0f), glm::vec3(1.0f, 0.0f, 1.0f));
52 return ((sector > 0) &&
sectors.at(sector)->isWall());
57 assert(ceiling !=
nullptr);
61 if ((sector >= 0) && (sector < (
long)
sectors.size())) {
62 *floor =
sectors.at(sector)->getFloor();
63 *ceiling =
sectors.at(sector)->getCeiling();
70 long sector = (((((int)x - (
int)
pos[0]) / 1024) *
81 if ((sector >= 0) && (sector < (
long)
sectors.size()))
82 *y =
sectors.at(sector)->getFloor();
86 float x2,
float y2,
float z2) {
87 glm::vec3 orig(x, y, z);
88 glm::vec3 dir(x2 - x, y2 - y, z2 - z);
91 for (
unsigned long i = 0; i <
portals.size(); i++) {
92 if ((glm::intersectLineTriangle(orig, dir,
portals.at(i)->getVertex(0),
94 portals.at(i)->getVertex(2), intersect))
95 || (glm::intersectLineTriangle(orig, dir,
portals.at(i)->getVertex(0),
97 portals.at(i)->getVertex(1), intersect)))
98 return portals.at(i)->getAdjoiningRoom();
void getHeightAtPosition(float x, float *y, float z)
bool isWall(unsigned long sector)
std::unique_ptr< RoomMesh > mesh
static bool showRoomGeometry
std::vector< std::unique_ptr< StaticModel > > models
static bool showBoundingBox
std::unique_ptr< BoundingBox > bbox
long getSector(float x, float z, float *floor, float *ceiling)
std::vector< std::unique_ptr< Sector > > sectors
std::vector< std::unique_ptr< RoomSprite > > sprites
#define assertLessThan(x, y)
Room(glm::vec3 _pos, BoundingBox *_bbox, RoomMesh *_mesh, unsigned int f, int a, int x, int z, int i)
void display(glm::mat4 VP)
static bool showRoomModels
std::vector< std::unique_ptr< Portal > > portals
int getAdjoiningRoom(float x, float y, float z, float x2, float y2, float z2)
static bool showRoomSprites