浏览代码

Fixed wrong entity rotation

Thomas Buck 10 年前
父节点
当前提交
93e008178b
共有 3 个文件被更改,包括 11 次插入22 次删除
  1. 2
    1
      ChangeLog.md
  2. 3
    4
      src/Entity.cpp
  3. 6
    17
      src/SkeletalModel.cpp

+ 2
- 1
ChangeLog.md 查看文件

@@ -3,7 +3,8 @@
3 3
 ## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>
4 4
 
5 5
     [ 20140617 ]
6
-    * Finally fixed SkeletalModel bug introduced a month ago
6
+    * Finally fixed SkeletalModel bugs introduced a month ago
7
+      (animations and rotations are *mostly* correct now)
7 8
     * Reimplemented *animate* command
8 9
 
9 10
     [ 20140615 ]

+ 3
- 4
src/Entity.cpp 查看文件

@@ -17,14 +17,11 @@ Entity::Entity(TombRaider &tr, unsigned int index, unsigned int i, unsigned int
17 17
     tr2_moveable_t *moveable = tr.Moveable();
18 18
     tr2_item_t *item = tr.Item();
19 19
 
20
-    vec_t yaw = ((item[i].angle >> 14) & 0x03);
21
-    yaw *= 90;
22
-
23 20
     pos[0] = item[i].x;
24 21
     pos[1] = item[i].y;
25 22
     pos[2] = item[i].z;
26 23
     angles[0] = 0;
27
-    angles[1] = yaw;
24
+    angles[1] = OR_DEG_TO_RAD(((item[i].angle >> 14) & 0x03) * 90.0f);
28 25
     angles[2] = 0;
29 26
     objectId = moveable[index].object_id;
30 27
     moveType = MoveTypeWalk;
@@ -46,6 +43,8 @@ void Entity::display() {
46 43
     glPushMatrix();
47 44
     glTranslatef(pos[0], pos[1], pos[2]);
48 45
     glRotatef(OR_RAD_TO_DEG(angles[1]), 0, 1, 0);
46
+    glRotatef(OR_RAD_TO_DEG(angles[0]), 1, 0, 0);
47
+    glRotatef(OR_RAD_TO_DEG(angles[2]), 0, 0, 1);
49 48
     getWorld().getSkeletalModel(skeletalModel).display(animationFrame, boneFrame);
50 49
     glPopMatrix();
51 50
 

+ 6
- 17
src/SkeletalModel.cpp 查看文件

@@ -280,14 +280,9 @@ void SkeletalModel::display(unsigned int aframe, unsigned int bframe) {
280 280
         tag.getOffset(off);
281 281
 
282 282
         if (a == 0) {
283
-            if (!equalEpsilon(rot[1], 0.0f))
284
-                glRotatef(rot[1], 0, 1, 0);
285
-
286
-            if (!equalEpsilon(rot[0], 0.0f))
287
-                glRotatef(rot[0], 1, 0, 0);
288
-
289
-            if (!equalEpsilon(rot[2], 0.0f))
290
-                glRotatef(rot[2], 0, 0, 1);
283
+            glRotatef(rot[1], 0, 1, 0);
284
+            glRotatef(rot[0], 1, 0, 0);
285
+            glRotatef(rot[2], 0, 0, 1);
291 286
         } else {
292 287
             if (tag.getFlag() & 0x01)
293 288
                 glPopMatrix();
@@ -296,15 +291,9 @@ void SkeletalModel::display(unsigned int aframe, unsigned int bframe) {
296 291
                 glPushMatrix();
297 292
 
298 293
             glTranslatef(off[0], off[1], off[2]);
299
-
300
-            if (!equalEpsilon(rot[1], 0.0f))
301
-                glRotatef(rot[1], 0, 1, 0);
302
-
303
-            if (!equalEpsilon(rot[0], 0.0f))
304
-                glRotatef(rot[0], 1, 0, 0);
305
-
306
-            if (!equalEpsilon(rot[2], 0.0f))
307
-                glRotatef(rot[2], 0, 0, 1);
294
+            glRotatef(rot[1], 0, 1, 0);
295
+            glRotatef(rot[0], 1, 0, 0);
296
+            glRotatef(rot[2], 0, 0, 1);
308 297
         }
309 298
 
310 299
         // Draw layered lara in TR4 (2 meshes per tag)

正在加载...
取消
保存