Browse Source

Individual toggles for bounding box visualisation.

Thomas Buck 9 years ago
parent
commit
2218ccfcad
8 changed files with 36 additions and 9 deletions
  1. 3
    0
      ChangeLog.md
  2. 1
    1
      TODO.md
  3. 1
    1
      include/Camera.h
  4. 4
    2
      include/Room.h
  5. 5
    0
      include/StaticMesh.h
  6. 16
    1
      src/Render.cpp
  7. 3
    2
      src/Room.cpp
  8. 3
    2
      src/StaticMesh.cpp

+ 3
- 0
ChangeLog.md View File

@@ -2,6 +2,9 @@
2 2
 
3 3
 ## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>
4 4
 
5
+    [ 20140109 ]
6
+    * Display of Bounding Boxes can be individually toggled for Rooms/StaticMeshes
7
+
5 8
     [ 20140108 ]
6 9
     * FPS and Camera position now displayed in imgui Overlay
7 10
     * Removed many unnecessary includes

+ 1
- 1
TODO.md View File

@@ -21,5 +21,5 @@
21 21
 
22 22
 * Depend on physfs for easier file location management
23 23
 * Depend on libcdio, use it to read original CDs or CUE/TOC/ISO images
24
-* Add ability to play the FMVs. Format? VLC can play them!
24
+* Add ability to play the FMVs. QuickTime, ima4 Audio, h264 avc1 Video!
25 25
 

+ 1
- 1
include/Camera.h View File

@@ -25,7 +25,7 @@ class Camera {
25 25
 
26 26
     //! \fixme The Y axis seems to be the source of all evil?
27 27
     static void setPosition(glm::vec3 p) { pos = glm::vec3(p.x, -p.y, p.z); }
28
-    static glm::vec3 getPosition() { return pos; }
28
+    static glm::vec3 getPosition() { return glm::vec3(pos.x, -pos.y, pos.z); }
29 29
 
30 30
     static glm::vec2 getRotation() { return rot; }
31 31
     static glm::mat4 getProjectionMatrix() { return projection; }

+ 4
- 2
include/Room.h View File

@@ -62,6 +62,9 @@ class Room {
62 62
     Sprite& getSprite(unsigned long index);
63 63
     void addSprite(Sprite* s);
64 64
 
65
+    static void setShowBoundingBox(bool s) { showBoundingBox = s; }
66
+    static bool getShowBoundingBox() { return showBoundingBox; }
67
+
65 68
   private:
66 69
     glm::vec3 pos;
67 70
     glm::mat4 model;
@@ -79,8 +82,7 @@ class Room {
79 82
     std::vector<std::unique_ptr<Sector>> sectors;
80 83
     std::vector<std::unique_ptr<Light>> lights;
81 84
 
82
-    // Was used for "depth sorting" render list, but never assigned...?!
83
-    //float dist; // Distance to near plane, move to room?
85
+    static bool showBoundingBox;
84 86
 };
85 87
 
86 88
 #endif

+ 5
- 0
include/StaticMesh.h View File

@@ -20,10 +20,15 @@ class StaticMesh {
20 20
 
21 21
     int getID() { return id; }
22 22
 
23
+    static void setShowBoundingBox(bool s) { showBoundingBox = s; }
24
+    static bool getShowBoundingBox() { return showBoundingBox; }
25
+
23 26
   private:
24 27
     int id;
25 28
     int mesh;
26 29
     std::unique_ptr<BoundingBox> bbox1, bbox2;
30
+
31
+    static bool showBoundingBox;
27 32
 };
28 33
 
29 34
 #endif

+ 16
- 1
src/Render.cpp View File

@@ -11,6 +11,7 @@
11 11
 #include "global.h"
12 12
 #include "Camera.h"
13 13
 #include "Log.h"
14
+#include "StaticMesh.h"
14 15
 #include "World.h"
15 16
 #include "system/Shader.h"
16 17
 #include "system/Window.h"
@@ -180,7 +181,7 @@ void Render::displayUI() {
180 181
             item = 2;
181 182
         else if (mode == RenderMode::Solid)
182 183
             item = 3;
183
-        if (ImGui::Combo("Mode", &item, modeStrings, modeStringCount)) {
184
+        if (ImGui::Combo("Render Mode", &item, modeStrings, modeStringCount)) {
184 185
             if (item == 0)
185 186
                 mode = RenderMode::LoadScreen;
186 187
             else if (item == 1)
@@ -191,12 +192,26 @@ void Render::displayUI() {
191 192
                 mode = RenderMode::Solid;
192 193
         }
193 194
 
195
+        ImGui::Separator();
196
+        ImGui::Text("Camera:");
194 197
         bool updateViewFrustum = Camera::getUpdateViewFrustum();
195 198
         if (ImGui::Checkbox("Update Frustum##render", &updateViewFrustum)) {
196 199
             Camera::setUpdateViewFrustum(updateViewFrustum);
197 200
         }
198 201
         ImGui::SameLine();
199 202
         ImGui::Checkbox("Show Frustum##render", &displayViewFrustum);
203
+
204
+        ImGui::Separator();
205
+        ImGui::Text("Bounding Boxes:");
206
+        bool showBoundingBox = Room::getShowBoundingBox();
207
+        if (ImGui::Checkbox("Room##bbox", &showBoundingBox)) {
208
+            Room::setShowBoundingBox(showBoundingBox);
209
+        }
210
+        ImGui::SameLine();
211
+        bool showBoundingBox2 = StaticMesh::getShowBoundingBox();
212
+        if (ImGui::Checkbox("StaticMesh##bbox", &showBoundingBox2)) {
213
+            StaticMesh::setShowBoundingBox(showBoundingBox2);
214
+        }
200 215
     }
201 216
 }
202 217
 

+ 3
- 2
src/Room.cpp View File

@@ -7,12 +7,13 @@
7 7
 
8 8
 #include "global.h"
9 9
 #include "Log.h"
10
-#include "Render.h"
11 10
 #include "Room.h"
12 11
 
13 12
 #include <glm/gtc/matrix_transform.hpp>
14 13
 #include <glm/gtx/intersect.hpp>
15 14
 
15
+bool Room::showBoundingBox = false;
16
+
16 17
 Room::Room(glm::vec3 _pos, BoundingBox* _bbox, RoomMesh* _mesh, unsigned int f,
17 18
            int a, int x, int z) : pos(_pos), bbox(_bbox), mesh(_mesh), flags(f),
18 19
                                   alternateRoom(a), numXSectors(x), numZSectors(z) {
@@ -28,7 +29,7 @@ void Room::display(glm::mat4 VP) {
28 29
         m->display(VP);
29 30
     }
30 31
 
31
-    if (Render::getMode() == RenderMode::Wireframe)
32
+    if (showBoundingBox)
32 33
         bbox->display(VP, glm::vec3(0.0f, 1.0f, 0.0f), glm::vec3(1.0f, 0.0f, 1.0f));
33 34
 }
34 35
 

+ 3
- 2
src/StaticMesh.cpp View File

@@ -6,14 +6,15 @@
6 6
  */
7 7
 
8 8
 #include "global.h"
9
-#include "Render.h"
10 9
 #include "World.h"
11 10
 #include "StaticMesh.h"
12 11
 
12
+bool StaticMesh::showBoundingBox = false;
13
+
13 14
 void StaticMesh::display(glm::mat4 MVP) {
14 15
     getWorld().getMesh(mesh).display(MVP);
15 16
 
16
-    if (Render::getMode() == RenderMode::Wireframe) {
17
+    if (showBoundingBox) {
17 18
         bbox1->display(MVP, glm::vec3(1.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f));
18 19
         bbox2->display(MVP, glm::vec3(1.0f, 0.0f, 1.0f), glm::vec3(0.0f, 0.0f, 1.0f));
19 20
     }

Loading…
Cancel
Save