Bläddra i källkod

Fixed Sprite rotation, Sound upside-down, Entity UI

Thomas Buck 9 år sedan
förälder
incheckning
164ba94597
7 ändrade filer med 68 tillägg och 17 borttagningar
  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 Visa fil

6
     * Can click on RoomModels and RoomSprites
6
     * Can click on RoomModels and RoomSprites
7
     * This will show their BoundingSpheres
7
     * This will show their BoundingSpheres
8
     * Fixed Mouse Selector Depth Sorting Issue
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
     [ 20150803 ]
13
     [ 20150803 ]
12
     * Started working on ray casting for mouse object selection
14
     * Started working on ray casting for mouse object selection

+ 3
- 0
include/Entity.h Visa fil

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

+ 1
- 1
src/Camera.cpp Visa fil

209
         calculateFrustumPlanes();
209
         calculateFrustumPlanes();
210
 
210
 
211
     glm::vec3 at(0.0f, 0.0f, -1.0f);
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
     Sound::listenAt(pos, quaternion * at, quaternion * up);
213
     Sound::listenAt(pos, quaternion * at, quaternion * up);
214
 
214
 
215
     dirty = false;
215
     dirty = false;

+ 26
- 4
src/Entity.cpp Visa fil

12
 #include "Entity.h"
12
 #include "Entity.h"
13
 
13
 
14
 #include <glm/gtc/matrix_transform.hpp>
14
 #include <glm/gtc/matrix_transform.hpp>
15
+#include <imgui/imgui.h>
15
 
16
 
16
 #define CACHE_SPRITE 0
17
 #define CACHE_SPRITE 0
17
 #define CACHE_MESH 1
18
 #define CACHE_MESH 1
21
 bool Entity::showEntityMeshes = false;
22
 bool Entity::showEntityMeshes = false;
22
 bool Entity::showEntityModels = false;
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
          * The order in which to look for matching objects with the same ID
28
          * The order in which to look for matching objects with the same ID
28
          * seems to be very important!
29
          * seems to be very important!
60
         orAssertGreaterThan(cache, -1);
61
         orAssertGreaterThan(cache, -1);
61
         orAssertGreaterThan(cacheType, -1);
62
         orAssertGreaterThan(cacheType, -1);
62
     }
63
     }
64
+}
65
+
66
+void Entity::display(glm::mat4 VP) {
67
+    find();
63
 
68
 
64
     glm::mat4 translate = glm::translate(glm::mat4(1.0f), pos);
69
     glm::mat4 translate = glm::translate(glm::mat4(1.0f), pos);
65
     glm::mat4 rotate;
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
     } else {
73
     } else {
69
         rotate = glm::rotate(glm::mat4(1.0f), rot.y, glm::vec3(0.0f, 1.0f, 0.0f));
74
         rotate = glm::rotate(glm::mat4(1.0f), rot.y, glm::vec3(0.0f, 1.0f, 0.0f));
70
     }
75
     }
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 Visa fil

77
 
77
 
78
 void RoomSprite::display(glm::mat4 VP) {
78
 void RoomSprite::display(glm::mat4 VP) {
79
     glm::mat4 translate = glm::translate(glm::mat4(1.0f), pos);
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
                                    glm::vec3(0.0f, 1.0f, 0.0f));
81
                                    glm::vec3(0.0f, 1.0f, 0.0f));
84
-
85
     World::getSprite(sprite).display(VP * (translate * rotate));
82
     World::getSprite(sprite).display(VP * (translate * rotate));
86
 }
83
 }
87
 
84
 

+ 2
- 2
src/UI.cpp Visa fil

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

+ 32
- 5
src/World.cpp Visa fil

122
 void World::displayUI() {
122
 void World::displayUI() {
123
     // Rooms
123
     // Rooms
124
     static bool offsets = false;
124
     static bool offsets = false;
125
-    if (ImGui::CollapsingHeader("Rooms")) {
125
+    if (ImGui::CollapsingHeader("Room Listing")) {
126
         ImGui::Columns(8, "rooms");
126
         ImGui::Columns(8, "rooms");
127
         ImGui::Text("No");
127
         ImGui::Text("No");
128
         ImGui::NextColumn();
128
         ImGui::NextColumn();
159
         ImGui::Columns(1);
159
         ImGui::Columns(1);
160
     }
160
     }
161
 
161
 
162
-    // Static Meshes
162
+    // Entities
163
     static bool offsets2 = false;
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
         ImGui::Text("No");
166
         ImGui::Text("No");
167
         ImGui::NextColumn();
167
         ImGui::NextColumn();
168
         ImGui::Text("ID");
168
         ImGui::Text("ID");
169
         ImGui::NextColumn();
169
         ImGui::NextColumn();
170
-        ImGui::Text("Mesh");
170
+        ImGui::Text("Type");
171
+        ImGui::NextColumn();
172
+        ImGui::Text("Index");
171
         ImGui::NextColumn();
173
         ImGui::NextColumn();
172
         ImGui::Separator();
174
         ImGui::Separator();
173
         if (!offsets2) {
175
         if (!offsets2) {
174
             ImGui::SetColumnOffset(1, 40.0f);
176
             ImGui::SetColumnOffset(1, 40.0f);
175
             ImGui::SetColumnOffset(2, 80.0f);
177
             ImGui::SetColumnOffset(2, 80.0f);
178
+            ImGui::SetColumnOffset(3, 200.0f);
176
             offsets2 = true;
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
         for (int i = 0; i < staticMeshes.size(); i++) {
205
         for (int i = 0; i < staticMeshes.size(); i++) {
179
             ImGui::Text("%03d", i);
206
             ImGui::Text("%03d", i);
180
             ImGui::NextColumn();
207
             ImGui::NextColumn();

Laddar…
Avbryt
Spara