Przeglądaj źródła

LoaderTR1 Unfinished Business support. Sprint for camera movement.

Thomas Buck 9 lat temu
rodzic
commit
aa52606cc1
4 zmienionych plików z 32 dodań i 5 usunięć
  1. 4
    0
      ChangeLog.md
  2. 1
    1
      include/Camera.h
  3. 15
    3
      src/Camera.cpp
  4. 12
    1
      src/loader/LoaderTR1.cpp

+ 4
- 0
ChangeLog.md Wyświetl plik

@@ -2,6 +2,10 @@
2 2
 
3 3
 ## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>
4 4
 
5
+    [ 20140306 ]
6
+    * Fixed LoaderTR1, can now also open the Unfinished Business levels
7
+    * Walk key can now be used to increase free-camera movement speed
8
+
5 9
     [ 20140305 ]
6 10
     * SoundAL now has more useful error message output.
7 11
     * Fixed TR1 color map parsing, now textures have the proper color values.

+ 1
- 1
include/Camera.h Wyświetl plik

@@ -60,7 +60,7 @@ class Camera {
60 60
     static glm::mat4 projection;
61 61
     static glm::mat4 view;
62 62
     static float rotationDeltaX, rotationDeltaY;
63
-    static bool updateViewFrustum, dirty, showOverlay;
63
+    static bool updateViewFrustum, dirty, showOverlay, movingFaster;
64 64
     static int room;
65 65
 };
66 66
 

+ 15
- 3
src/Camera.cpp Wyświetl plik

@@ -43,6 +43,7 @@ const static float controllerDeadZone = 0.33f;
43 43
 const static float controllerViewFactor = glm::pi<float>();
44 44
 const static float rotationAngleClamp = glm::pi<float>() * 2.0f;
45 45
 const static float rotationAngleVertMax = glm::pi<float>() / 2.0f;
46
+const static float runFactor = 2.5f;
46 47
 
47 48
 const static glm::vec3 rightUnit(1.0f, 0.0f, 0.0f);
48 49
 const static glm::vec3 upUnit(0.0f, 1.0f, 0.0f);
@@ -59,6 +60,7 @@ float Camera::rotationDeltaY = 0.75f;
59 60
 bool Camera::updateViewFrustum = true;
60 61
 bool Camera::dirty = true;
61 62
 bool Camera::showOverlay = false;
63
+bool Camera::movingFaster = false;
62 64
 int Camera::room = -1;
63 65
 
64 66
 void Camera::reset() {
@@ -96,6 +98,8 @@ void Camera::handleAction(ActionEvents action, bool isFinished) {
96 98
         posSpeed += upUnit * maxSpeed * factor;
97 99
     } else if (action == crouchAction) {
98 100
         posSpeed -= upUnit * maxSpeed * factor;
101
+    } else if (action == walkAction) {
102
+        movingFaster = !isFinished;
99 103
     } else {
100 104
         return;
101 105
     }
@@ -176,9 +180,17 @@ bool Camera::update() {
176 180
     glm::quat quatX = glm::angleAxis(rot.y, glm::vec3(1.0f, 0.0f, 0.0f));
177 181
     glm::quat quaternion = quatY * quatX;
178 182
 
179
-    glm::vec3 clampedSpeed(posSpeed);
180
-    if (glm::length(clampedSpeed) > maxSpeed) {
181
-        clampedSpeed = glm::normalize(clampedSpeed) * maxSpeed;
183
+    glm::vec3 clampedSpeed;
184
+    if (movingFaster) {
185
+        clampedSpeed = posSpeed * runFactor;
186
+        if (glm::length(clampedSpeed) > (maxSpeed * runFactor)) {
187
+            clampedSpeed = glm::normalize(clampedSpeed) * maxSpeed * runFactor;
188
+        }
189
+    } else {
190
+        clampedSpeed = posSpeed;
191
+        if (glm::length(clampedSpeed) > maxSpeed) {
192
+            clampedSpeed = glm::normalize(clampedSpeed) * maxSpeed;
193
+        }
182 194
     }
183 195
 
184 196
     pos += quaternion * clampedSpeed * dT;

+ 12
- 1
src/loader/LoaderTR1.cpp Wyświetl plik

@@ -10,6 +10,7 @@
10 10
 #include "Log.h"
11 11
 #include "SoundManager.h"
12 12
 #include "World.h"
13
+#include "utils/strings.h"
13 14
 #include "loader/LoaderTR1.h"
14 15
 
15 16
 int LoaderTR1::load(std::string f) {
@@ -22,6 +23,10 @@ int LoaderTR1::load(std::string f) {
22 23
         return 2; // Not a TR1 level?!
23 24
     }
24 25
 
26
+    bool unfinishedBusiness = stringEndsWith(f, ".tub");
27
+    if (unfinishedBusiness)
28
+        Log::get(LOG_INFO) << "LoaderTR1: Detected Unfinished Business level!" << Log::endl;
29
+
25 30
     loadTextures();
26 31
 
27 32
     file.seek(file.tell() + 4); // Unused value?
@@ -33,6 +38,10 @@ int LoaderTR1::load(std::string f) {
33 38
     loadStaticMeshes();
34 39
     loadTextiles();
35 40
     loadSprites();
41
+
42
+    if (unfinishedBusiness)
43
+        loadPalette();
44
+
36 45
     loadCameras();
37 46
     loadSoundSources();
38 47
     loadBoxesOverlapsZones();
@@ -41,7 +50,9 @@ int LoaderTR1::load(std::string f) {
41 50
 
42 51
     file.seek(file.tell() + 8192); // TODO light map!
43 52
 
44
-    loadPalette();
53
+    if (!unfinishedBusiness)
54
+        loadPalette();
55
+
45 56
     loadCinematicFrames();
46 57
     loadDemoData();
47 58
     loadSoundMap();

Ładowanie…
Anuluj
Zapisz