Browse Source

Fixed Lara no longer rotating with camera

Thomas Buck 10 years ago
parent
commit
ffd928a508
6 changed files with 31 additions and 72 deletions
  1. 1
    8
      TODO.md
  2. 11
    11
      include/TombRaiderData.h
  3. 4
    4
      src/Console.cpp
  4. 3
    20
      src/Entity.cpp
  5. 9
    24
      src/Game.cpp
  6. 3
    5
      src/OpenRaider.cpp

+ 1
- 8
TODO.md View File

@@ -21,7 +21,7 @@ There are these DebugModel, DebugMap flags...?
21 21
 
22 22
     Assertion failed: (sector < (int)mRooms.at(room)->sizeSectors()), function isWall, file /Users/thomas/Projekte/OpenRaider/src/World.cpp, line 180.
23 23
 
24
-* The wrong SkeletalModels are used by other entities...?
24
+* The wrong SkeletalModels are used by entities, except for Lara...?
25 25
 
26 26
 ## Cmake
27 27
 
@@ -36,10 +36,3 @@ There are these DebugModel, DebugMap flags...?
36 36
     * Cut TGA image reader, currently only used for menu background?!
37 37
 * When cutscene rendering is working, use TR4/5 style menu?
38 38
 
39
-## Errors
40
-
41
-* Sometimes this on quitting OpenRaider:
42
-
43
-    OpenRaider(92329,0x7fff7a8c4310) malloc: *** error for object 0x7fabc2001000: incorrect checksum for freed object - object was probably modified after being freed.
44
-
45
-

+ 11
- 11
include/TombRaiderData.h View File

@@ -17,17 +17,17 @@
17 17
 #define TR_SOUND_FOOTSTEP0 1
18 18
 #define TR_SOUND_F_PISTOL  12
19 19
 
20
-#define TR_ANIAMTION_RUN            0
21
-#define TR_ANIAMTION_STAND          11
22
-#define TR_ANIAMTION_TURN_L         12
23
-#define TR_ANIAMTION_TURN_R         13
24
-#define TR_ANIAMTION_HIT_WALL_FRONT 53
25
-#define TR_ANIAMTION_SWIM_IDLE      87
26
-#define TR_ANIAMTION_SWIM           86
27
-#define TR_ANIAMTION_SWIM_L         143
28
-#define TR_ANIAMTION_SWIM_R         144
29
-#define TR_ANIAMTION_GRAB_LEDGE     96
30
-#define TR_ANIAMTION_PULLING_UP     97
20
+#define TR_ANIMATION_RUN            0
21
+#define TR_ANIMATION_STAND          11
22
+#define TR_ANIMATION_TURN_L         12
23
+#define TR_ANIMATION_TURN_R         13
24
+#define TR_ANIMATION_HIT_WALL_FRONT 53
25
+#define TR_ANIMATION_SWIM_IDLE      87
26
+#define TR_ANIMATION_SWIM           86
27
+#define TR_ANIMATION_SWIM_L         143
28
+#define TR_ANIMATION_SWIM_R         144
29
+#define TR_ANIMATION_GRAB_LEDGE     96
30
+#define TR_ANIMATION_PULLING_UP     97
31 31
 
32 32
 typedef enum {
33 33
     TR_VERSION_UNKNOWN,

+ 4
- 4
src/Console.cpp View File

@@ -5,6 +5,8 @@
5 5
  * \author xythobuz
6 6
  */
7 7
 
8
+#include <iostream>
9
+
8 10
 #include "global.h"
9 11
 #include "Console.h"
10 12
 #include "OpenRaider.h"
@@ -67,7 +69,7 @@ void Console::print(const char *s, ...) {
67 69
     if (tmp != NULL) {
68 70
         mHistory.push_back(tmp);
69 71
 #ifdef DEBUG
70
-        printf("%s\n", tmp);
72
+        std::cout << tmp << std::endl;
71 73
 #endif
72 74
     }
73 75
 }
@@ -205,8 +207,6 @@ void Console::moveInHistory(bool up) {
205 207
 }
206 208
 
207 209
 void Console::handleText(char *text, bool notFinished) {
208
-    //printf("Text: %s (%s)\n", text, (notFinished ? "not finished" : "finished"));
209
-
210 210
     // Always scroll to bottom when text input is received
211 211
     mLineOffset = 0;
212 212
 
@@ -225,7 +225,7 @@ void Console::handleText(char *text, bool notFinished) {
225 225
         size_t length = strlen(text);
226 226
         if (length > 0) {
227 227
             if (((INPUT_BUFFER_SIZE - mInputBufferPointer) < length)) {
228
-                printf("Console input buffer overflowed! (> %d)\n", INPUT_BUFFER_SIZE);
228
+                print("Console input buffer overflowed! (> %d)", INPUT_BUFFER_SIZE);
229 229
                 return;
230 230
             }
231 231
             strcpy((mInputBuffer + mInputBufferPointer), text);

+ 3
- 20
src/Entity.cpp View File

@@ -34,21 +34,6 @@ Entity::Entity(TombRaider &tr, unsigned int index, unsigned int i, unsigned int
34 34
     animationFrame = 0;
35 35
     idleAnimation = 0;
36 36
     state = 0;
37
-
38
-    if (tr.Engine() == TR_VERSION_1) {
39
-        switch (objectId) {
40
-            case TombRaider1::Wolf:
41
-                state = TombRaider1::WolfState_Lying;
42
-                animationFrame = 3;
43
-                break;
44
-        }
45
-    }
46
-
47
-    // Gather more info if this is lara
48
-    if (objectId == 0) {
49
-        animationFrame = TR_ANIAMTION_RUN;
50
-        idleAnimation = TR_ANIAMTION_STAND;
51
-    }
52 37
 }
53 38
 
54 39
 bool Entity::operator<(Entity &o) {
@@ -60,9 +45,7 @@ bool Entity::operator<(Entity &o) {
60 45
 void Entity::display() {
61 46
     glPushMatrix();
62 47
     glTranslatef(pos[0], pos[1], pos[2]);
63
-    glRotatef(angles[0], 1, 0, 0);
64
-    glRotatef(angles[1], 0, 1, 0); // Only this was done for non-lara entities
65
-    glRotatef(angles[2], 0, 0, 1);
48
+    glRotatef(OR_RAD_TO_DEG(angles[1]), 0, 1, 0);
66 49
     getWorld().getSkeletalModel(skeletalModel).display(animationFrame, boneFrame);
67 50
     glPopMatrix();
68 51
 
@@ -131,7 +114,7 @@ void Entity::move(char movement) {
131 114
                 x, y, z);
132 115
 
133 116
         if (roomNew > -1)
134
-            printf("Crossing from room %i to %i\n", room, roomNew);
117
+            getConsole().print("Crossing from room %i to %i", room, roomNew);
135 118
         else
136 119
             //! \fixme mRooms, sectors, ... are now std::vector, but often upper bound checks are missing
137 120
             return;
@@ -230,7 +213,7 @@ void Entity::print() {
230 213
     getConsole().print("Entity %d:", objectId);
231 214
     getConsole().print("  Room %i (0x%X)", room, getWorld().getRoomInfo(room));
232 215
     getConsole().print("  %.1fx %.1fy %.1fz", pos[0], pos[1], pos[2]);
233
-    getConsole().print("  %.1f Yaw %.1f Pitch", OR_RAD_TO_DEG(angles[1]), OR_RAD_TO_DEG(angles[2]));
216
+    getConsole().print("  %.1f Yaw", OR_RAD_TO_DEG(angles[1]));
234 217
 }
235 218
 
236 219
 SkeletalModel &Entity::getModel() {

+ 9
- 24
src/Game.cpp View File

@@ -166,7 +166,6 @@ Entity &Game::getLara() {
166 166
 }
167 167
 
168 168
 void Game::processSprites() {
169
-    printf("Processing sprites: ");
170 169
     for (int i = 0; i < (mTombRaider.NumItems() - 1); i++) {
171 170
         if ((mTombRaider.Engine() == TR_VERSION_1) && (mTombRaider.Item()[i].intensity1 == -1))
172 171
             continue;
@@ -176,14 +175,15 @@ void Game::processSprites() {
176 175
                 getWorld().addSprite(*new SpriteSequence(mTombRaider, i, j));
177 176
         }
178 177
     }
179
-    printf("Done! Found %d sprites.\n", mTombRaider.NumSpriteSequences());
178
+
179
+    getConsole().print("Found %d sprites.", mTombRaider.NumSpriteSequences());
180 180
 }
181 181
 
182 182
 void Game::processRooms() {
183
-    printf("Processing rooms: ");
184 183
     for (int index = 0; index < mTombRaider.NumRooms(); index++)
185 184
         getWorld().addRoom(*new Room(mTombRaider, index));
186
-    printf("Done! Found %d rooms.\n", mTombRaider.NumRooms());
185
+
186
+    getConsole().print("Found %d rooms.", mTombRaider.NumRooms());
187 187
 }
188 188
 
189 189
 void Game::processPakSounds()
@@ -204,8 +204,6 @@ void Game::processPakSounds()
204 204
     // in this group, bits 0-1: channel number
205 205
     */
206 206
 
207
-    printf("Processing pak sound files: ");
208
-
209 207
     for (i = 0; i < mTombRaider.getSoundSamplesCount(); ++i)
210 208
     {
211 209
         mTombRaider.getSoundSample(i, &riffSz, &riff);
@@ -225,12 +223,9 @@ void Game::processPakSounds()
225 223
         //pos[1] = sound[i].y;
226 224
         //pos[2] = sound[i].z;
227 225
         //getSound().SourceAt(id, pos);
228
-
229
-        //printf(".");
230
-        //fflush(stdout);
231 226
     }
232 227
 
233
-    printf("Done! Found %u files.\n", mTombRaider.getSoundSamplesCount());
228
+    getConsole().print("Found %u sound samples.", mTombRaider.getSoundSamplesCount());
234 229
 }
235 230
 
236 231
 void Game::processTextures()
@@ -239,8 +234,6 @@ void Game::processTextures()
239 234
     unsigned char *bumpmap;
240 235
     int i;
241 236
 
242
-    printf("Processing TR textures: ");
243
-
244 237
     //if ( mTombRaider.getNumBumpMaps())
245 238
     //  gBumpMapStart = mTombRaider.NumTextures();
246 239
 
@@ -270,14 +263,11 @@ void Game::processTextures()
270 263
 
271 264
         if (bumpmap)
272 265
             delete [] bumpmap;
273
-
274
-        //printf(".");
275
-        //fflush(stdout);
276 266
     }
277 267
 
278 268
     mTextureOffset = (mTextureStart - 1) + mTombRaider.NumTextures();
279 269
 
280
-    printf("Done! Found %d textures.\n", mTombRaider.NumTextures());
270
+    getConsole().print("Found %d textures.", mTombRaider.NumTextures());
281 271
 }
282 272
 
283 273
 void Game::processMoveables()
@@ -288,8 +278,6 @@ void Game::processMoveables()
288 278
     tr2_item_t *item = mTombRaider.Item();
289 279
     tr2_sprite_sequence_t *sprite_sequence = mTombRaider.SpriteSequence();
290 280
 
291
-    printf("Processing skeletal models: ");
292
-
293 281
     for (int i = 0; i < mTombRaider.NumItems(); ++i)
294 282
     {
295 283
         int j;
@@ -364,7 +352,7 @@ void Game::processMoveables()
364 352
     }
365 353
     */
366 354
 
367
-    printf("Done! Found %d models.\n", mTombRaider.NumMoveables() + statCount);
355
+    getConsole().print("Found %d moveables.", mTombRaider.NumMoveables() + statCount);
368 356
 }
369 357
 
370 358
 // index moveable, i item, sometimes both moveable
@@ -438,7 +426,7 @@ void Game::setupTextureColor(texture_tri_t *r_tri, float *colorf)
438 426
     }
439 427
     else
440 428
     {
441
-        //printf("Color already loaded %i -> 0x%08x\n",
429
+        //getConsole().print("Color already loaded %i -> 0x%08x",
442 430
         //       gColorTextureHACK.getCurrentIndex(),
443 431
         //       gColorTextureHACK.current());
444 432
 
@@ -451,7 +439,6 @@ void Game::setupTextureColor(texture_tri_t *r_tri, float *colorf)
451 439
 
452 440
 void Game::processModels()
453 441
 {
454
-    printf("Processing meshes: ");
455 442
     for (int index = 0; index < mTombRaider.getMeshCount(); index++) {
456 443
         int i, j, count, texture;
457 444
         int vertexIndices[6];
@@ -465,8 +452,6 @@ void Game::processModels()
465 452
         {
466 453
             //! \fixme allow sparse lists with matching ids instead?
467 454
             getWorld().addMesh(NULL); // Filler, to make meshes array ids align
468
-            //printf("x");
469
-            //fflush(stdout);
470 455
             return;
471 456
         }
472 457
 
@@ -649,6 +634,6 @@ void Game::processModels()
649 634
         getWorld().addMesh(mesh);
650 635
     }
651 636
 
652
-    printf("Done! Found %d meshes.\n", mTombRaider.getMeshCount());
637
+    getConsole().print("Found %d meshes.", mTombRaider.getMeshCount());
653 638
 }
654 639
 

+ 3
- 5
src/OpenRaider.cpp View File

@@ -62,7 +62,7 @@ int OpenRaider::initialize() {
62 62
 
63 63
     error = getWindow().initializeFont();
64 64
     if (error != 0) {
65
-        printf("Could not initialize SDL-TTF (%d)!\n", error);
65
+        printf("Could not initialize Font (%d)!\n", error);
66 66
         return -3;
67 67
     }
68 68
 
@@ -75,7 +75,7 @@ int OpenRaider::initialize() {
75 75
     // Initialize game engine
76 76
     error = getGame().initialize();
77 77
     if (error != 0) {
78
-        printf("Could not initialize Game Engine (%d)!\n", error);
78
+        printf("Could not initialize Game (%d)!\n", error);
79 79
         return -5;
80 80
     }
81 81
 
@@ -456,11 +456,9 @@ int OpenRaider::bind(ActionEvents action, const char *key) {
456 456
 
457 457
 void OpenRaider::run() {
458 458
     assert(mRunning == false);
459
-
460 459
     mRunning = true;
461
-    while (mRunning) {
460
+    while (mRunning)
462 461
         frame();
463
-    }
464 462
 }
465 463
 
466 464
 void OpenRaider::frame() {

Loading…
Cancel
Save