瀏覽代碼

Ported Entity and SkeletalModel constructor

Thomas Buck 10 年之前
父節點
當前提交
4a08d4c789
共有 6 個檔案被更改,包括 223 行新增322 行删除
  1. 1
    1
      include/Entity.h
  2. 0
    1
      include/SkeletalModel.h
  3. 35
    1
      src/Entity.cpp
  4. 8
    307
      src/Game.cpp
  5. 179
    10
      src/SkeletalModel.cpp
  6. 0
    2
      src/World.cpp

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

@@ -21,7 +21,7 @@ public:
21 21
         MoveTypeSwim       = 3
22 22
     } MoveType;
23 23
 
24
-    Entity(TombRaider &tr);
24
+    Entity(TombRaider &tr, unsigned int index, unsigned int i, unsigned int model);
25 25
 
26 26
     bool operator<(Entity &o);
27 27
     void display();

+ 0
- 1
include/SkeletalModel.h 查看文件

@@ -62,7 +62,6 @@ public:
62 62
 
63 63
     unsigned int size();
64 64
     AnimationFrame &get(unsigned int i);
65
-    void add(AnimationFrame &a);
66 65
 
67 66
 private:
68 67
     int id;

+ 35
- 1
src/Entity.cpp 查看文件

@@ -19,8 +19,42 @@
19 19
 #include "Entity.h"
20 20
 #include "main.h"
21 21
 
22
-Entity::Entity(TombRaider &tr) {
22
+Entity::Entity(TombRaider &tr, unsigned int index, unsigned int i, unsigned int model) {
23
+    tr2_moveable_t *moveable = tr.Moveable();
24
+    tr2_item_t *item = tr.Item();
23 25
 
26
+    vec_t yaw = ((item[i].angle >> 14) & 0x03);
27
+    yaw *= 90;
28
+
29
+    pos[0] = item[i].x;
30
+    pos[1] = item[i].y;
31
+    pos[2] = item[i].z;
32
+    angles[0] = 0;
33
+    angles[1] = yaw;
34
+    angles[2] = 0;
35
+    objectId = moveable[index].object_id;
36
+    moveType = MoveTypeWalk;
37
+    room = getWorld().getRoomByLocation(pos[0], pos[1], pos[2]);
38
+    skeletalModel = model;
39
+    boneFrame = 0;
40
+    animationFrame = 0;
41
+    idleAnimation = 0;
42
+    state = 0;
43
+
44
+    if (tr.Engine() == TR_VERSION_1) {
45
+        switch (objectId) {
46
+            case TombRaider1::Wolf:
47
+                state = TombRaider1::WolfState_Lying;
48
+                animationFrame = 3;
49
+                break;
50
+        }
51
+    }
52
+
53
+    // Gather more info if this is lara
54
+    if (objectId == 0) {
55
+        animationFrame = TR_ANIAMTION_RUN;
56
+        idleAnimation = TR_ANIAMTION_STAND;
57
+    }
24 58
 }
25 59
 
26 60
 bool Entity::operator<(Entity &o) {

+ 8
- 307
src/Game.cpp 查看文件

@@ -381,13 +381,10 @@ void Game::processMoveables()
381 381
 
382 382
 // index moveable, i item, sometimes both moveable
383 383
 // object_id of item or moveable
384
-void Game::processMoveable(int index, int i, int object_id)
385
-{
386
-    //std::vector<skeletal_model_t *> &cache2
387
-    //std::vector<unsigned int> &cache
388
-
384
+void Game::processMoveable(int index, int i, int object_id) {
389 385
     bool cached = false;
390
-    for (unsigned int mod = 0; mod < getWorld().sizeSkeletalModel(); mod++) {
386
+    unsigned int mod = 0;
387
+    for (; mod < getWorld().sizeSkeletalModel(); mod++) {
391 388
         if (getWorld().getSkeletalModel(mod).getId() == moveable[index].object_id) {
392 389
             cached = true;
393 390
             break;
@@ -395,310 +392,14 @@ void Game::processMoveable(int index, int i, int object_id)
395 392
     }
396 393
 
397 394
     if (!cached) {
398
-        getWorld().addSkeletalModel(*new SkeletalModel(mTombRaider, index));
399
-    }
400
-
401
-    getWorld().addEntity(*new Entity(mTombRaider, /* ... */ mod));
402
-
403
-
404
-
405
-    // This creates both Entity and SkeletalModel
406
-    // Basic Idea:
407
-    // - Move animation state from SkeletalModel into Entity
408
-    // - Check if skeletal model is already stored
409
-    // - If so tell new Entity to reuse
410
-    // - Else store new skeletal model, tell new entity to use this one
411
-
412
-
413
-
414
-
415
-    int j, k, a, frame_step;
416
-    unsigned int l, frame_offset, frame_count, f;
417
-
418
-    unsigned short *frame = mTombRaider.Frame();
419
-    tr2_moveable_t *moveable = mTombRaider.Moveable();
420
-    tr2_meshtree_t *meshtree = mTombRaider.MeshTree();
421
-    tr2_mesh_t *mesh = mTombRaider.Mesh();
422
-    tr2_item_t *item = mTombRaider.Item();
423
-    tr2_animation_t *animation = mTombRaider.Animation();
424
-
425
-    float yaw = ((item[i].angle >> 14) & 0x03);
426
-    yaw *= 90;
427
-
428
-    entity_t *thing = new entity_t;
429
-    thing->pos[0] = item[i].x;
430
-    thing->pos[1] = item[i].y;
431
-    thing->pos[2] = item[i].z;
432
-    thing->angles[1] = yaw;
433
-    thing->objectId = moveable[index].object_id;
434
-
435
-    SkeletalModel *sModel = new SkeletalModel();
436
-    getRender().addSkeletalModel(sModel);
437
-    thing->tmpHook = sModel; // temp hack to keep a running version during refactoring
438
-
439
-    if (mTombRaider.Engine() == TR_VERSION_1)
440
-    {
441
-        switch (thing->objectId)
442
-        {
443
-            case TombRaider1::Wolf:
444
-                thing->state = TombRaider1::WolfState_Lying;
445
-                sModel->setAnimation(3);
446
-                sModel->setFrame(0);
447
-                break;
448
-        }
449
-    }
450
-
451
-    skeletal_model_t *r_model = new skeletal_model_t;
452
-    r_model->id = moveable[index].object_id;
453
-
454
-    // Gather more info if this is lara
455
-    if (moveable[index].object_id == 0)
456
-    {
457
-        mLara = thing; // Mongoose 2002.03.22, Cheap hack for now
458
-
459
-        sModel->setAnimation(TR_ANIAMTION_RUN);
460
-        sModel->setIdleAnimation(TR_ANIAMTION_STAND);
461
-
462
-        // Only TR4 lara has 2 layer bone tags/meshes per bone frame
463
-        r_model->tr4Overlay = (mTombRaider.Engine() == TR_VERSION_4);
464
-        r_model->ponytailId = 0;
465
-    }
466
-    else
467
-    {
468
-        r_model->ponytailId = -1;
469
-    }
470
-
471
-    // Animation
472
-    a = moveable[index].animation;
473
-
474
-    frame_offset = animation[a].frame_offset / 2;
475
-    frame_step = animation[a].frame_size;
476
-
477
-    if (a >= (int)mTombRaider.NumAnimations())
478
-    {
479
-        a = mTombRaider.NumFrames() - frame_offset;
480
-    }
481
-    else
482
-    {
483
-        a = (animation[a].frame_offset / 2) - frame_offset;
484
-    }
485
-
486
-    if (frame_step != 0)  // prevent divide-by-zero errors
487
-        a /= frame_step;
488
-
489
-    if (a < 0)
490
-    {
491
-        //continue;
492
-        getConsole().print("Invalid animation data for model %d", index);
493
-        delete r_model;
494
-        return; // leaking thing here!
495
-    }
496
-
497
-    //! \fixme Might be better UID for each model, but this seems to work well
498
-    j = object_id;
499
-
500
-    // We only want one copy of the skeletal model in memory
501
-    unsigned int foundIndex;
502
-    bool found = false;
503
-    for (foundIndex = 0; foundIndex < cache.size(); foundIndex++) {
504
-        if ((int)cache[foundIndex] == j) {
505
-            found = true;
506
-            break;
507
-        }
395
+        getWorld().addSkeletalModel(*new SkeletalModel(mTombRaider, index, i));
508 396
     }
509
-    if (!found)
510
-    {
511
-        sModel->model = r_model;
512
-        getWorld().addEntity(thing);
513
-
514
-        k = getWorld().addModel(r_model);
515
-
516
-        cache.push_back(j);
517
-        cache2.push_back(r_model);
518
-
519
-        switch (mTombRaider.Engine())
520
-        {
521
-            case TR_VERSION_4:
522
-                if (mLara && moveable[index].object_id == 30)
523
-                {
524
-                    r_model->ponytailId = k;
525
-                    r_model->ponytailMeshId = moveable[index].starting_mesh;
526
-                    r_model->ponytailNumMeshes = ((moveable[index].num_meshes > 0) ?
527
-                            moveable[index].num_meshes : 0);
528
-                    r_model->ponytailAngle = -90.0f;
529
-                    r_model->ponytail[0] = -3;
530
-                    r_model->ponytail[1] = -22;
531
-                    r_model->ponytail[2] = -20;
532
-                    r_model->ponyOff = 40;
533
-                    r_model->ponyOff2 = 32;
534
-                    r_model->pigtails = false;
535
-
536
-                    // Try to guess pigtails by looking for certian num verts in head
537
-                    if (mesh[moveable[0].starting_mesh].num_vertices > 80)
538
-                    {
539
-                        r_model->pigtails = true;
540
-                        r_model->ponyOff -= 20;
541
-                        r_model->ponytail[1] -= 32;
542
-                    }
543
-
544
-                    getRender().setFlags(Render::fRenderPonytail);
545
-                    getConsole().print("Found known ponytail");
546
-                }
547
-                break; // ?
548
-            case TR_VERSION_1:
549
-            case TR_VERSION_2:
550
-            case TR_VERSION_3:
551
-            case TR_VERSION_5:
552
-            case TR_VERSION_UNKNOWN:
553
-                if (mLara && moveable[index].object_id == 2)
554
-                {
555
-                    r_model->ponytailId = k;
556
-                    r_model->ponytailMeshId = moveable[index].starting_mesh;
557
-                    r_model->ponytailNumMeshes = ((moveable[index].num_meshes > 0) ?
558
-                            moveable[index].num_meshes : 0);
559
-                    r_model->ponytailAngle = -90.0f;
560
-                    r_model->ponytail[0] = 0;
561
-                    r_model->ponytail[1] = -20;
562
-                    r_model->ponytail[2] = -20;
563
-                    r_model->ponyOff = 40;
564
-                    r_model->ponyOff2 = 0;
565
-
566
-                    getRender().setFlags(Render::fRenderPonytail);
567
-                    getConsole().print("Found ponytail?");
568
-                }
569
-                break;
570
-        }
571
-    }
572
-    else
573
-    {
574
-        // Already cached
575
-        delete r_model;
576
-        r_model = cache2[foundIndex];
577
-        sModel->model = r_model;
578
-        getWorld().addEntity(thing);
579
-        getWorld().addModel(r_model);
580
-        printf("c");
581
-        return;
582
-    }
583
-
584
-    //a = moveable[index].animation;
585
-    //frame_offset = animation[a].frame_offset / 2;
586
-    //frame_step = animation[a].frame_size;
587
-
588
-    for (; a < mTombRaider.getNumAnimsForMoveable(index); a++) {
589
-        frame_offset = animation[a].frame_offset / 2;
590
-        frame_step = animation[a].frame_size;
591
-
592
-        animation_frame_t *animation_frame = new animation_frame_t;
593
-        r_model->animation.push_back(animation_frame);
594 397
 
595
-        frame_count = (animation[a].frame_end - animation[a].frame_start) + 1;
596
-        animation_frame->rate = animation[a].frame_rate;
398
+    getWorld().addEntity(*new Entity(mTombRaider, index, i, mod));
597 399
 
598
-        // Get all the frames for aniamtion
599
-        for (f = 0; f < frame_count; ++f, frame_offset += frame_step)
600
-        {
601
-            // HACK: Lara's ObjectID is 315, but her meshes start at 0, so make a
602
-            // quick substitution (so she doesn't appear as a bunch of thighs)
603
-            if (index == 0 && mTombRaider.Engine() == TR_VERSION_3)
604
-            {
605
-                for (j = 0; j < (int)mTombRaider.NumMoveables() && !index; ++j)
606
-                {
607
-                    if (moveable[j].object_id == 315)
608
-                        index = j;
609
-                }
610
-            }
611
-
612
-            // Fix Lara in TR4
613
-            if (index == 0 && mTombRaider.Engine() == TR_VERSION_4)
614
-            {
615
-                for (j = 0; j < (int)mTombRaider.NumMoveables() && !index; ++j)
616
-                {
617
-                    // Body is ItemID 8, joints are ItemID 9
618
-                    //  (TR4 demo: body is ItemID 10, joints are ItemID 11)
619
-                    if (moveable[j].object_id == 8)
620
-                        index = j;
621
-                }
622
-            }
623
-            else if (moveable[index].object_id == 8 &&
624
-                    mTombRaider.Engine() == TR_VERSION_4)
625
-            {
626
-                // KLUDGE to do "skinning"
627
-                index = 0;
628
-
629
-                for (j = 0; j < (int)mTombRaider.NumMoveables() && !index; ++j)
630
-                {
631
-                    // Body is ItemID 8, joints are ItemID 9
632
-                    //  (TR4 demo: body is ItemID 10, joints are ItemID 11)
633
-                    if (moveable[j].object_id == 9)
634
-                        index = j;
635
-                }
636
-            }
637
-
638
-            // Mongoose 2002.08.15, Was
639
-            //   if (frame_offset + 8 > _tombraider.NumFrames())
640
-            if (frame_offset > mTombRaider.NumFrames())
641
-            {
642
-                getConsole().print("WARNING: Bad animation frame %i > %i",
643
-                        frame_offset, mTombRaider.NumFrames());
644
-                return; //continue;
645
-            }
646
-
647
-            // Generate bone frames and tags per frame ////////////
648
-            bone_frame_t *bone = new bone_frame_t;
649
-            animation_frame->frame.push_back(bone);
650
-
651
-            // Init translate for bone frame
652
-            bone->pos[0] = (short)frame[frame_offset + 6];
653
-            bone->pos[1] = (short)frame[frame_offset + 7];
654
-            bone->pos[2] = (short)frame[frame_offset + 8];
655
-            bone->yaw = yaw;
656
-
657
-            //printf("%f %f %f\n", bone->pos[0], bone->pos[1], bone->pos[2]);
658
-
659
-            l = 9;   // First angle offset in this Frame
660
-
661
-            // Run through the tag and calculate the rotation and offset
662
-            for (j = 0; j < (int)moveable[index].num_meshes; ++j)
663
-            {
664
-                bone_tag_t *tag = new bone_tag_t;
665
-                bone->tag.push_back(tag);
666
-                tag->off[0] = 0.0;
667
-                tag->off[1] = 0.0;
668
-                tag->off[2] = 0.0;
669
-                tag->flag = 0x00;
670
-                tag->rot[0] = 0.0;
671
-                tag->rot[1] = 0.0;
672
-                tag->rot[2] = 0.0;
673
-                tag->mesh = moveable[index].starting_mesh + j;
674
-
675
-                // Setup offsets to produce skeletion
676
-                if (j == 0)
677
-                {
678
-                    // Always push tag[0], this isn't really used either
679
-                    tag->flag = 0x02;
680
-                }
681
-                else  // Nonprimary tag - position relative to first tag
682
-                {
683
-                    int *tree;
684
-                    // Hack: moveable[index].mesh_tree is a byte offset
685
-                    //       into mesh_tree[], so we have to convert to index
686
-                    tree = (int *)(void *)meshtree;
687
-                    tr2_meshtree_t *mesh_tree = (tr2_meshtree_t *)&tree[moveable[index].mesh_tree
688
-                        + ((j - 1) * 4)];
689
-
690
-                    tag->off[0] = mesh_tree->x;
691
-                    tag->off[1] = mesh_tree->y;
692
-                    tag->off[2] = mesh_tree->z;
693
-                    tag->flag = (char)mesh_tree->flags;
694
-                }
695
-
696
-                // Setup tag rotations
697
-                mTombRaider.computeRotationAngles(&frame, &frame_offset, &l,
698
-                        tag->rot, tag->rot+1, tag->rot+2);
699
-            }
700
-        }
701
-    }
400
+    // Store reference to Lara
401
+    if (getWorld().getEntity(getWorld().sizeEntity() - 1).getObjectId() == 0)
402
+        mLara = getWorld().sizeEntity() - 1;
702 403
 
703 404
     if (i == mTombRaider.getSkyModelId())
704 405
         getRender().setSkyMesh(i, //moveable[i].starting_mesh,

+ 179
- 10
src/SkeletalModel.cpp 查看文件

@@ -8,14 +8,60 @@
8 8
 
9 9
 #include <assert.h>
10 10
 
11
+#include "main.h"
11 12
 #include "SkeletalModel.h"
12 13
 
13
-BoneTag::BoneTag() {
14
+BoneTag::BoneTag(TombRaider &tr, unsigned int index, int j, unsigned int *l) {
15
+    tr2_moveable_t *moveable = mTombRaider.Moveable();
16
+    tr2_meshtree_t *meshtree = mTombRaider.MeshTree();
14 17
 
18
+    off[0] = 0.0;
19
+    off[1] = 0.0;
20
+    off[2] = 0.0;
21
+    flag = 0x00;
22
+    rot[0] = 0.0;
23
+    rot[1] = 0.0;
24
+    rot[2] = 0.0;
25
+    mesh = moveable[index].starting_mesh + j;
26
+
27
+    // Setup offsets to produce skeleton
28
+    if (j == 0) {
29
+        // Always push tag[0], this isn't really used either
30
+        tag->flag = 0x02;
31
+    } else { // Nonprimary tag - position relative to first tag
32
+
33
+        // Hack: moveable[index].mesh_tree is a byte offset
34
+        //       into mesh_tree[], so we have to convert to index
35
+        int *tree = (int *)(void *)meshtree;
36
+        tr2_meshtree_t *mesh_tree = (tr2_meshtree_t *)(tree
37
+                + moveable[index].mesh_tree + ((j - 1) * 4));
38
+
39
+        off[0] = mesh_tree->x;
40
+        off[1] = mesh_tree->y;
41
+        off[2] = mesh_tree->z;
42
+        flag = (char)mesh_tree->flags;
43
+    }
44
+
45
+    // Setup tag rotations
46
+    tr.computeRotationAngles(&frame, &frame_offset, l, rot, rot+1, rot+2);
15 47
 }
16 48
 
17
-BoneFrame::BoneFrame() {
49
+BoneFrame::BoneFrame(TombRaider &tr, unsigned int index, unsigned int i, unsigned int frame_offset) {
50
+    tr2_moveable_t *moveable = mTombRaider.Moveable();
51
+    unsigned short *frame = mTombRaider.Frame();
52
+
53
+    pos[0] = (short)frame[frame_offset + 6];
54
+    pos[1] = (short)frame[frame_offset + 7];
55
+    pos[2] = (short)frame[frame_offset + 8];
56
+
57
+    yaw = ((item[i].angle >> 14) & 0x03);
58
+    yaw *= 90;
18 59
 
60
+    unsigned int l = 9; // First angle offset in this Frame
61
+
62
+    // Run through the tag and calculate the rotation and offset
63
+    for (int j = 0; j < (int)moveable[index].num_meshes; ++j)
64
+        tag.push_back(*new BoneTag(tr, index, j, &l));
19 65
 }
20 66
 
21 67
 BoneFrame::~BoneFrame() {
@@ -36,8 +82,50 @@ void BoneFrame::add(BoneTag &b) {
36 82
     tag.push_back(&b);
37 83
 }
38 84
 
39
-AnimationFrame::AnimationFrame() {
40
-
85
+AnimationFrame::AnimationFrame(TombRaider &tr, unsigned int index, unsigned int i, int a) {
86
+    tr2_moveable_t *moveable = mTombRaider.Moveable();
87
+    tr2_animation_t *animation = mTombRaider.Animation();
88
+
89
+    unsigned int frame_offset = animation[a].frame_offset / 2;
90
+    int frame_step = animation[a].frame_size;
91
+    unsigned int frame_count = (animation[a].frame_end - animation[a].frame_start) + 1;
92
+    rate = animation[a].frame_rate;
93
+
94
+    for (unsigned int f = 0; f < frame_count; f++, frame_offset += frame_step) {
95
+        // HACK: Lara's ObjectID is 315, but her meshes start at 0, so make a
96
+        // quick substitution (so she doesn't appear as a bunch of thighs)
97
+        if ((index == 0) && (tr.Engine() == TR_VERSION_3)) {
98
+            for (int j = 0; (j < (int)tr.NumMoveables()) && (index == 0); j++) {
99
+                if (moveable[j].object_id == 315)
100
+                    index = j;
101
+            }
102
+        }
103
+
104
+        // Fix Lara in TR4
105
+        // Body is ItemID 8, joints are ItemID 9
106
+        // (TR4 demo: body is ItemID 10, joints are ItemID 11)
107
+        if ((index == 0) && (tr.Engine() == TR_VERSION_4)) {
108
+            for (int j = 0; (j < (int)tr.NumMoveables()) && (index == 0); j++) {
109
+                if (moveable[j].object_id == 8)
110
+                    index = j;
111
+            }
112
+        } else if ((moveable[index].object_id == 8) && (tr.Engine() == TR_VERSION_4)) {
113
+            // KLUDGE to do "skinning"
114
+            index = 0;
115
+            for (int j = 0; (j < (int)tr.NumMoveables()) && (index == 0); j++) {
116
+                if (moveable[j].object_id == 9)
117
+                    index = j;
118
+            }
119
+        }
120
+
121
+        if (frame_offset > tr.NumFrames()) {
122
+            getConsole().print("WARNING: Bad animation frame %i > %i",
123
+                    frame_offset, tr.NumFrames());
124
+            return;
125
+        }
126
+
127
+        frame.push_back(*new BoneFrame(tr, index, i, frame_offset));
128
+    }
41 129
 }
42 130
 
43 131
 AnimationFrame::~AnimationFrame() {
@@ -58,8 +146,93 @@ void AnimationFrame::add(BoneFrame &b) {
58 146
     frame.push_back(&b);
59 147
 }
60 148
 
61
-SkeletalModel::SkeletalModel(TombRaider &tr, unsigned int index) {
62
-
149
+SkeletalModel::SkeletalModel(TombRaider &tr, unsigned int index, unsigned int i) {
150
+    tr2_moveable_t *moveable = mTombRaider.Moveable();
151
+    tr2_animation_t *anim = mTombRaider.Animation();
152
+
153
+    id = moveable[index].object_id;
154
+
155
+    // Gather more info if this is lara
156
+    if (id == 0) {
157
+        // Only TR4 lara has 2 layer bone tags/meshes per bone frame
158
+        tr4Overlay = (mTombRaider.Engine() == TR_VERSION_4);
159
+        ponytailId = 0;
160
+    } else {
161
+        tr4Overlay = false;
162
+        ponytailId = -1;
163
+    }
164
+
165
+    switch (mTombRaider.Engine()) {
166
+        case TR_VERSION_4:
167
+            if (moveable[index].object_id == 30) {
168
+                ponytailId = getWorld().sizeSkeletalModel(); //! \fixme Why is this even needed?
169
+                ponytailMeshId = moveable[index].starting_mesh;
170
+                ponytailNumMeshes = ((moveable[index].num_meshes > 0) ?
171
+                        moveable[index].num_meshes : 0);
172
+                ponytailAngle = -90.0f;
173
+                ponytail[0] = -3;
174
+                ponytail[1] = -22;
175
+                ponytail[2] = -20;
176
+                ponyOff = 40;
177
+                ponyOff2 = 32;
178
+                pigtails = false;
179
+
180
+                // Try to guess pigtails by looking for certian num verts in head
181
+                if (mesh[moveable[0].starting_mesh].num_vertices > 80) {
182
+                    pigtails = true;
183
+                    ponyOff -= 20;
184
+                    ponytail[1] -= 32;
185
+                }
186
+
187
+                getRender().setFlags(Render::fRenderPonytail);
188
+                getConsole().print("Found known ponytail");
189
+            }
190
+            break;
191
+
192
+        case TR_VERSION_1:
193
+        case TR_VERSION_2:
194
+        case TR_VERSION_3:
195
+        case TR_VERSION_5:
196
+        case TR_VERSION_UNKNOWN:
197
+            if (moveable[index].object_id == 2) {
198
+                ponytailId = k;
199
+                ponytailMeshId = moveable[index].starting_mesh;
200
+                ponytailNumMeshes = ((moveable[index].num_meshes > 0) ?
201
+                        moveable[index].num_meshes : 0);
202
+                ponytailAngle = -90.0f;
203
+                ponytail[0] = 0;
204
+                ponytail[1] = -20;
205
+                ponytail[2] = -20;
206
+                ponyOff = 40;
207
+                ponyOff2 = 0;
208
+
209
+                getRender().setFlags(Render::fRenderPonytail);
210
+                getConsole().print("Found ponytail?");
211
+            }
212
+            break;
213
+    }
214
+
215
+    // Animations
216
+    int a = moveable[index].animation;
217
+    unsigned int frame_offset = anim[a].frame_offset / 2;
218
+    int frame_step = anim[a].frame_size;
219
+
220
+    if (a >= (int)tr.NumAnimations())
221
+        a = tr.NumFrames() - frame_offset; //! \fixme Couldn't a be already used out of range?!
222
+    else
223
+        a = (anim[a].frame_offset / 2) - frame_offset;
224
+
225
+    if (frame_step != 0) // prevent divide-by-zero errors
226
+        a /= frame_step;
227
+
228
+    if (a < 0) {
229
+        getConsole().print("Invalid animation data for model %d. Skip!", index);
230
+        return;
231
+    } else {
232
+        for (; a < tr.getNumAnimsForMoveable(index); a++) {
233
+            animation.push_back(new AnimationFrame(tr, index, i, a))
234
+        }
235
+    }
63 236
 }
64 237
 
65 238
 SkeletalModel::~SkeletalModel() {
@@ -80,7 +253,3 @@ AnimationFrame &SkeletalModel::get(unsigned int i) {
80 253
     return *animation.at(i);
81 254
 }
82 255
 
83
-void SkeletalModel::add(AnimationFrame &a) {
84
-    animation.push_back(&a);
85
-}
86
-

+ 0
- 2
src/World.cpp 查看文件

@@ -227,8 +227,6 @@ SpriteSequence &World::getSprite(unsigned int index) {
227 227
 }
228 228
 
229 229
 void World::addEntity(Entity &entity) {
230
-    //e->moveType = worldMoveType_walk; // Walk
231
-    //e->room = getRoomByLocation(e->pos[0], e->pos[1], e->pos[2]);
232 230
     mEntities.push_back(&entity);
233 231
 }
234 232
 

Loading…
取消
儲存