浏览代码

Fixed StaticMesh Y offset

Thomas Buck 10 年前
父节点
当前提交
4e9ef0cb43
共有 9 个文件被更改,包括 27 次插入104 次删除
  1. 1
    0
      ChangeLog.md
  2. 1
    1
      include/RunTime.h
  3. 1
    1
      src/Camera.cpp
  4. 5
    5
      src/Render.cpp
  5. 1
    1
      src/RoomData.cpp
  6. 3
    8
      src/main.cpp
  7. 12
    4
      src/system/Window.cpp
  8. 3
    13
      test/CMakeLists.txt
  9. 0
    71
      test/Loader.cpp

+ 1
- 0
ChangeLog.md 查看文件

8
     * Now using stb_image for all image loading (except pcx format)
8
     * Now using stb_image for all image loading (except pcx format)
9
     * Now storing screenshots in PNG format
9
     * Now storing screenshots in PNG format
10
     * Updated imgui
10
     * Updated imgui
11
+    * Fixed StaticMesh Y-offset (position Y needed to be flipped)
11
 
12
 
12
     [ 20141228 ]
13
     [ 20141228 ]
13
     * Room Bounding Boxes are now visualized in Wireframe mode (again).
14
     * Room Bounding Boxes are now visualized in Wireframe mode (again).

+ 1
- 1
include/RunTime.h 查看文件

36
     static void setRunning(bool run) { gameIsRunning = run; }
36
     static void setRunning(bool run) { gameIsRunning = run; }
37
 
37
 
38
     static bool getShowFPS() { return showFPS; }
38
     static bool getShowFPS() { return showFPS; }
39
-    static void setShowFPS(bool fps) { showFPS = fps; }
39
+    static void setShowFPS(bool f) { showFPS = f; }
40
 
40
 
41
     static unsigned long getFPS() { return fps; }
41
     static unsigned long getFPS() { return fps; }
42
     static const std::vector<float>& getHistoryFPS() { return history; }
42
     static const std::vector<float>& getHistoryFPS() { return history; }

+ 1
- 1
src/Camera.cpp 查看文件

94
         dirty = true;
94
         dirty = true;
95
     }
95
     }
96
 
96
 
97
-    static int lastDir = 0;
98
     if (y != 0) {
97
     if (y != 0) {
98
+        static int lastDir = 0;
99
         float a = glm::dot(upUnit, quaternion * upUnit);
99
         float a = glm::dot(upUnit, quaternion * upUnit);
100
         if (((lastDir >= 0) && (y < 0)) || ((lastDir <= 0) && (y > 0)) || (a > 0.5f)) {
100
         if (((lastDir >= 0) && (y < 0)) || ((lastDir <= 0) && (y > 0)) || (a > 0.5f)) {
101
             quaternion = glm::quat(quaternion * -rightUnit * (rotationDeltaY * y)) * quaternion;
101
             quaternion = glm::quat(quaternion * -rightUnit * (rotationDeltaY * y)) * quaternion;

+ 5
- 5
src/Render.cpp 查看文件

196
     Window::drawTextGL(vertices, uvs, color, texture);
196
     Window::drawTextGL(vertices, uvs, color, texture);
197
 }
197
 }
198
 
198
 
199
-void Render::displayUI() {
200
-    static const int modeStringCount = 5;
201
-    static const char* modeStrings[modeStringCount] = {
202
-        "Disable", "Splash", "Texture", "Wireframe", "Solid"
203
-    };
199
+static const int modeStringCount = 5;
200
+static const char* modeStrings[modeStringCount] = {
201
+    "Disable", "Splash", "Texture", "Wireframe", "Solid"
202
+};
204
 
203
 
204
+void Render::displayUI() {
205
     if (ImGui::CollapsingHeader("Render Settings")) {
205
     if (ImGui::CollapsingHeader("Render Settings")) {
206
         int item = 0;
206
         int item = 0;
207
         if (mode == RenderMode::LoadScreen)
207
         if (mode == RenderMode::LoadScreen)

+ 1
- 1
src/RoomData.cpp 查看文件

65
         assert(cache >= 0);
65
         assert(cache >= 0);
66
     }
66
     }
67
 
67
 
68
-    glm::mat4 translate = glm::translate(glm::mat4(1.0f), pos);
68
+    glm::mat4 translate = glm::translate(glm::mat4(1.0f), glm::vec3(pos.x, -pos.y, pos.z));
69
     glm::mat4 rotate = glm::rotate(glm::mat4(1.0f), angle, glm::vec3(0.0f, 1.0f, 0.0f));
69
     glm::mat4 rotate = glm::rotate(glm::mat4(1.0f), angle, glm::vec3(0.0f, 1.0f, 0.0f));
70
     glm::mat4 model = translate * rotate;
70
     glm::mat4 model = translate * rotate;
71
     getWorld().getStaticMesh(cache).display(model, view, projection);
71
     getWorld().getStaticMesh(cache).display(model, view, projection);

+ 3
- 8
src/main.cpp 查看文件

10
 
10
 
11
 #include "global.h"
11
 #include "global.h"
12
 #include "Exception.h"
12
 #include "Exception.h"
13
-#include "commander/commander.h"
14
-#include "commands/Command.h"
15
-#include "utils/time.h"
16
-
17
-#ifndef UNIT_TEST
18
-
19
 #include "Game.h"
13
 #include "Game.h"
20
 #include "Log.h"
14
 #include "Log.h"
21
 #include "MenuFolder.h"
15
 #include "MenuFolder.h"
24
 #include "TextureManager.h"
18
 #include "TextureManager.h"
25
 #include "UI.h"
19
 #include "UI.h"
26
 #include "World.h"
20
 #include "World.h"
21
+#include "commander/commander.h"
22
+#include "commands/Command.h"
27
 #include "system/Font.h"
23
 #include "system/Font.h"
28
 #include "system/Sound.h"
24
 #include "system/Sound.h"
29
 #include "system/Window.h"
25
 #include "system/Window.h"
26
+#include "utils/time.h"
30
 
27
 
31
 static std::string configFileToUse;
28
 static std::string configFileToUse;
32
 
29
 
176
     RunTime::updateFPS();
173
     RunTime::updateFPS();
177
 }
174
 }
178
 
175
 
179
-#endif // UNIT_TEST
180
-
181
 #if defined(HAVE_EXECINFO_H) && defined(HAVE_BACKTRACE) && defined(HAVE_BACKTRACE_SYMBOLS)
176
 #if defined(HAVE_EXECINFO_H) && defined(HAVE_BACKTRACE) && defined(HAVE_BACKTRACE_SYMBOLS)
182
 #ifndef NDEBUG
177
 #ifndef NDEBUG
183
 
178
 

+ 12
- 4
src/system/Window.cpp 查看文件

19
 #endif
19
 #endif
20
 
20
 
21
 int Window::initialize() {
21
 int Window::initialize() {
22
-    int res = -1;
22
+    int res;
23
 #ifdef USING_SDL
23
 #ifdef USING_SDL
24
     res = WindowSDL::initialize();
24
     res = WindowSDL::initialize();
25
 #elif defined(USING_GLFW)
25
 #elif defined(USING_GLFW)
26
     res = WindowGLFW::initialize();
26
     res = WindowGLFW::initialize();
27
+#else
28
+    res = -1;
27
 #endif
29
 #endif
28
 
30
 
29
     initializeGL();
31
     initializeGL();
84
 }
86
 }
85
 
87
 
86
 bool Window::getFullscreen() {
88
 bool Window::getFullscreen() {
87
-    bool ret = false;
89
+    bool ret;
88
 #ifdef USING_SDL
90
 #ifdef USING_SDL
89
     ret = WindowSDL::getFullscreen();
91
     ret = WindowSDL::getFullscreen();
90
 #elif defined(USING_GLFW)
92
 #elif defined(USING_GLFW)
91
     ret = WindowGLFW::getFullscreen();
93
     ret = WindowGLFW::getFullscreen();
94
+#else
95
+    ret = false;
92
 #endif
96
 #endif
93
 
97
 
94
     return ret;
98
     return ret;
103
 }
107
 }
104
 
108
 
105
 bool Window::getMousegrab() {
109
 bool Window::getMousegrab() {
106
-    bool ret = false;
110
+    bool ret;
107
 #ifdef USING_SDL
111
 #ifdef USING_SDL
108
     ret = WindowSDL::getMousegrab();
112
     ret = WindowSDL::getMousegrab();
109
 #elif defined(USING_GLFW)
113
 #elif defined(USING_GLFW)
110
     ret = WindowGLFW::getMousegrab();
114
     ret = WindowGLFW::getMousegrab();
115
+#else
116
+    ret = false;
111
 #endif
117
 #endif
112
 
118
 
113
     return ret;
119
     return ret;
122
 }
128
 }
123
 
129
 
124
 bool Window::getTextInput() {
130
 bool Window::getTextInput() {
125
-    bool ret = false;
131
+    bool ret;
126
 #ifdef USING_SDL
132
 #ifdef USING_SDL
127
     ret = WindowSDL::getTextInput();
133
     ret = WindowSDL::getTextInput();
128
 #elif defined(USING_GLFW)
134
 #elif defined(USING_GLFW)
129
     ret = WindowGLFW::getTextInput();
135
     ret = WindowGLFW::getTextInput();
136
+#else
137
+    ret = false;
130
 #endif
138
 #endif
131
 
139
 
132
     return ret;
140
     return ret;

+ 3
- 13
test/CMakeLists.txt 查看文件

8
 
8
 
9
 add_executable (tester_binary EXCLUDE_FROM_ALL
9
 add_executable (tester_binary EXCLUDE_FROM_ALL
10
     "binary.cpp" "../src/utils/binary.cpp"
10
     "binary.cpp" "../src/utils/binary.cpp"
11
-    "../src/Exception.cpp" "../src/main.cpp"
11
+    "../src/Exception.cpp"
12
 )
12
 )
13
 add_dependencies (check tester_binary)
13
 add_dependencies (check tester_binary)
14
 add_test (NAME test_binary COMMAND tester_binary)
14
 add_test (NAME test_binary COMMAND tester_binary)
15
 
15
 
16
 #################################################################
16
 #################################################################
17
 
17
 
18
-add_executable (tester_loader EXCLUDE_FROM_ALL
19
-    "Loader.cpp" "../src/utils/binary.cpp"
20
-    "../src/loader/Loader.cpp" "../src/loader/LoaderTR1.cpp"
21
-    "../src/loader/LoaderTR2.cpp" "../src/loader/LoaderTR3.cpp"
22
-)
23
-#add_dependencies (check tester_loader)
24
-#add_test (NAME test_loader COMMAND tester_loader)
25
-
26
-#################################################################
27
-
28
 add_executable (tester_script EXCLUDE_FROM_ALL
18
 add_executable (tester_script EXCLUDE_FROM_ALL
29
     "Script.cpp" "ScriptPayload.h" "ScriptTest.h"
19
     "Script.cpp" "ScriptPayload.h" "ScriptTest.h"
30
-    "../src/Script.cpp" "../src/main.cpp"
31
-    "../src/utils/binary.cpp" "../src/Exception.cpp"
20
+    "../src/Script.cpp" "../src/Exception.cpp"
21
+    "../src/utils/binary.cpp"
32
 )
22
 )
33
 
23
 
34
 find_package (ZLIB REQUIRED)
24
 find_package (ZLIB REQUIRED)

+ 0
- 71
test/Loader.cpp 查看文件

1
-/*!
2
- * \file test/Loader.cpp
3
- * \brief Level Loader Unit Test
4
- *
5
- * \author xythobuz
6
- */
7
-
8
-#include "global.h"
9
-#include "loader/Loader.h"
10
-
11
-int main(int argc, char* argv[]) {
12
-    if (argc != 2) {
13
-        std::cout << "Usage:" << std::endl;
14
-        std::cout << "\t" << argv[0] << " /path/to/level.tr2" << std::endl;
15
-        return 0; // Don't fail when just running this test...
16
-    }
17
-
18
-    // Print file engine version
19
-    std::cout << "Loading \"" << argv[1] << "\"" << std::endl;
20
-    std::cout << "Trying to detect engine version... ";
21
-    Loader::LoaderVersion v = Loader::checkFile(argv[1]);
22
-    switch (v) {
23
-        case Loader::TR_1:
24
-            std::cout << "TR 1";
25
-            break;
26
-
27
-        case Loader::TR_2:
28
-            std::cout << "TR 2";
29
-            break;
30
-
31
-        case Loader::TR_3:
32
-            std::cout << "TR 3";
33
-            break;
34
-
35
-        case Loader::TR_4:
36
-            std::cout << "TR 4";
37
-            break;
38
-
39
-        case Loader::TR_5:
40
-            std::cout << "TR 5";
41
-            break;
42
-
43
-        case Loader::TR_UNKNOWN:
44
-            std::cout << "Unknown version!" << std::endl;
45
-            return 2;
46
-    }
47
-    std::cout << " detected!" << std::endl;
48
-
49
-    // Create matching loader
50
-    std::cout << std::endl << "Creating level loader... ";
51
-    std::unique_ptr<Loader> loader = Loader::createLoader(argv[1]);
52
-    if (!loader) {
53
-        std::cout << "Failed!" << std::endl;
54
-        return 3;
55
-    } else {
56
-        std::cout << "Success!" << std::endl;
57
-    }
58
-
59
-    // Try to load the level
60
-    std::cout << "Trying to load level... ";
61
-    int error = loader->load(argv[1]);
62
-    if (error != 0) {
63
-        std::cout << "Failure!" << std::endl;
64
-        std::cout << "Error code: " << error << std::endl;
65
-    } else {
66
-        std::cout << "Success!" << std::endl;
67
-    }
68
-
69
-    return error;
70
-}
71
-

正在加载...
取消
保存