Thomas Buck 10 years ago
parent
commit
dbc1fa9507
5 changed files with 27 additions and 32 deletions
  1. 1
    1
      include/Entity.h
  2. 4
    5
      include/SkeletalModel.h
  3. 4
    3
      src/Entity.cpp
  4. 2
    2
      src/Game.cpp
  5. 16
    21
      src/SkeletalModel.cpp

+ 1
- 1
include/Entity.h View File

@@ -34,7 +34,7 @@ public:
34 34
     MoveType getMoveType();
35 35
     void setMoveType(MoveType m);
36 36
     int getObjectId();
37
-    void setAngles(vec_t yaw, vec_t pitch);
37
+    void setAngle(vec_t yaw);
38 38
     vec_t getPos(unsigned int i);
39 39
     vec_t getAngle(unsigned int i);
40 40
     int getRoom();

+ 4
- 5
include/SkeletalModel.h View File

@@ -16,7 +16,7 @@
16 16
 
17 17
 class BoneTag {
18 18
 public:
19
-    BoneTag(TombRaider &tr, unsigned int index, int j, unsigned int *l, unsigned int frame_offset);
19
+    BoneTag(TombRaider &tr, unsigned int index, unsigned int j, unsigned int *l, unsigned int frame_offset);
20 20
     void display();
21 21
 
22 22
     void getOffset(vec3_t o);
@@ -32,7 +32,7 @@ private:
32 32
 
33 33
 class BoneFrame {
34 34
 public:
35
-    BoneFrame(TombRaider &tr, unsigned int index, unsigned int i, unsigned int frame_offset);
35
+    BoneFrame(TombRaider &tr, unsigned int index, unsigned int frame_offset);
36 36
     ~BoneFrame();
37 37
 
38 38
     void getPosition(vec3_t p);
@@ -42,13 +42,12 @@ public:
42 42
 
43 43
 private:
44 44
     vec3_t pos;
45
-    vec_t yaw;
46 45
     std::vector<BoneTag *> tag;
47 46
 };
48 47
 
49 48
 class AnimationFrame {
50 49
 public:
51
-    AnimationFrame(TombRaider &tr, unsigned int index, unsigned int i, int a);
50
+    AnimationFrame(TombRaider &tr, unsigned int index, int a);
52 51
     ~AnimationFrame();
53 52
 
54 53
     unsigned int size();
@@ -61,7 +60,7 @@ private:
61 60
 
62 61
 class SkeletalModel {
63 62
 public:
64
-    SkeletalModel(TombRaider &tr, unsigned int index, unsigned int i, int objectId);
63
+    SkeletalModel(TombRaider &tr, unsigned int index, int objectId);
65 64
     ~SkeletalModel();
66 65
     void display(unsigned int aframe, unsigned int bframe);
67 66
 

+ 4
- 3
src/Entity.cpp View File

@@ -60,7 +60,9 @@ bool Entity::operator<(Entity &o) {
60 60
 void Entity::display() {
61 61
     glPushMatrix();
62 62
     glTranslatef(pos[0], pos[1], pos[2]);
63
-    glRotatef(angles[1], 0, 1, 0);
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);
64 66
     getWorld().getSkeletalModel(skeletalModel).display(animationFrame, boneFrame);
65 67
     glPopMatrix();
66 68
 
@@ -254,9 +256,8 @@ int Entity::getObjectId() {
254 256
     return objectId;
255 257
 }
256 258
 
257
-void Entity::setAngles(vec_t yaw, vec_t pitch) {
259
+void Entity::setAngle(vec_t yaw) {
258 260
     angles[1] = yaw;
259
-    angles[2] = pitch;
260 261
 }
261 262
 
262 263
 vec_t Entity::getPos(unsigned int i) {

+ 2
- 2
src/Game.cpp View File

@@ -155,7 +155,7 @@ void Game::handleMouseMotion(int xrel, int yrel) {
155 155
                 getCamera().command(CAMERA_ROTATE_DOWN);
156 156
 
157 157
         // Fix Laras rotation
158
-        getLara().setAngles(getCamera().getRadianYaw(), getCamera().getRadianPitch());
158
+        getLara().setAngle(getCamera().getRadianYaw());
159 159
     }
160 160
 }
161 161
 
@@ -380,7 +380,7 @@ void Game::processMoveable(int index, int i, int object_id) {
380 380
     }
381 381
 
382 382
     if (!cached) {
383
-        getWorld().addSkeletalModel(*new SkeletalModel(mTombRaider, index, i, object_id));
383
+        getWorld().addSkeletalModel(*new SkeletalModel(mTombRaider, index, object_id));
384 384
     }
385 385
 
386 386
     getWorld().addEntity(*new Entity(mTombRaider, index, i, mod));

+ 16
- 21
src/SkeletalModel.cpp View File

@@ -12,7 +12,7 @@
12 12
 #include "SkeletalModel.h"
13 13
 #include "World.h"
14 14
 
15
-BoneTag::BoneTag(TombRaider &tr, unsigned int index, int j, unsigned int *l, unsigned int frame_offset) {
15
+BoneTag::BoneTag(TombRaider &tr, unsigned int index, unsigned int i, unsigned int *l, unsigned int frame_offset) {
16 16
     tr2_moveable_t *moveable = tr.Moveable();
17 17
     tr2_meshtree_t *meshtree = tr.MeshTree();
18 18
     unsigned short *frame = tr.Frame();
@@ -24,10 +24,10 @@ BoneTag::BoneTag(TombRaider &tr, unsigned int index, int j, unsigned int *l, uns
24 24
     rot[0] = 0.0;
25 25
     rot[1] = 0.0;
26 26
     rot[2] = 0.0;
27
-    mesh = moveable[index].starting_mesh + j;
27
+    mesh = moveable[index].starting_mesh + i;
28 28
 
29 29
     // Setup offsets to produce skeleton
30
-    if (j == 0) {
30
+    if (i == 0) {
31 31
         // Always push tag[0], this isn't really used either
32 32
         flag = 0x02;
33 33
     } else { // Nonprimary tag - position relative to first tag
@@ -36,7 +36,7 @@ BoneTag::BoneTag(TombRaider &tr, unsigned int index, int j, unsigned int *l, uns
36 36
         //       into mesh_tree[], so we have to convert to index
37 37
         int *tree = (int *)(void *)meshtree;
38 38
         tr2_meshtree_t *mesh_tree = (tr2_meshtree_t *)(tree
39
-                + moveable[index].mesh_tree + ((j - 1) * 4));
39
+                + moveable[index].mesh_tree + ((i - 1) * 4));
40 40
 
41 41
         off[0] = mesh_tree->x;
42 42
         off[1] = mesh_tree->y;
@@ -68,23 +68,18 @@ char BoneTag::getFlag() {
68 68
     return flag;
69 69
 }
70 70
 
71
-BoneFrame::BoneFrame(TombRaider &tr, unsigned int index, unsigned int i, unsigned int frame_offset) {
71
+BoneFrame::BoneFrame(TombRaider &tr, unsigned int index, unsigned int frame_offset) {
72 72
     tr2_moveable_t *moveable = tr.Moveable();
73
-    tr2_item_t *item = tr.Item();
74 73
     unsigned short *frame = tr.Frame();
75 74
 
76
-    pos[0] = (short)(frame[frame_offset + 6]);
77
-    pos[1] = (short)(frame[frame_offset + 7]);
78
-    pos[2] = (short)(frame[frame_offset + 8]);
79
-
80
-    yaw = ((item[i].angle >> 14) & 0x03);
81
-    yaw *= 90;
75
+    pos[0] = (short)frame[frame_offset + 6];
76
+    pos[1] = (short)frame[frame_offset + 7];
77
+    pos[2] = (short)frame[frame_offset + 8];
82 78
 
83 79
     unsigned int l = 9; // First angle offset in this Frame
84 80
 
85
-    // Run through the tag and calculate the rotation and offset
86
-    for (int j = 0; j < (int)moveable[index].num_meshes; ++j)
87
-        tag.push_back(new BoneTag(tr, index, j, &l, frame_offset));
81
+    for (unsigned int i = 0; i < moveable[index].num_meshes; i++)
82
+        tag.push_back(new BoneTag(tr, index, i, &l, frame_offset));
88 83
 }
89 84
 
90 85
 BoneFrame::~BoneFrame() {
@@ -107,7 +102,7 @@ void BoneFrame::getPosition(vec3_t p) {
107 102
     p[2] = pos[2];
108 103
 }
109 104
 
110
-AnimationFrame::AnimationFrame(TombRaider &tr, unsigned int index, unsigned int i, int a) {
105
+AnimationFrame::AnimationFrame(TombRaider &tr, unsigned int index, int a) {
111 106
     tr2_moveable_t *moveable = tr.Moveable();
112 107
     tr2_animation_t *animation = tr.Animation();
113 108
 
@@ -144,12 +139,12 @@ AnimationFrame::AnimationFrame(TombRaider &tr, unsigned int index, unsigned int
144 139
         }
145 140
 
146 141
         if (frame_offset > tr.NumFrames()) {
147
-            getConsole().print("WARNING: Bad animation frame %i > %i (%u.%u.%d)",
148
-                    frame_offset, tr.NumFrames(), index, i, a);
142
+            getConsole().print("WARNING: Bad animation frame %i > %i (%u.%d)",
143
+                    frame_offset, tr.NumFrames(), index, a);
149 144
             return;
150 145
         }
151 146
 
152
-        frame.push_back(new BoneFrame(tr, index, i, frame_offset));
147
+        frame.push_back(new BoneFrame(tr, index, frame_offset));
153 148
     }
154 149
 }
155 150
 
@@ -167,7 +162,7 @@ BoneFrame &AnimationFrame::get(unsigned int i) {
167 162
     return *frame.at(i);
168 163
 }
169 164
 
170
-SkeletalModel::SkeletalModel(TombRaider &tr, unsigned int index, unsigned int i, int objectId) {
165
+SkeletalModel::SkeletalModel(TombRaider &tr, unsigned int index, int objectId) {
171 166
     tr2_moveable_t *moveable = tr.Moveable();
172 167
     tr2_animation_t *anim = tr.Animation();
173 168
     tr2_mesh_t *mesh = tr.Mesh();
@@ -252,7 +247,7 @@ SkeletalModel::SkeletalModel(TombRaider &tr, unsigned int index, unsigned int i,
252 247
         return;
253 248
     } else {
254 249
         for (; a < tr.getNumAnimsForMoveable(index); a++) {
255
-            animation.push_back(new AnimationFrame(tr, index, i, a));
250
+            animation.push_back(new AnimationFrame(tr, index, a));
256 251
         }
257 252
     }
258 253
 }

Loading…
Cancel
Save