summaryrefslogtreecommitdiffstats
path: root/graphics/crystalspace-devel/files/patch-plugins-mesh-sprcal3d-object_sprcal3d.cpp
blob: 0f103199482db33d85c94a0635191080bb582c65 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
--- plugins/mesh/sprcal3d/object/sprcal3d.cpp   Wed Aug 16 10:45:55 2006
+++ plugins/mesh/sprcal3d/object/sprcal3d.cpp   Wed Aug 16 23:34:50 2006
@@ -53,6 +53,8 @@
 
 
 #include "sprcal3d.h"
+#include <cal3d/coretrack.h>
+#include <cal3d/corekeyframe.h>
 
 // STL include required by cal3d
 #include <string>
@@ -657,10 +659,12 @@
     ->getVectorCoreBone();
 
   // loop through all root core bones
-  std::list<int>::iterator iteratorRootCoreBoneId;
-  for (iteratorRootCoreBoneId = pCoreSkeleton->getListRootCoreBoneId().begin()
-    ; iteratorRootCoreBoneId != pCoreSkeleton->getListRootCoreBoneId().end()
-    ; ++iteratorRootCoreBoneId)
+  std::vector<int>& rootCoreBones = 
+    pCoreSkeleton->getVectorRootCoreBoneId();
+  std::vector<int>::iterator iteratorRootCoreBoneId;
+  for (iteratorRootCoreBoneId = rootCoreBones.begin();
+       iteratorRootCoreBoneId != rootCoreBones.end();
+       ++iteratorRootCoreBoneId)
   {
     CalCoreBone *bone = vectorCoreBone[*iteratorRootCoreBoneId];
     CalQuaternion bonerot = bone->getRotation();
@@ -677,32 +681,25 @@
   {
     CalCoreAnimation *anim = calCoreModel.getCoreAnimation(i);
     if (!anim) continue;
-
-    const uint trackCount = anim->getTrackCount();
-    std::vector<CalTransform> poses = anim->getPoses();
-    const uint frameCount = (uint)poses.size() / trackCount;
-
     // loop through all root core bones
-    std::list<int>::iterator iteratorRootCoreBoneId;
-    for (iteratorRootCoreBoneId = pCoreSkeleton->getListRootCoreBoneId().begin()
-        ; iteratorRootCoreBoneId != pCoreSkeleton->getListRootCoreBoneId().end()
-    ; ++iteratorRootCoreBoneId)
+    for (iteratorRootCoreBoneId = rootCoreBones.begin();
+         iteratorRootCoreBoneId != rootCoreBones.end();
+         ++iteratorRootCoreBoneId)
     {
-      int boneTrack = anim->getTrackAssignment (*iteratorRootCoreBoneId);
-      if (boneTrack < 0) continue;
-      for (uint j = 0; j < frameCount; j++)
+      CalCoreTrack *track = anim->getCoreTrack(*iteratorRootCoreBoneId);
+      if (!track) continue;
+      for (int j=0; j<track->getCoreKeyframeCount(); j++)
       {
-        CalTransform& tf = poses[j * trackCount + boneTrack];
-        CalQuaternion bonerot = tf.getRotation();
-        CalVector bonevec = tf.getTranslation();
-        bonerot *= quatrot;
-        bonevec *= quatrot;
-        bonevec += translation;
-        tf.setRotation (bonerot);
-        tf.setTranslation (bonevec);
+   CalCoreKeyframe *frame = track->getCoreKeyframe(j);
+   CalQuaternion bonerot = frame->getRotation();
+   CalVector bonevec = frame->getTranslation();
+   bonerot *= quatrot;
+   bonevec *= quatrot;
+   bonevec += translation;
+   frame->setRotation(bonerot);
+   frame->setTranslation(bonevec);
       }
     }
-    anim->setPoses (poses, trackCount);
   }
 //  calCoreModel.getCoreSkeleton()->calculateBoundingBoxes(&calCoreModel);
 }