Browse Source

World static, more debug infos, portal rendering.

Thomas Buck 9 years ago
parent
commit
ea91c9484a
19 changed files with 318 additions and 159 deletions
  1. 6
    0
      ChangeLog.md
  2. 2
    0
      include/Room.h
  3. 13
    1
      include/RoomData.h
  4. 1
    0
      include/StaticMesh.h
  5. 31
    39
      include/World.h
  6. 9
    9
      src/Entity.cpp
  7. 8
    8
      src/Game.cpp
  8. 33
    17
      src/Render.cpp
  9. 46
    5
      src/Room.cpp
  10. 24
    4
      src/RoomData.cpp
  11. 1
    1
      src/SkeletalModel.cpp
  12. 1
    1
      src/Sprite.cpp
  13. 10
    1
      src/StaticMesh.cpp
  14. 9
    9
      src/TextureManager.cpp
  15. 4
    3
      src/UI.cpp
  16. 103
    38
      src/World.cpp
  17. 2
    2
      src/loader/LoaderTR1.cpp
  18. 14
    14
      src/loader/LoaderTR2.cpp
  19. 1
    7
      src/main.cpp

+ 6
- 0
ChangeLog.md View File

2
 
2
 
3
 ## OpenRaider (0.1.4) xythobuz <xythobuz@xythobuz.de>
3
 ## OpenRaider (0.1.4) xythobuz <xythobuz@xythobuz.de>
4
 
4
 
5
+    [ 20150404 ]
6
+    * World is now static
7
+    * Can display debug informations about Rooms and StaticMeshes
8
+    * Can now render portal outlines
9
+    * Building rendering list now also based on portal visibility
10
+
5
     [ 20150330 ]
11
     [ 20150330 ]
6
     * Removed custom Font support
12
     * Removed custom Font support
7
     * Some GL performance improvements
13
     * Some GL performance improvements

+ 2
- 0
include/Room.h View File

51
     unsigned long sizePortals() { return portals.size(); }
51
     unsigned long sizePortals() { return portals.size(); }
52
     Portal& getPortal(unsigned long index) { return *portals.at(index); }
52
     Portal& getPortal(unsigned long index) { return *portals.at(index); }
53
 
53
 
54
+    void displayUI();
55
+
54
     static void setShowBoundingBox(bool s) { showBoundingBox = s; }
56
     static void setShowBoundingBox(bool s) { showBoundingBox = s; }
55
     static bool getShowBoundingBox() { return showBoundingBox; }
57
     static bool getShowBoundingBox() { return showBoundingBox; }
56
 
58
 

+ 13
- 1
include/RoomData.h View File

52
   public:
52
   public:
53
     StaticModel(glm::vec3 pos, float angle, int i);
53
     StaticModel(glm::vec3 pos, float angle, int i);
54
     void display(glm::mat4 VP);
54
     void display(glm::mat4 VP);
55
+    void displayUI();
55
 
56
 
56
   private:
57
   private:
57
     int id;
58
     int id;
76
 class Portal {
77
 class Portal {
77
   public:
78
   public:
78
     Portal(int adj, glm::vec3 n, glm::vec3 v1, glm::vec3 v2, glm::vec3 v3,
79
     Portal(int adj, glm::vec3 n, glm::vec3 v1, glm::vec3 v2, glm::vec3 v3,
79
-           glm::vec3 v4) : adjoiningRoom(adj), normal(n) {
80
+           glm::vec3 v4) : adjoiningRoom(adj), normal(n), bbox(v1, v3) {
80
         vert[0] = v1; vert[1] = v2;
81
         vert[0] = v1; vert[1] = v2;
81
         vert[2] = v3; vert[3] = v4;
82
         vert[2] = v3; vert[3] = v4;
82
     }
83
     }
84
+
83
     int getAdjoiningRoom() { return adjoiningRoom; }
85
     int getAdjoiningRoom() { return adjoiningRoom; }
84
     glm::vec3 getNormal() { return normal; }
86
     glm::vec3 getNormal() { return normal; }
87
+    BoundingBox getBoundingBox() { return bbox; }
88
+
89
+    void display(glm::mat4 VP);
90
+    void displayUI();
85
 
91
 
86
     glm::vec3 getVertex(int i) {
92
     glm::vec3 getVertex(int i) {
87
         orAssertGreaterThanEqual(i, 0);
93
         orAssertGreaterThanEqual(i, 0);
89
         return vert[i];
95
         return vert[i];
90
     }
96
     }
91
 
97
 
98
+    static void setShowBoundingBox(bool s) { showBoundingBox = s; }
99
+    static bool getShowBoundingBox() { return showBoundingBox; }
100
+
92
   private:
101
   private:
93
     int adjoiningRoom;
102
     int adjoiningRoom;
94
     glm::vec3 normal;
103
     glm::vec3 normal;
95
     glm::vec3 vert[4];
104
     glm::vec3 vert[4];
105
+    BoundingBox bbox;
106
+
107
+    static bool showBoundingBox;
96
 };
108
 };
97
 
109
 
98
 // --------------------------------------
110
 // --------------------------------------

+ 1
- 0
include/StaticMesh.h View File

17
     StaticMesh(int i, int m, BoundingBox* b1, BoundingBox* b2)
17
     StaticMesh(int i, int m, BoundingBox* b1, BoundingBox* b2)
18
         : id(i), mesh(m), bbox1(b1), bbox2(b2) { }
18
         : id(i), mesh(m), bbox1(b1), bbox2(b2) { }
19
     void display(glm::mat4 MVP);
19
     void display(glm::mat4 MVP);
20
+    void displayUI();
20
 
21
 
21
     int getID() { return id; }
22
     int getID() { return id; }
22
 
23
 

+ 31
- 39
include/World.h View File

24
  */
24
  */
25
 class World {
25
 class World {
26
   public:
26
   public:
27
+    static void destroy();
27
 
28
 
28
-    /*!
29
-     * \brief Deconstructs an object of World
30
-     */
31
-    ~World();
29
+    static void addRoom(Room* room);
30
+    static unsigned long sizeRoom();
31
+    static Room& getRoom(unsigned long index);
32
 
32
 
33
-    /*!
34
-     * \brief Clears all data in world
35
-     */
36
-    void destroy();
33
+    static void addSprite(Sprite* sprite);
34
+    static unsigned long sizeSprite();
35
+    static Sprite& getSprite(unsigned long index);
37
 
36
 
38
-    void addRoom(Room* room);
39
-    unsigned long sizeRoom();
40
-    Room& getRoom(unsigned long index);
37
+    static void addSpriteSequence(SpriteSequence* sprite);
38
+    static unsigned long sizeSpriteSequence();
39
+    static SpriteSequence& getSpriteSequence(unsigned long index);
41
 
40
 
42
-    void addSprite(Sprite* sprite);
43
-    unsigned long sizeSprite();
44
-    Sprite& getSprite(unsigned long index);
41
+    static void addEntity(Entity* entity);
42
+    static unsigned long sizeEntity();
43
+    static Entity& getEntity(unsigned long index);
45
 
44
 
46
-    void addSpriteSequence(SpriteSequence* sprite);
47
-    unsigned long sizeSpriteSequence();
48
-    SpriteSequence& getSpriteSequence(unsigned long index);
45
+    static void addSkeletalModel(SkeletalModel* model);
46
+    static unsigned long sizeSkeletalModel();
47
+    static SkeletalModel& getSkeletalModel(unsigned long index);
49
 
48
 
50
-    void addEntity(Entity* entity);
51
-    unsigned long sizeEntity();
52
-    Entity& getEntity(unsigned long index);
49
+    static void addStaticMesh(StaticMesh* model);
50
+    static unsigned long sizeStaticMesh();
51
+    static StaticMesh& getStaticMesh(unsigned long index);
53
 
52
 
54
-    void addSkeletalModel(SkeletalModel* model);
55
-    unsigned long sizeSkeletalModel();
56
-    SkeletalModel& getSkeletalModel(unsigned long index);
53
+    static void addMesh(Mesh* mesh);
54
+    static unsigned long sizeMesh();
55
+    static Mesh& getMesh(unsigned long index);
57
 
56
 
58
-    void addStaticMesh(StaticMesh* model);
59
-    unsigned long sizeStaticMesh();
60
-    StaticMesh& getStaticMesh(unsigned long index);
61
-
62
-    void addMesh(Mesh* mesh);
63
-    unsigned long sizeMesh();
64
-    Mesh& getMesh(unsigned long index);
57
+    static void displayUI();
65
 
58
 
66
   private:
59
   private:
67
-    std::vector<std::unique_ptr<Room>> mRooms;
68
-    std::vector<std::unique_ptr<Sprite>> mSprites;
69
-    std::vector<std::unique_ptr<SpriteSequence>> mSpriteSequences;
70
-    std::vector<std::unique_ptr<Entity>> mEntities;
71
-    std::vector<std::unique_ptr<SkeletalModel>> mModels;
72
-    std::vector<std::unique_ptr<StaticMesh>> mStaticMeshes;
73
-    std::vector<std::unique_ptr<Mesh>> mMeshes;
60
+    static std::vector<std::unique_ptr<Room>> rooms;
61
+    static std::vector<std::unique_ptr<Sprite>> sprites;
62
+    static std::vector<std::unique_ptr<SpriteSequence>> spriteSequences;
63
+    static std::vector<std::unique_ptr<Entity>> entities;
64
+    static std::vector<std::unique_ptr<SkeletalModel>> models;
65
+    static std::vector<std::unique_ptr<StaticMesh>> staticMeshes;
66
+    static std::vector<std::unique_ptr<Mesh>> meshes;
74
 };
67
 };
75
 
68
 
76
-World& getWorld();
77
-
78
 #endif
69
 #endif
70
+

+ 9
- 9
src/Entity.cpp View File

30
          * be displayed wrong (eg. 'bad guy' becomes 'clothes' in tr2/boat)...
30
          * be displayed wrong (eg. 'bad guy' becomes 'clothes' in tr2/boat)...
31
          */
31
          */
32
 
32
 
33
-        for (int i = 0; (i < getWorld().sizeSkeletalModel()) && (cache == -1); i++) {
34
-            auto& s = getWorld().getSkeletalModel(i);
33
+        for (int i = 0; (i < World::sizeSkeletalModel()) && (cache == -1); i++) {
34
+            auto& s = World::getSkeletalModel(i);
35
             if (s.getID() == id) {
35
             if (s.getID() == id) {
36
                 cacheType = CACHE_MODEL;
36
                 cacheType = CACHE_MODEL;
37
                 cache = i;
37
                 cache = i;
39
             }
39
             }
40
         }
40
         }
41
 
41
 
42
-        for (int i = 0; (i < getWorld().sizeStaticMesh()) && (cache == -1); i++) {
43
-            auto& s = getWorld().getStaticMesh(i);
42
+        for (int i = 0; (i < World::sizeStaticMesh()) && (cache == -1); i++) {
43
+            auto& s = World::getStaticMesh(i);
44
             if (s.getID() == id) {
44
             if (s.getID() == id) {
45
                 cacheType = CACHE_MESH;
45
                 cacheType = CACHE_MESH;
46
                 cache = i;
46
                 cache = i;
48
             }
48
             }
49
         }
49
         }
50
 
50
 
51
-        for (int i = 0; i < getWorld().sizeSpriteSequence(); i++) {
52
-            auto& s = getWorld().getSpriteSequence(i);
51
+        for (int i = 0; i < World::sizeSpriteSequence(); i++) {
52
+            auto& s = World::getSpriteSequence(i);
53
             if (s.getID() == id) {
53
             if (s.getID() == id) {
54
                 cacheType = CACHE_SPRITE;
54
                 cacheType = CACHE_SPRITE;
55
                 cache = i;
55
                 cache = i;
73
 
73
 
74
     if (cacheType == CACHE_SPRITE) {
74
     if (cacheType == CACHE_SPRITE) {
75
         if (showEntitySprites)
75
         if (showEntitySprites)
76
-            getWorld().getSpriteSequence(cache).display(MVP, sprite);
76
+            World::getSpriteSequence(cache).display(MVP, sprite);
77
     } else if (cacheType == CACHE_MESH) {
77
     } else if (cacheType == CACHE_MESH) {
78
         if (showEntityMeshes)
78
         if (showEntityMeshes)
79
-            getWorld().getStaticMesh(cache).display(MVP);
79
+            World::getStaticMesh(cache).display(MVP);
80
     } else if (cacheType == CACHE_MODEL) {
80
     } else if (cacheType == CACHE_MODEL) {
81
         if (showEntityModels)
81
         if (showEntityModels)
82
-            getWorld().getSkeletalModel(cache).display(MVP, animation, frame);
82
+            World::getSkeletalModel(cache).display(MVP, animation, frame);
83
     }
83
     }
84
 }
84
 }
85
 
85
 

+ 8
- 8
src/Game.cpp View File

35
     Render::clearRoomList();
35
     Render::clearRoomList();
36
     SoundManager::clear();
36
     SoundManager::clear();
37
     TextureManager::clear();
37
     TextureManager::clear();
38
-    getWorld().destroy();
38
+    World::destroy();
39
 }
39
 }
40
 
40
 
41
 int Game::loadLevel(std::string level) {
41
 int Game::loadLevel(std::string level) {
51
             return -2;
51
             return -2;
52
         }
52
         }
53
 
53
 
54
-        for (int i = 0; i < getWorld().sizeMesh(); i++) {
55
-            getWorld().getMesh(i).prepare();
54
+        for (int i = 0; i < World::sizeMesh(); i++) {
55
+            World::getMesh(i).prepare();
56
         }
56
         }
57
 
57
 
58
-        for (int i = 0; i < getWorld().sizeRoom(); i++) {
59
-            getWorld().getRoom(i).prepare();
58
+        for (int i = 0; i < World::sizeRoom(); i++) {
59
+            World::getRoom(i).prepare();
60
         }
60
         }
61
 
61
 
62
         SoundManager::prepareSources();
62
         SoundManager::prepareSources();
114
 
114
 
115
 Entity& Game::getLara() {
115
 Entity& Game::getLara() {
116
     orAssertGreaterThanEqual(mLara, 0);
116
     orAssertGreaterThanEqual(mLara, 0);
117
-    orAssertLessThan(mLara, getWorld().sizeEntity());
118
-    return getWorld().getEntity(mLara);
117
+    orAssertLessThan(mLara, World::sizeEntity());
118
+    return World::getEntity(mLara);
119
 }
119
 }
120
 
120
 
121
 void Game::setLara(long lara) {
121
 void Game::setLara(long lara) {
122
     orAssertGreaterThanEqual(lara, 0);
122
     orAssertGreaterThanEqual(lara, 0);
123
-    orAssertLessThan(lara, getWorld().sizeEntity());
123
+    orAssertLessThan(lara, World::sizeEntity());
124
     mLara = lara;
124
     mLara = lara;
125
 }
125
 }
126
 
126
 

+ 33
- 17
src/Render.cpp View File

68
     for (int r = roomList.size() - 1; r >= 0; r--) {
68
     for (int r = roomList.size() - 1; r >= 0; r--) {
69
         roomList.at(r)->display(VP);
69
         roomList.at(r)->display(VP);
70
 
70
 
71
-        for (int i = 0; i < getWorld().sizeEntity(); i++) {
72
-            auto& e = getWorld().getEntity(i);
71
+        for (int i = 0; i < World::sizeEntity(); i++) {
72
+            auto& e = World::getEntity(i);
73
             if (roomList.at(r)->getIndex() == e.getRoom()) {
73
             if (roomList.at(r)->getIndex() == e.getRoom()) {
74
                 e.display(VP);
74
                 e.display(VP);
75
             }
75
             }
87
 void Render::buildRoomList(int room, int budget) {
87
 void Render::buildRoomList(int room, int budget) {
88
     if (room < -1) {
88
     if (room < -1) {
89
         // Check if the camera currently is in a room...
89
         // Check if the camera currently is in a room...
90
-        for (int i = 0; i < getWorld().sizeRoom(); i++) {
91
-            if (getWorld().getRoom(i).getBoundingBox().inBox(Camera::getPosition())) {
90
+        for (int i = 0; i < World::sizeRoom(); i++) {
91
+            if (World::getRoom(i).getBoundingBox().inBox(Camera::getPosition())) {
92
                 buildRoomList(i, budget);
92
                 buildRoomList(i, budget);
93
                 return;
93
                 return;
94
             }
94
             }
96
         buildRoomList(-1, budget);
96
         buildRoomList(-1, budget);
97
     } else if (room == -1) {
97
     } else if (room == -1) {
98
         // Check visibility for all rooms!
98
         // Check visibility for all rooms!
99
-        for (int i = 0; i < getWorld().sizeRoom(); i++) {
100
-            if (Camera::boxInFrustum(getWorld().getRoom(i).getBoundingBox())) {
101
-                roomList.push_back(&getWorld().getRoom(i));
99
+        for (int i = 0; i < World::sizeRoom(); i++) {
100
+            if (Camera::boxInFrustum(World::getRoom(i).getBoundingBox())) {
101
+                roomList.push_back(&World::getRoom(i));
102
             }
102
             }
103
         }
103
         }
104
     } else {
104
     } else {
105
         // Check visibility of room and connected rooms, recursively
105
         // Check visibility of room and connected rooms, recursively
106
-        if (Camera::boxInFrustum(getWorld().getRoom(room).getBoundingBox())) {
107
-            roomList.push_back(&getWorld().getRoom(room));
108
-            for (int i = 0; i < getWorld().getRoom(room).sizePortals(); i++) {
109
-                int r = getWorld().getRoom(room).getPortal(i).getAdjoiningRoom();
106
+        if (Camera::boxInFrustum(World::getRoom(room).getBoundingBox())) {
107
+            roomList.push_back(&World::getRoom(room));
108
+            for (int i = 0; i < World::getRoom(room).sizePortals(); i++) {
109
+                auto& portal = World::getRoom(room).getPortal(i);
110
+
111
+                // Check if portal is visible / can be seen through
112
+                bool visible = Camera::boxInFrustum(portal.getBoundingBox());
113
+                if (!visible) {
114
+                    continue;
115
+                }
116
+
117
+                // Check if already in list...
110
                 bool found = false;
118
                 bool found = false;
111
                 for (int n = 0; n < roomList.size(); n++) {
119
                 for (int n = 0; n < roomList.size(); n++) {
112
-                    if (roomList.at(n) == &getWorld().getRoom(r)) {
120
+                    if (roomList.at(n) == &World::getRoom(portal.getAdjoiningRoom())) {
113
                         found = true;
121
                         found = true;
114
                         break;
122
                         break;
115
                     }
123
                     }
116
                 }
124
                 }
125
+
126
+                // ...only render if not
117
                 if (!found) {
127
                 if (!found) {
118
                     if (budget > 0) {
128
                     if (budget > 0) {
119
-                        buildRoomList(r, --budget);
129
+                        buildRoomList(portal.getAdjoiningRoom(), --budget);
120
                     }
130
                     }
121
                 }
131
                 }
122
             }
132
             }
201
         if (ImGui::Checkbox("Overlay", &showOverlay)) {
211
         if (ImGui::Checkbox("Overlay", &showOverlay)) {
202
             Camera::setShowOverlay(showOverlay);
212
             Camera::setShowOverlay(showOverlay);
203
         }
213
         }
204
-        if (ImGui::Button("Reset Room ID")) {
205
-            Camera::setRoom(-1);
214
+        glm::vec3 camPos = Camera::getPosition();
215
+        if (ImGui::SliderFloat3("Position", &camPos.x, -100000, 100000)) {
216
+            Camera::setPosition(camPos);
206
         }
217
         }
207
 
218
 
208
         ImGui::Separator();
219
         ImGui::Separator();
209
         ImGui::Text("Bounding Boxes:");
220
         ImGui::Text("Bounding Boxes:");
210
         bool showBoundingBox = Room::getShowBoundingBox();
221
         bool showBoundingBox = Room::getShowBoundingBox();
211
-        if (ImGui::Checkbox("Room##bbox", &showBoundingBox)) {
222
+        if (ImGui::Checkbox("Rooms##bbox", &showBoundingBox)) {
212
             Room::setShowBoundingBox(showBoundingBox);
223
             Room::setShowBoundingBox(showBoundingBox);
213
         }
224
         }
214
         ImGui::SameLine();
225
         ImGui::SameLine();
215
         bool showBoundingBox2 = StaticMesh::getShowBoundingBox();
226
         bool showBoundingBox2 = StaticMesh::getShowBoundingBox();
216
-        if (ImGui::Checkbox("StaticMesh##bbox", &showBoundingBox2)) {
227
+        if (ImGui::Checkbox("StaticMeshes##bbox", &showBoundingBox2)) {
217
             StaticMesh::setShowBoundingBox(showBoundingBox2);
228
             StaticMesh::setShowBoundingBox(showBoundingBox2);
218
         }
229
         }
230
+        ImGui::SameLine();
231
+        bool showBoundingBox3 = Portal::getShowBoundingBox();
232
+        if (ImGui::Checkbox("Portals##bbox", &showBoundingBox3)) {
233
+            Portal::setShowBoundingBox(showBoundingBox3);
234
+        }
219
 
235
 
220
         ImGui::Separator();
236
         ImGui::Separator();
221
         ImGui::Text("Renderable Objects:");
237
         ImGui::Text("Renderable Objects:");

+ 46
- 5
src/Room.cpp View File

9
 #include "Log.h"
9
 #include "Log.h"
10
 #include "Room.h"
10
 #include "Room.h"
11
 
11
 
12
+#include "imgui/imgui.h"
13
+
12
 #include <glm/gtc/matrix_transform.hpp>
14
 #include <glm/gtc/matrix_transform.hpp>
13
 #include <glm/gtx/intersect.hpp>
15
 #include <glm/gtx/intersect.hpp>
14
 
16
 
24
 }
26
 }
25
 
27
 
26
 void Room::display(glm::mat4 VP) {
28
 void Room::display(glm::mat4 VP) {
27
-    glm::mat4 MVP = VP * model;
28
-
29
-    if (showRoomGeometry)
30
-        mesh->display(MVP);
29
+    if (showRoomGeometry) {
30
+        mesh->display(VP * model);
31
+    }
31
 
32
 
32
     if (showRoomModels) {
33
     if (showRoomModels) {
33
         for (auto& m : models) {
34
         for (auto& m : models) {
41
         }
42
         }
42
     }
43
     }
43
 
44
 
44
-    if (showBoundingBox)
45
+    if (showBoundingBox) {
45
         bbox->display(VP, glm::vec3(0.0f, 1.0f, 0.0f), glm::vec3(1.0f, 0.0f, 1.0f));
46
         bbox->display(VP, glm::vec3(0.0f, 1.0f, 0.0f), glm::vec3(1.0f, 0.0f, 1.0f));
47
+    }
48
+
49
+    if (Portal::getShowBoundingBox()) {
50
+        for (auto& p : portals) {
51
+            p->display(VP);
52
+        }
53
+    }
46
 }
54
 }
47
 
55
 
48
 bool Room::isWall(unsigned long sector) {
56
 bool Room::isWall(unsigned long sector) {
101
     return -1;
109
     return -1;
102
 }
110
 }
103
 
111
 
112
+void Room::displayUI() {
113
+    ImGui::PushID(roomIndex);
114
+    ImGui::Text("%03d", roomIndex);
115
+    ImGui::NextColumn();
116
+    ImGui::Text("%03d", alternateRoom);
117
+    ImGui::NextColumn();
118
+    ImGui::Text("0x%04X", flags);
119
+    ImGui::NextColumn();
120
+    if (models.size() > 0) {
121
+        if (ImGui::TreeNode("...##model")) {
122
+            for (auto& m : models) {
123
+                m->displayUI();
124
+            }
125
+            ImGui::TreePop();
126
+        }
127
+    } else {
128
+        ImGui::Text("None");
129
+    }
130
+    ImGui::NextColumn();
131
+    if (portals.size() > 0) {
132
+        if (ImGui::TreeNode("...##portal")) {
133
+            for (auto& p : portals) {
134
+                p->displayUI();
135
+            }
136
+            ImGui::TreePop();
137
+        }
138
+    } else {
139
+        ImGui::Text("None");
140
+    }
141
+    ImGui::NextColumn();
142
+    ImGui::PopID();
143
+}
144
+

+ 24
- 4
src/RoomData.cpp View File

11
 #include "system/Shader.h"
11
 #include "system/Shader.h"
12
 #include "RoomData.h"
12
 #include "RoomData.h"
13
 
13
 
14
+#include "imgui/imgui.h"
15
+
14
 #include <glbinding/gl/gl33.h>
16
 #include <glbinding/gl/gl33.h>
15
 #include <glm/gtc/matrix_transform.hpp>
17
 #include <glm/gtc/matrix_transform.hpp>
16
 
18
 
64
 
66
 
65
 void StaticModel::display(glm::mat4 VP) {
67
 void StaticModel::display(glm::mat4 VP) {
66
     if (cache < 0) {
68
     if (cache < 0) {
67
-        for (int i = 0; i < getWorld().sizeStaticMesh(); i++) {
68
-            if (getWorld().getStaticMesh(i).getID() == id) {
69
+        for (int i = 0; i < World::sizeStaticMesh(); i++) {
70
+            if (World::getStaticMesh(i).getID() == id) {
69
                 cache = i;
71
                 cache = i;
70
             }
72
             }
71
         }
73
         }
72
         orAssertGreaterThanEqual(cache, 0);
74
         orAssertGreaterThanEqual(cache, 0);
73
     }
75
     }
74
 
76
 
75
-    getWorld().getStaticMesh(cache).display(VP * model);
77
+    World::getStaticMesh(cache).display(VP * model);
78
+}
79
+
80
+void StaticModel::displayUI() {
81
+    ImGui::Text("ID %d; No. %d", id, cache);
76
 }
82
 }
77
 
83
 
78
 // ----------------------------------------------------------------------------
84
 // ----------------------------------------------------------------------------
83
                                    0.0f));
89
                                    0.0f));
84
     glm::mat4 model = translate * rotate;
90
     glm::mat4 model = translate * rotate;
85
 
91
 
86
-    getWorld().getSprite(sprite).display(VP * model);
92
+    World::getSprite(sprite).display(VP * model);
93
+}
94
+
95
+// ----------------------------------------------------------------------------
96
+
97
+bool Portal::showBoundingBox = false;
98
+
99
+void Portal::display(glm::mat4 VP) {
100
+    if (showBoundingBox) {
101
+        bbox.display(VP, glm::vec3(1.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f));
102
+    }
103
+}
104
+
105
+void Portal::displayUI() {
106
+    ImGui::Text("To %03d", adjoiningRoom);
87
 }
107
 }
88
 
108
 
89
 // ----------------------------------------------------------------------------
109
 // ----------------------------------------------------------------------------

+ 1
- 1
src/SkeletalModel.cpp View File

14
 #include <glm/gtc/matrix_transform.hpp>
14
 #include <glm/gtc/matrix_transform.hpp>
15
 
15
 
16
 void BoneTag::display(glm::mat4 MVP, ShaderTexture* shaderTexture) {
16
 void BoneTag::display(glm::mat4 MVP, ShaderTexture* shaderTexture) {
17
-    getWorld().getMesh(mesh).display(MVP, shaderTexture);
17
+    World::getMesh(mesh).display(MVP, shaderTexture);
18
 }
18
 }
19
 
19
 
20
 // ----------------------------------------------------------------------------
20
 // ----------------------------------------------------------------------------

+ 1
- 1
src/Sprite.cpp View File

49
 void SpriteSequence::display(glm::mat4 MVP, int index) {
49
 void SpriteSequence::display(glm::mat4 MVP, int index) {
50
     orAssertGreaterThanEqual(index, 0);
50
     orAssertGreaterThanEqual(index, 0);
51
     orAssertLessThan(index, length);
51
     orAssertLessThan(index, length);
52
-    getWorld().getSprite(start + index).display(MVP);
52
+    World::getSprite(start + index).display(MVP);
53
 }
53
 }
54
 
54
 

+ 10
- 1
src/StaticMesh.cpp View File

9
 #include "World.h"
9
 #include "World.h"
10
 #include "StaticMesh.h"
10
 #include "StaticMesh.h"
11
 
11
 
12
+#include "imgui/imgui.h"
13
+
12
 bool StaticMesh::showBoundingBox = false;
14
 bool StaticMesh::showBoundingBox = false;
13
 
15
 
14
 void StaticMesh::display(glm::mat4 MVP) {
16
 void StaticMesh::display(glm::mat4 MVP) {
15
-    getWorld().getMesh(mesh).display(MVP);
17
+    World::getMesh(mesh).display(MVP);
16
 
18
 
17
     if (showBoundingBox) {
19
     if (showBoundingBox) {
18
         bbox1->display(MVP, glm::vec3(1.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f));
20
         bbox1->display(MVP, glm::vec3(1.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f));
20
     }
22
     }
21
 }
23
 }
22
 
24
 
25
+void StaticMesh::displayUI() {
26
+    ImGui::Text("%03d", id);
27
+    ImGui::NextColumn();
28
+    ImGui::Text("%03d // and two bboxes", mesh);
29
+    ImGui::NextColumn();
30
+}
31
+

+ 9
- 9
src/TextureManager.cpp View File

543
     }
543
     }
544
 
544
 
545
     if (ImGui::CollapsingHeader("Sprite Sequence Viewer")) {
545
     if (ImGui::CollapsingHeader("Sprite Sequence Viewer")) {
546
-        if (getWorld().sizeSprite() <= 0) {
546
+        if (World::sizeSprite() <= 0) {
547
             ImGui::Text("Please load a level containing sprites!");
547
             ImGui::Text("Please load a level containing sprites!");
548
         } else {
548
         } else {
549
             static int index = 0;
549
             static int index = 0;
550
             static int sprite = 0;
550
             static int sprite = 0;
551
-            if (ImGui::SliderInt("##spriteslide", &index, 0, getWorld().sizeSpriteSequence() - 1)) {
551
+            if (ImGui::SliderInt("##spriteslide", &index, 0, World::sizeSpriteSequence() - 1)) {
552
                 sprite = 0;
552
                 sprite = 0;
553
             }
553
             }
554
             ImGui::SameLine();
554
             ImGui::SameLine();
555
             if (ImGui::Button("+##spriteplus", ImVec2(0, 0), true)) {
555
             if (ImGui::Button("+##spriteplus", ImVec2(0, 0), true)) {
556
-                if (index < (getWorld().sizeSpriteSequence() - 1))
556
+                if (index < (World::sizeSpriteSequence() - 1))
557
                     index++;
557
                     index++;
558
                 else
558
                 else
559
                     index = 0;
559
                     index = 0;
564
                 if (index > 0)
564
                 if (index > 0)
565
                     index--;
565
                     index--;
566
                 else
566
                 else
567
-                    index = getWorld().sizeSpriteSequence() - 1;
567
+                    index = World::sizeSpriteSequence() - 1;
568
                 sprite = 0;
568
                 sprite = 0;
569
             }
569
             }
570
 
570
 
571
-            if (index >= getWorld().sizeSpriteSequence()) {
571
+            if (index >= World::sizeSpriteSequence()) {
572
                 index = 0;
572
                 index = 0;
573
                 sprite = 0;
573
                 sprite = 0;
574
             }
574
             }
575
 
575
 
576
-            if (sprite >= getWorld().getSpriteSequence(index).size()) {
576
+            if (sprite >= World::getSpriteSequence(index).size()) {
577
                 sprite = 0;
577
                 sprite = 0;
578
             }
578
             }
579
 
579
 
580
             ImGui::SameLine();
580
             ImGui::SameLine();
581
-            ImGui::Text("Sprite %d/%d", sprite + 1, getWorld().getSpriteSequence(index).size());
581
+            ImGui::Text("Sprite %d/%d", sprite + 1, World::getSpriteSequence(index).size());
582
 
582
 
583
-            auto& s = getWorld().getSprite(getWorld().getSpriteSequence(index).getStart() + sprite);
583
+            auto& s = World::getSprite(World::getSpriteSequence(index).getStart() + sprite);
584
             auto bm = getBufferManager(s.getTexture(), TextureStorage::GAME);
584
             auto bm = getBufferManager(s.getTexture(), TextureStorage::GAME);
585
             ImVec2 size(ImGui::GetColumnWidth() * 2 / 3, ImGui::GetColumnWidth() * 2 / 3);
585
             ImVec2 size(ImGui::GetColumnWidth() * 2 / 3, ImGui::GetColumnWidth() * 2 / 3);
586
             auto uv = s.getUVs();
586
             auto uv = s.getUVs();
593
                 fr--;
593
                 fr--;
594
             } else {
594
             } else {
595
                 fr = RunTime::getFPS() / 10;
595
                 fr = RunTime::getFPS() / 10;
596
-                if (sprite < (getWorld().getSpriteSequence(index).size() - 1))
596
+                if (sprite < (World::getSpriteSequence(index).size() - 1))
597
                     sprite++;
597
                     sprite++;
598
                 else
598
                 else
599
                     sprite = 0;
599
                     sprite = 0;

+ 4
- 3
src/UI.cpp View File

255
         RunTime::display();
255
         RunTime::display();
256
         TextureManager::display();
256
         TextureManager::display();
257
         SoundManager::display();
257
         SoundManager::display();
258
+        World::displayUI();
258
 
259
 
259
         if (ImGui::CollapsingHeader("Library Versions")) {
260
         if (ImGui::CollapsingHeader("Library Versions")) {
260
             ImGui::TextWrapped("%s", VERSION);
261
             ImGui::TextWrapped("%s", VERSION);
287
         if (ImGui::CollapsingHeader("ShaderTexture Test")) {
288
         if (ImGui::CollapsingHeader("ShaderTexture Test")) {
288
             static ShaderTexture* st = nullptr;
289
             static ShaderTexture* st = nullptr;
289
             static int index = 0;
290
             static int index = 0;
290
-            ImGui::SliderInt("SkeletalModel", &index, 0, getWorld().sizeSkeletalModel() - 1);
291
+            ImGui::SliderInt("SkeletalModel", &index, 0, World::sizeSkeletalModel() - 1);
291
 
292
 
292
             static glm::mat4 MVP(1.0f);
293
             static glm::mat4 MVP(1.0f);
293
             static bool dirty = true, redraw = false;
294
             static bool dirty = true, redraw = false;
322
                 dirty = false;
323
                 dirty = false;
323
             }
324
             }
324
 
325
 
325
-            if ((index >= 0) && (index < getWorld().sizeSkeletalModel())) {
326
-                auto& sm = getWorld().getSkeletalModel(index);
326
+            if ((index >= 0) && (index < World::sizeSkeletalModel())) {
327
+                auto& sm = World::getSkeletalModel(index);
327
                 if ((sm.size() > 0) && (sm.get(0).size() > 0)) {
328
                 if ((sm.size() > 0) && (sm.get(0).size() > 0)) {
328
                     if (ImGui::Button("(Re)Create ShaderTexture...")) {
329
                     if (ImGui::Button("(Re)Create ShaderTexture...")) {
329
                         if (st != nullptr) {
330
                         if (st != nullptr) {

+ 103
- 38
src/World.cpp View File

8
 #include "global.h"
8
 #include "global.h"
9
 #include "World.h"
9
 #include "World.h"
10
 
10
 
11
-World::~World() {
12
-    destroy();
13
-}
11
+#include "imgui/imgui.h"
12
+
13
+std::vector<std::unique_ptr<Room>> World::rooms;
14
+std::vector<std::unique_ptr<Sprite>> World::sprites;
15
+std::vector<std::unique_ptr<SpriteSequence>> World::spriteSequences;
16
+std::vector<std::unique_ptr<Entity>> World::entities;
17
+std::vector<std::unique_ptr<SkeletalModel>> World::models;
18
+std::vector<std::unique_ptr<StaticMesh>> World::staticMeshes;
19
+std::vector<std::unique_ptr<Mesh>> World::meshes;
14
 
20
 
15
 void World::destroy() {
21
 void World::destroy() {
16
-    mRooms.clear();
17
-    mSprites.clear();
18
-    mSpriteSequences.clear();
19
-    mEntities.clear();
20
-    mModels.clear();
21
-    mStaticMeshes.clear();
22
-    mMeshes.clear();
22
+    rooms.clear();
23
+    sprites.clear();
24
+    spriteSequences.clear();
25
+    entities.clear();
26
+    models.clear();
27
+    staticMeshes.clear();
28
+    meshes.clear();
23
 }
29
 }
24
 
30
 
25
 void World::addRoom(Room* room) {
31
 void World::addRoom(Room* room) {
26
-    mRooms.emplace_back(std::unique_ptr<Room>(room));
32
+    rooms.emplace_back(std::unique_ptr<Room>(room));
27
 }
33
 }
28
 
34
 
29
 unsigned long World::sizeRoom() {
35
 unsigned long World::sizeRoom() {
30
-    return mRooms.size();
36
+    return rooms.size();
31
 }
37
 }
32
 
38
 
33
 Room& World::getRoom(unsigned long index) {
39
 Room& World::getRoom(unsigned long index) {
34
-    orAssertLessThan(index, mRooms.size());
35
-    return *mRooms.at(index);
40
+    orAssertLessThan(index, rooms.size());
41
+    return *rooms.at(index);
36
 }
42
 }
37
 
43
 
38
 void World::addSprite(Sprite* sprite) {
44
 void World::addSprite(Sprite* sprite) {
39
-    mSprites.emplace_back(std::unique_ptr<Sprite>(sprite));
45
+    sprites.emplace_back(std::unique_ptr<Sprite>(sprite));
40
 }
46
 }
41
 
47
 
42
 unsigned long World::sizeSprite() {
48
 unsigned long World::sizeSprite() {
43
-    return mSprites.size();
49
+    return sprites.size();
44
 }
50
 }
45
 
51
 
46
 Sprite& World::getSprite(unsigned long index) {
52
 Sprite& World::getSprite(unsigned long index) {
47
-    orAssertLessThan(index, mSprites.size());
48
-    return *mSprites.at(index);
53
+    orAssertLessThan(index, sprites.size());
54
+    return *sprites.at(index);
49
 }
55
 }
50
 
56
 
51
 void World::addSpriteSequence(SpriteSequence* sprite) {
57
 void World::addSpriteSequence(SpriteSequence* sprite) {
52
-    mSpriteSequences.emplace_back(std::unique_ptr<SpriteSequence>(sprite));
58
+    spriteSequences.emplace_back(std::unique_ptr<SpriteSequence>(sprite));
53
 }
59
 }
54
 
60
 
55
 unsigned long World::sizeSpriteSequence() {
61
 unsigned long World::sizeSpriteSequence() {
56
-    return mSpriteSequences.size();
62
+    return spriteSequences.size();
57
 }
63
 }
58
 
64
 
59
 SpriteSequence& World::getSpriteSequence(unsigned long index) {
65
 SpriteSequence& World::getSpriteSequence(unsigned long index) {
60
-    orAssertLessThan(index, mSpriteSequences.size());
61
-    return *mSpriteSequences.at(index);
66
+    orAssertLessThan(index, spriteSequences.size());
67
+    return *spriteSequences.at(index);
62
 }
68
 }
63
 
69
 
64
 void World::addEntity(Entity* entity) {
70
 void World::addEntity(Entity* entity) {
65
-    mEntities.emplace_back(std::unique_ptr<Entity>(entity));
71
+    entities.emplace_back(std::unique_ptr<Entity>(entity));
66
 }
72
 }
67
 
73
 
68
 unsigned long World::sizeEntity() {
74
 unsigned long World::sizeEntity() {
69
-    return mEntities.size();
75
+    return entities.size();
70
 }
76
 }
71
 
77
 
72
 Entity& World::getEntity(unsigned long index) {
78
 Entity& World::getEntity(unsigned long index) {
73
-    orAssertLessThan(index, mEntities.size());
74
-    return *mEntities.at(index);
79
+    orAssertLessThan(index, entities.size());
80
+    return *entities.at(index);
75
 }
81
 }
76
 
82
 
77
 void World::addSkeletalModel(SkeletalModel* model) {
83
 void World::addSkeletalModel(SkeletalModel* model) {
78
-    mModels.emplace_back(std::unique_ptr<SkeletalModel>(model));
84
+    models.emplace_back(std::unique_ptr<SkeletalModel>(model));
79
 }
85
 }
80
 
86
 
81
 unsigned long World::sizeSkeletalModel() {
87
 unsigned long World::sizeSkeletalModel() {
82
-    return mModels.size();
88
+    return models.size();
83
 }
89
 }
84
 
90
 
85
 SkeletalModel& World::getSkeletalModel(unsigned long index) {
91
 SkeletalModel& World::getSkeletalModel(unsigned long index) {
86
-    orAssertLessThan(index, mModels.size());
87
-    return *mModels.at(index);
92
+    orAssertLessThan(index, models.size());
93
+    return *models.at(index);
88
 }
94
 }
89
 
95
 
90
 void World::addStaticMesh(StaticMesh* model) {
96
 void World::addStaticMesh(StaticMesh* model) {
91
-    mStaticMeshes.emplace_back(std::unique_ptr<StaticMesh>(model));
97
+    staticMeshes.emplace_back(std::unique_ptr<StaticMesh>(model));
92
 }
98
 }
93
 
99
 
94
 unsigned long World::sizeStaticMesh() {
100
 unsigned long World::sizeStaticMesh() {
95
-    return mStaticMeshes.size();
101
+    return staticMeshes.size();
96
 }
102
 }
97
 
103
 
98
 StaticMesh& World::getStaticMesh(unsigned long index) {
104
 StaticMesh& World::getStaticMesh(unsigned long index) {
99
-    orAssertLessThan(index, mStaticMeshes.size());
100
-    return *mStaticMeshes.at(index);
105
+    orAssertLessThan(index, staticMeshes.size());
106
+    return *staticMeshes.at(index);
101
 }
107
 }
102
 
108
 
103
 void World::addMesh(Mesh* mesh) {
109
 void World::addMesh(Mesh* mesh) {
104
-    mMeshes.emplace_back(mesh);
110
+    meshes.emplace_back(mesh);
105
 }
111
 }
106
 
112
 
107
 unsigned long World::sizeMesh() {
113
 unsigned long World::sizeMesh() {
108
-    return mMeshes.size();
114
+    return meshes.size();
109
 }
115
 }
110
 
116
 
111
 Mesh& World::getMesh(unsigned long index) {
117
 Mesh& World::getMesh(unsigned long index) {
112
-    orAssertLessThan(index, mMeshes.size());
113
-    return *mMeshes.at(index);
118
+    orAssertLessThan(index, meshes.size());
119
+    return *meshes.at(index);
120
+}
121
+
122
+void World::displayUI() {
123
+    // Rooms
124
+    static bool offsets = false;
125
+    if (ImGui::CollapsingHeader("Rooms")) {
126
+        ImGui::Columns(6, "rooms");
127
+        ImGui::Text("No");
128
+        ImGui::NextColumn();
129
+        ImGui::Text("Ind.");
130
+        ImGui::NextColumn();
131
+        ImGui::Text("Alt.");
132
+        ImGui::NextColumn();
133
+        ImGui::Text("Flags");
134
+        ImGui::NextColumn();
135
+        ImGui::Text("Models");
136
+        ImGui::NextColumn();
137
+        ImGui::Text("Portals");
138
+        ImGui::NextColumn();
139
+        ImGui::Separator();
140
+        if (!offsets) {
141
+            ImGui::SetColumnOffset(1, 40.0f);
142
+            ImGui::SetColumnOffset(2, 80.0f);
143
+            ImGui::SetColumnOffset(3, 120.0f);
144
+            ImGui::SetColumnOffset(4, 180.0f);
145
+            ImGui::SetColumnOffset(5, 300.0f);
146
+            offsets = true;
147
+        }
148
+        for (int i = 0; i < rooms.size(); i++) {
149
+            ImGui::Text("%03d", i);
150
+            ImGui::NextColumn();
151
+            rooms.at(i)->displayUI();
152
+        }
153
+        ImGui::Columns(1);
154
+    }
155
+
156
+    // Static Meshes
157
+    static bool offsets2 = false;
158
+    if (ImGui::CollapsingHeader("StaticMeshes")) {
159
+        ImGui::Columns(3, "staticmeshes");
160
+        ImGui::Text("No");
161
+        ImGui::NextColumn();
162
+        ImGui::Text("ID");
163
+        ImGui::NextColumn();
164
+        ImGui::Text("Mesh");
165
+        ImGui::NextColumn();
166
+        ImGui::Separator();
167
+        if (!offsets2) {
168
+            ImGui::SetColumnOffset(1, 40.0f);
169
+            ImGui::SetColumnOffset(2, 80.0f);
170
+            offsets2 = true;
171
+        }
172
+        for (int i = 0; i < staticMeshes.size(); i++) {
173
+            ImGui::Text("%03d", i);
174
+            ImGui::NextColumn();
175
+            staticMeshes.at(i)->displayUI();
176
+        }
177
+        ImGui::Columns(1);
178
+    }
114
 }
179
 }
115
 
180
 

+ 2
- 2
src/loader/LoaderTR1.cpp View File

179
         );
179
         );
180
 
180
 
181
         Entity* e = new Entity(objectID, room, pos, rot);
181
         Entity* e = new Entity(objectID, room, pos, rot);
182
-        getWorld().addEntity(e);
182
+        World::addEntity(e);
183
 
183
 
184
         if (objectID == 0) {
184
         if (objectID == 0) {
185
-            Game::setLara(getWorld().sizeEntity() - 1);
185
+            Game::setLara(World::sizeEntity() - 1);
186
         }
186
         }
187
     }
187
     }
188
 
188
 

+ 14
- 14
src/loader/LoaderTR2.cpp View File

384
             // TODO translate vertices by room offset!
384
             // TODO translate vertices by room offset!
385
 
385
 
386
             portals.push_back(new Portal(adjoiningRoom,
386
             portals.push_back(new Portal(adjoiningRoom,
387
-                                         glm::vec3(xNormal, yNormal, zNormal),
388
-                                         glm::vec3(xCorner1, yCorner1, zCorner1),
389
-                                         glm::vec3(xCorner2, yCorner2, zCorner2),
390
-                                         glm::vec3(xCorner3, yCorner3, zCorner3),
391
-                                         glm::vec3(xCorner4, yCorner4, zCorner4)));
387
+                                         glm::vec3(xNormal, yNormal, zNormal) + pos,
388
+                                         glm::vec3(xCorner1, yCorner1, zCorner1) + pos,
389
+                                         glm::vec3(xCorner2, yCorner2, zCorner2) + pos,
390
+                                         glm::vec3(xCorner3, yCorner3, zCorner3) + pos,
391
+                                         glm::vec3(xCorner4, yCorner4, zCorner4) + pos));
392
         }
392
         }
393
 
393
 
394
         uint16_t numZSectors = file.readU16();
394
         uint16_t numZSectors = file.readU16();
446
         for (auto s : roomSprites)
446
         for (auto s : roomSprites)
447
             room->addSprite(s);
447
             room->addSprite(s);
448
 
448
 
449
-        getWorld().addRoom(room);
449
+        World::addRoom(room);
450
 
450
 
451
         // Sanity check
451
         // Sanity check
452
         if ((numPortals == 0) && (numVertices == 0)
452
         if ((numPortals == 0) && (numVertices == 0)
493
         int16_t bottomSide = file.read16();
493
         int16_t bottomSide = file.read16();
494
 
494
 
495
         Sprite* sp = new Sprite(tile, x, y, width, height);
495
         Sprite* sp = new Sprite(tile, x, y, width, height);
496
-        getWorld().addSprite(sp);
496
+        World::addSprite(sp);
497
     }
497
     }
498
 
498
 
499
     uint32_t numSpriteSequences = file.readU32();
499
     uint32_t numSpriteSequences = file.readU32();
507
         orAssertLessThanEqual(offset + (negativeLength * -1), numSpriteTextures);
507
         orAssertLessThanEqual(offset + (negativeLength * -1), numSpriteTextures);
508
 
508
 
509
         SpriteSequence* ss = new SpriteSequence(objectID, offset, (negativeLength * -1));
509
         SpriteSequence* ss = new SpriteSequence(objectID, offset, (negativeLength * -1));
510
-        getWorld().addSpriteSequence(ss);
510
+        World::addSpriteSequence(ss);
511
     }
511
     }
512
 
512
 
513
     if ((numSpriteTextures > 0) || (numSpriteSequences > 0))
513
     if ((numSpriteTextures > 0) || (numSpriteSequences > 0))
636
 
636
 
637
         Mesh* mesh = new Mesh(vertices, texturedRectangles, texturedTriangles,
637
         Mesh* mesh = new Mesh(vertices, texturedRectangles, texturedTriangles,
638
                               coloredRectangles, coloredTriangles);
638
                               coloredRectangles, coloredTriangles);
639
-        getWorld().addMesh(mesh);
639
+        World::addMesh(mesh);
640
     }
640
     }
641
 
641
 
642
     if (numMeshPointers > 0)
642
     if (numMeshPointers > 0)
675
 
675
 
676
         BoundingBox* bbox1 = new BoundingBox(glm::vec3(x11, y11, z11), glm::vec3(x12, y12, z12));
676
         BoundingBox* bbox1 = new BoundingBox(glm::vec3(x11, y11, z11), glm::vec3(x12, y12, z12));
677
         BoundingBox* bbox2 = new BoundingBox(glm::vec3(x21, y21, z21), glm::vec3(x22, y22, z22));
677
         BoundingBox* bbox2 = new BoundingBox(glm::vec3(x21, y21, z21), glm::vec3(x22, y22, z22));
678
-        getWorld().addStaticMesh(new StaticMesh(objectID, mesh, bbox1, bbox2));
678
+        World::addStaticMesh(new StaticMesh(objectID, mesh, bbox1, bbox2));
679
     }
679
     }
680
 
680
 
681
     if (numStaticMeshes > 0)
681
     if (numStaticMeshes > 0)
944
 
944
 
945
         SkeletalModel* sm = new SkeletalModel(objectID);
945
         SkeletalModel* sm = new SkeletalModel(objectID);
946
         sm->add(af);
946
         sm->add(af);
947
-        getWorld().addSkeletalModel(sm);
947
+        World::addSkeletalModel(sm);
948
         /*
948
         /*
949
         } else {
949
         } else {
950
             // TODO Add the whole animation hierarchy
950
             // TODO Add the whole animation hierarchy
962
 
962
 
963
             SkeletalModel* sm = new SkeletalModel(objectID);
963
             SkeletalModel* sm = new SkeletalModel(objectID);
964
             sm->add(af);
964
             sm->add(af);
965
-            getWorld().addSkeletalModel(sm);
965
+            World::addSkeletalModel(sm);
966
         }
966
         }
967
         */
967
         */
968
     }
968
     }
1005
         );
1005
         );
1006
 
1006
 
1007
         Entity* e = new Entity(objectID, room, pos, rot);
1007
         Entity* e = new Entity(objectID, room, pos, rot);
1008
-        getWorld().addEntity(e);
1008
+        World::addEntity(e);
1009
 
1009
 
1010
         if (objectID == 0) {
1010
         if (objectID == 0) {
1011
-            Game::setLara(getWorld().sizeEntity() - 1);
1011
+            Game::setLara(World::sizeEntity() - 1);
1012
         }
1012
         }
1013
     }
1013
     }
1014
 
1014
 

+ 1
- 7
src/main.cpp View File

28
 #include <glbinding/Binding.h>
28
 #include <glbinding/Binding.h>
29
 
29
 
30
 static std::string configFileToUse;
30
 static std::string configFileToUse;
31
-static std::shared_ptr<World> gWorld;
32
-
33
-World& getWorld() {
34
-    return *gWorld;
35
-}
36
 
31
 
37
 int main(int argc, char* argv[]) {
32
 int main(int argc, char* argv[]) {
38
     command_t cmd;
33
     command_t cmd;
48
     Log::initialize();
43
     Log::initialize();
49
     RunTime::initialize(); // RunTime is required by other constructors
44
     RunTime::initialize(); // RunTime is required by other constructors
50
 
45
 
51
-    gWorld.reset(new World());
52
-
53
     Command::fillCommandList();
46
     Command::fillCommandList();
54
 
47
 
55
     Log::get(LOG_INFO) << "Initializing " << VERSION << Log::endl;
48
     Log::get(LOG_INFO) << "Initializing " << VERSION << Log::endl;
127
         renderFrame();
120
         renderFrame();
128
     }
121
     }
129
 
122
 
123
+    World::destroy();
130
     Menu::shutdown();
124
     Menu::shutdown();
131
     UI::shutdown();
125
     UI::shutdown();
132
     Sound::shutdown();
126
     Sound::shutdown();

Loading…
Cancel
Save