Ver código fonte

Individual toggles for bounding box visualisation.

Thomas Buck 9 anos atrás
pai
commit
2218ccfcad
8 arquivos alterados com 36 adições e 9 exclusões
  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 Ver arquivo

2
 
2
 
3
 ## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>
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
     [ 20140108 ]
8
     [ 20140108 ]
6
     * FPS and Camera position now displayed in imgui Overlay
9
     * FPS and Camera position now displayed in imgui Overlay
7
     * Removed many unnecessary includes
10
     * Removed many unnecessary includes

+ 1
- 1
TODO.md Ver arquivo

21
 
21
 
22
 * Depend on physfs for easier file location management
22
 * Depend on physfs for easier file location management
23
 * Depend on libcdio, use it to read original CDs or CUE/TOC/ISO images
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 Ver arquivo

25
 
25
 
26
     //! \fixme The Y axis seems to be the source of all evil?
26
     //! \fixme The Y axis seems to be the source of all evil?
27
     static void setPosition(glm::vec3 p) { pos = glm::vec3(p.x, -p.y, p.z); }
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
     static glm::vec2 getRotation() { return rot; }
30
     static glm::vec2 getRotation() { return rot; }
31
     static glm::mat4 getProjectionMatrix() { return projection; }
31
     static glm::mat4 getProjectionMatrix() { return projection; }

+ 4
- 2
include/Room.h Ver arquivo

62
     Sprite& getSprite(unsigned long index);
62
     Sprite& getSprite(unsigned long index);
63
     void addSprite(Sprite* s);
63
     void addSprite(Sprite* s);
64
 
64
 
65
+    static void setShowBoundingBox(bool s) { showBoundingBox = s; }
66
+    static bool getShowBoundingBox() { return showBoundingBox; }
67
+
65
   private:
68
   private:
66
     glm::vec3 pos;
69
     glm::vec3 pos;
67
     glm::mat4 model;
70
     glm::mat4 model;
79
     std::vector<std::unique_ptr<Sector>> sectors;
82
     std::vector<std::unique_ptr<Sector>> sectors;
80
     std::vector<std::unique_ptr<Light>> lights;
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
 #endif
88
 #endif

+ 5
- 0
include/StaticMesh.h Ver arquivo

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

+ 16
- 1
src/Render.cpp Ver arquivo

11
 #include "global.h"
11
 #include "global.h"
12
 #include "Camera.h"
12
 #include "Camera.h"
13
 #include "Log.h"
13
 #include "Log.h"
14
+#include "StaticMesh.h"
14
 #include "World.h"
15
 #include "World.h"
15
 #include "system/Shader.h"
16
 #include "system/Shader.h"
16
 #include "system/Window.h"
17
 #include "system/Window.h"
180
             item = 2;
181
             item = 2;
181
         else if (mode == RenderMode::Solid)
182
         else if (mode == RenderMode::Solid)
182
             item = 3;
183
             item = 3;
183
-        if (ImGui::Combo("Mode", &item, modeStrings, modeStringCount)) {
184
+        if (ImGui::Combo("Render Mode", &item, modeStrings, modeStringCount)) {
184
             if (item == 0)
185
             if (item == 0)
185
                 mode = RenderMode::LoadScreen;
186
                 mode = RenderMode::LoadScreen;
186
             else if (item == 1)
187
             else if (item == 1)
191
                 mode = RenderMode::Solid;
192
                 mode = RenderMode::Solid;
192
         }
193
         }
193
 
194
 
195
+        ImGui::Separator();
196
+        ImGui::Text("Camera:");
194
         bool updateViewFrustum = Camera::getUpdateViewFrustum();
197
         bool updateViewFrustum = Camera::getUpdateViewFrustum();
195
         if (ImGui::Checkbox("Update Frustum##render", &updateViewFrustum)) {
198
         if (ImGui::Checkbox("Update Frustum##render", &updateViewFrustum)) {
196
             Camera::setUpdateViewFrustum(updateViewFrustum);
199
             Camera::setUpdateViewFrustum(updateViewFrustum);
197
         }
200
         }
198
         ImGui::SameLine();
201
         ImGui::SameLine();
199
         ImGui::Checkbox("Show Frustum##render", &displayViewFrustum);
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 Ver arquivo

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

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

Carregando…
Cancelar
Salvar