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
 
21
 
22
     Assertion failed: (sector < (int)mRooms.at(room)->sizeSectors()), function isWall, file /Users/thomas/Projekte/OpenRaider/src/World.cpp, line 180.
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
 ## Cmake
26
 ## Cmake
27
 
27
 
36
     * Cut TGA image reader, currently only used for menu background?!
36
     * Cut TGA image reader, currently only used for menu background?!
37
 * When cutscene rendering is working, use TR4/5 style menu?
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
 #define TR_SOUND_FOOTSTEP0 1
17
 #define TR_SOUND_FOOTSTEP0 1
18
 #define TR_SOUND_F_PISTOL  12
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
 typedef enum {
32
 typedef enum {
33
     TR_VERSION_UNKNOWN,
33
     TR_VERSION_UNKNOWN,

+ 4
- 4
src/Console.cpp View File

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

+ 3
- 20
src/Entity.cpp View File

34
     animationFrame = 0;
34
     animationFrame = 0;
35
     idleAnimation = 0;
35
     idleAnimation = 0;
36
     state = 0;
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
 bool Entity::operator<(Entity &o) {
39
 bool Entity::operator<(Entity &o) {
60
 void Entity::display() {
45
 void Entity::display() {
61
     glPushMatrix();
46
     glPushMatrix();
62
     glTranslatef(pos[0], pos[1], pos[2]);
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
     getWorld().getSkeletalModel(skeletalModel).display(animationFrame, boneFrame);
49
     getWorld().getSkeletalModel(skeletalModel).display(animationFrame, boneFrame);
67
     glPopMatrix();
50
     glPopMatrix();
68
 
51
 
131
                 x, y, z);
114
                 x, y, z);
132
 
115
 
133
         if (roomNew > -1)
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
         else
118
         else
136
             //! \fixme mRooms, sectors, ... are now std::vector, but often upper bound checks are missing
119
             //! \fixme mRooms, sectors, ... are now std::vector, but often upper bound checks are missing
137
             return;
120
             return;
230
     getConsole().print("Entity %d:", objectId);
213
     getConsole().print("Entity %d:", objectId);
231
     getConsole().print("  Room %i (0x%X)", room, getWorld().getRoomInfo(room));
214
     getConsole().print("  Room %i (0x%X)", room, getWorld().getRoomInfo(room));
232
     getConsole().print("  %.1fx %.1fy %.1fz", pos[0], pos[1], pos[2]);
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
 SkeletalModel &Entity::getModel() {
219
 SkeletalModel &Entity::getModel() {

+ 9
- 24
src/Game.cpp View File

166
 }
166
 }
167
 
167
 
168
 void Game::processSprites() {
168
 void Game::processSprites() {
169
-    printf("Processing sprites: ");
170
     for (int i = 0; i < (mTombRaider.NumItems() - 1); i++) {
169
     for (int i = 0; i < (mTombRaider.NumItems() - 1); i++) {
171
         if ((mTombRaider.Engine() == TR_VERSION_1) && (mTombRaider.Item()[i].intensity1 == -1))
170
         if ((mTombRaider.Engine() == TR_VERSION_1) && (mTombRaider.Item()[i].intensity1 == -1))
172
             continue;
171
             continue;
176
                 getWorld().addSprite(*new SpriteSequence(mTombRaider, i, j));
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
 void Game::processRooms() {
182
 void Game::processRooms() {
183
-    printf("Processing rooms: ");
184
     for (int index = 0; index < mTombRaider.NumRooms(); index++)
183
     for (int index = 0; index < mTombRaider.NumRooms(); index++)
185
         getWorld().addRoom(*new Room(mTombRaider, index));
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
 void Game::processPakSounds()
189
 void Game::processPakSounds()
204
     // in this group, bits 0-1: channel number
204
     // in this group, bits 0-1: channel number
205
     */
205
     */
206
 
206
 
207
-    printf("Processing pak sound files: ");
208
-
209
     for (i = 0; i < mTombRaider.getSoundSamplesCount(); ++i)
207
     for (i = 0; i < mTombRaider.getSoundSamplesCount(); ++i)
210
     {
208
     {
211
         mTombRaider.getSoundSample(i, &riffSz, &riff);
209
         mTombRaider.getSoundSample(i, &riffSz, &riff);
225
         //pos[1] = sound[i].y;
223
         //pos[1] = sound[i].y;
226
         //pos[2] = sound[i].z;
224
         //pos[2] = sound[i].z;
227
         //getSound().SourceAt(id, pos);
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
 void Game::processTextures()
231
 void Game::processTextures()
239
     unsigned char *bumpmap;
234
     unsigned char *bumpmap;
240
     int i;
235
     int i;
241
 
236
 
242
-    printf("Processing TR textures: ");
243
-
244
     //if ( mTombRaider.getNumBumpMaps())
237
     //if ( mTombRaider.getNumBumpMaps())
245
     //  gBumpMapStart = mTombRaider.NumTextures();
238
     //  gBumpMapStart = mTombRaider.NumTextures();
246
 
239
 
270
 
263
 
271
         if (bumpmap)
264
         if (bumpmap)
272
             delete [] bumpmap;
265
             delete [] bumpmap;
273
-
274
-        //printf(".");
275
-        //fflush(stdout);
276
     }
266
     }
277
 
267
 
278
     mTextureOffset = (mTextureStart - 1) + mTombRaider.NumTextures();
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
 void Game::processMoveables()
273
 void Game::processMoveables()
288
     tr2_item_t *item = mTombRaider.Item();
278
     tr2_item_t *item = mTombRaider.Item();
289
     tr2_sprite_sequence_t *sprite_sequence = mTombRaider.SpriteSequence();
279
     tr2_sprite_sequence_t *sprite_sequence = mTombRaider.SpriteSequence();
290
 
280
 
291
-    printf("Processing skeletal models: ");
292
-
293
     for (int i = 0; i < mTombRaider.NumItems(); ++i)
281
     for (int i = 0; i < mTombRaider.NumItems(); ++i)
294
     {
282
     {
295
         int j;
283
         int j;
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
 // index moveable, i item, sometimes both moveable
358
 // index moveable, i item, sometimes both moveable
438
     }
426
     }
439
     else
427
     else
440
     {
428
     {
441
-        //printf("Color already loaded %i -> 0x%08x\n",
429
+        //getConsole().print("Color already loaded %i -> 0x%08x",
442
         //       gColorTextureHACK.getCurrentIndex(),
430
         //       gColorTextureHACK.getCurrentIndex(),
443
         //       gColorTextureHACK.current());
431
         //       gColorTextureHACK.current());
444
 
432
 
451
 
439
 
452
 void Game::processModels()
440
 void Game::processModels()
453
 {
441
 {
454
-    printf("Processing meshes: ");
455
     for (int index = 0; index < mTombRaider.getMeshCount(); index++) {
442
     for (int index = 0; index < mTombRaider.getMeshCount(); index++) {
456
         int i, j, count, texture;
443
         int i, j, count, texture;
457
         int vertexIndices[6];
444
         int vertexIndices[6];
465
         {
452
         {
466
             //! \fixme allow sparse lists with matching ids instead?
453
             //! \fixme allow sparse lists with matching ids instead?
467
             getWorld().addMesh(NULL); // Filler, to make meshes array ids align
454
             getWorld().addMesh(NULL); // Filler, to make meshes array ids align
468
-            //printf("x");
469
-            //fflush(stdout);
470
             return;
455
             return;
471
         }
456
         }
472
 
457
 
649
         getWorld().addMesh(mesh);
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
 
62
 
63
     error = getWindow().initializeFont();
63
     error = getWindow().initializeFont();
64
     if (error != 0) {
64
     if (error != 0) {
65
-        printf("Could not initialize SDL-TTF (%d)!\n", error);
65
+        printf("Could not initialize Font (%d)!\n", error);
66
         return -3;
66
         return -3;
67
     }
67
     }
68
 
68
 
75
     // Initialize game engine
75
     // Initialize game engine
76
     error = getGame().initialize();
76
     error = getGame().initialize();
77
     if (error != 0) {
77
     if (error != 0) {
78
-        printf("Could not initialize Game Engine (%d)!\n", error);
78
+        printf("Could not initialize Game (%d)!\n", error);
79
         return -5;
79
         return -5;
80
     }
80
     }
81
 
81
 
456
 
456
 
457
 void OpenRaider::run() {
457
 void OpenRaider::run() {
458
     assert(mRunning == false);
458
     assert(mRunning == false);
459
-
460
     mRunning = true;
459
     mRunning = true;
461
-    while (mRunning) {
460
+    while (mRunning)
462
         frame();
461
         frame();
463
-    }
464
 }
462
 }
465
 
463
 
466
 void OpenRaider::frame() {
464
 void OpenRaider::frame() {

Loading…
Cancel
Save