Browse Source

Fixed Sprite rotation, Sound upside-down, Entity UI

Thomas Buck 8 years ago
parent
commit
164ba94597
7 changed files with 68 additions and 17 deletions
  1. 3
    1
      ChangeLog.md
  2. 3
    0
      include/Entity.h
  3. 1
    1
      src/Camera.cpp
  4. 26
    4
      src/Entity.cpp
  5. 1
    4
      src/RoomData.cpp
  6. 2
    2
      src/UI.cpp
  7. 32
    5
      src/World.cpp

+ 3
- 1
ChangeLog.md View File

@@ -6,7 +6,9 @@
6 6
     * Can click on RoomModels and RoomSprites
7 7
     * This will show their BoundingSpheres
8 8
     * Fixed Mouse Selector Depth Sorting Issue
9
-    * Improved Room List UI
9
+    * Improved Room List UI, added Entity List UI
10
+    * Fixed Room and Entity Sprite rotation Issue
11
+    * Fixed upside-down Sound Listener positioning
10 12
 
11 13
     [ 20150803 ]
12 14
     * Started working on ray casting for mouse object selection

+ 3
- 0
include/Entity.h View File

@@ -14,6 +14,7 @@ class Entity {
14 14
         : id(i), room(r), pos(po), rot(ro), cache(-1), cacheType(-1),
15 15
           sprite(0), animation(0), frame(0) { }
16 16
     void display(glm::mat4 VP);
17
+    void displayUI();
17 18
 
18 19
     int getID() { return id; }
19 20
     int getRoom() { return room; }
@@ -35,6 +36,8 @@ class Entity {
35 36
     static bool getShowEntityModels() { return showEntityModels; }
36 37
 
37 38
   private:
39
+    void find();
40
+
38 41
     int id;
39 42
     int room;
40 43
     glm::vec3 pos;

+ 1
- 1
src/Camera.cpp View File

@@ -209,7 +209,7 @@ bool Camera::update() {
209 209
         calculateFrustumPlanes();
210 210
 
211 211
     glm::vec3 at(0.0f, 0.0f, -1.0f);
212
-    glm::vec3 up(0.0f, -1.0f, 0.0f);
212
+    glm::vec3 up(0.0f, 1.0f, 0.0f);
213 213
     Sound::listenAt(pos, quaternion * at, quaternion * up);
214 214
 
215 215
     dirty = false;

+ 26
- 4
src/Entity.cpp View File

@@ -12,6 +12,7 @@
12 12
 #include "Entity.h"
13 13
 
14 14
 #include <glm/gtc/matrix_transform.hpp>
15
+#include <imgui/imgui.h>
15 16
 
16 17
 #define CACHE_SPRITE 0
17 18
 #define CACHE_MESH 1
@@ -21,8 +22,8 @@ bool Entity::showEntitySprites = true;
21 22
 bool Entity::showEntityMeshes = false;
22 23
 bool Entity::showEntityModels = false;
23 24
 
24
-void Entity::display(glm::mat4 VP) {
25
-    if ((cache == -1) || (cacheType == -1)) {
25
+void Entity::find() {
26
+    if ((cache <= -1) || (cacheType <= -1)) {
26 27
         /*
27 28
          * The order in which to look for matching objects with the same ID
28 29
          * seems to be very important!
@@ -60,11 +61,15 @@ void Entity::display(glm::mat4 VP) {
60 61
         orAssertGreaterThan(cache, -1);
61 62
         orAssertGreaterThan(cacheType, -1);
62 63
     }
64
+}
65
+
66
+void Entity::display(glm::mat4 VP) {
67
+    find();
63 68
 
64 69
     glm::mat4 translate = glm::translate(glm::mat4(1.0f), pos);
65 70
     glm::mat4 rotate;
66
-    if (cacheType == 0) {
67
-        rotate = glm::rotate(glm::mat4(1.0f), Camera::getRotation().x, glm::vec3(0.0f, 1.0f, 0.0f));
71
+    if (cacheType == CACHE_SPRITE) {
72
+        rotate = glm::rotate(glm::mat4(1.0f), -Camera::getRotation().x, glm::vec3(0.0f, 1.0f, 0.0f));
68 73
     } else {
69 74
         rotate = glm::rotate(glm::mat4(1.0f), rot.y, glm::vec3(0.0f, 1.0f, 0.0f));
70 75
     }
@@ -83,3 +88,20 @@ void Entity::display(glm::mat4 VP) {
83 88
     }
84 89
 }
85 90
 
91
+void Entity::displayUI() {
92
+    find();
93
+
94
+    ImGui::Text("%03d", id);
95
+    ImGui::NextColumn();
96
+    if (cacheType == CACHE_SPRITE) {
97
+        ImGui::Text("SpriteSequence");
98
+    } else if (cacheType == CACHE_MESH) {
99
+        ImGui::Text("StaticMesh");
100
+    } else if (cacheType == CACHE_MODEL) {
101
+        ImGui::Text("SkeletalModel");
102
+    }
103
+    ImGui::NextColumn();
104
+    ImGui::Text("%03d", cache);
105
+    ImGui::NextColumn();
106
+}
107
+

+ 1
- 4
src/RoomData.cpp View File

@@ -77,11 +77,8 @@ void RoomSprite::displayBoundingSphere(glm::mat4 VP, glm::vec3 color) {
77 77
 
78 78
 void RoomSprite::display(glm::mat4 VP) {
79 79
     glm::mat4 translate = glm::translate(glm::mat4(1.0f), pos);
80
-
81
-    //! \fixme Calculate angle between camera and sprite
82
-    glm::mat4 rotate = glm::rotate(glm::mat4(1.0f), Camera::getRotation().x,
80
+    glm::mat4 rotate = glm::rotate(glm::mat4(1.0f), -Camera::getRotation().x,
83 81
                                    glm::vec3(0.0f, 1.0f, 0.0f));
84
-
85 82
     World::getSprite(sprite).display(VP * (translate * rotate));
86 83
 }
87 84
 

+ 2
- 2
src/UI.cpp View File

@@ -296,9 +296,9 @@ void UI::display() {
296 296
 
297 297
         Render::displayUI();
298 298
         RunTime::display();
299
-        TextureManager::display();
300
-        SoundManager::display();
301 299
         World::displayUI();
300
+        SoundManager::display();
301
+        TextureManager::display();
302 302
 
303 303
         if (ImGui::CollapsingHeader("Library Versions")) {
304 304
             ImGui::TextWrapped("%s", VERSION);

+ 32
- 5
src/World.cpp View File

@@ -122,7 +122,7 @@ Mesh& World::getMesh(unsigned long index) {
122 122
 void World::displayUI() {
123 123
     // Rooms
124 124
     static bool offsets = false;
125
-    if (ImGui::CollapsingHeader("Rooms")) {
125
+    if (ImGui::CollapsingHeader("Room Listing")) {
126 126
         ImGui::Columns(8, "rooms");
127 127
         ImGui::Text("No");
128 128
         ImGui::NextColumn();
@@ -159,22 +159,49 @@ void World::displayUI() {
159 159
         ImGui::Columns(1);
160 160
     }
161 161
 
162
-    // Static Meshes
162
+    // Entities
163 163
     static bool offsets2 = false;
164
-    if (ImGui::CollapsingHeader("StaticMeshes")) {
165
-        ImGui::Columns(3, "staticmeshes");
164
+    if (ImGui::CollapsingHeader("Entity Listing")) {
165
+        ImGui::Columns(4, "entities");
166 166
         ImGui::Text("No");
167 167
         ImGui::NextColumn();
168 168
         ImGui::Text("ID");
169 169
         ImGui::NextColumn();
170
-        ImGui::Text("Mesh");
170
+        ImGui::Text("Type");
171
+        ImGui::NextColumn();
172
+        ImGui::Text("Index");
171 173
         ImGui::NextColumn();
172 174
         ImGui::Separator();
173 175
         if (!offsets2) {
174 176
             ImGui::SetColumnOffset(1, 40.0f);
175 177
             ImGui::SetColumnOffset(2, 80.0f);
178
+            ImGui::SetColumnOffset(3, 200.0f);
176 179
             offsets2 = true;
177 180
         }
181
+        for (int i = 0; i < entities.size(); i++) {
182
+            ImGui::Text("%03d", i);
183
+            ImGui::NextColumn();
184
+            entities.at(i)->displayUI();
185
+        }
186
+        ImGui::Columns(1);
187
+    }
188
+
189
+    // Static Meshes
190
+    static bool offsets3 = false;
191
+    if (ImGui::CollapsingHeader("StaticMesh Listing")) {
192
+        ImGui::Columns(3, "staticmeshes");
193
+        ImGui::Text("No");
194
+        ImGui::NextColumn();
195
+        ImGui::Text("ID");
196
+        ImGui::NextColumn();
197
+        ImGui::Text("Mesh");
198
+        ImGui::NextColumn();
199
+        ImGui::Separator();
200
+        if (!offsets3) {
201
+            ImGui::SetColumnOffset(1, 40.0f);
202
+            ImGui::SetColumnOffset(2, 80.0f);
203
+            offsets3 = true;
204
+        }
178 205
         for (int i = 0; i < staticMeshes.size(); i++) {
179 206
             ImGui::Text("%03d", i);
180 207
             ImGui::NextColumn();

Loading…
Cancel
Save