|
@@ -19,7 +19,7 @@ BoneAnimation::BoneAnimation(
|
|
|
frames = new KeyFrame[1];
|
|
|
frames[0].time = 0.0;
|
|
|
frames[0].pos = originPos;
|
|
|
- frames[9].rot = originRot;
|
|
|
+ frames[0].rot = originRot;
|
|
|
current = frames[0];
|
|
|
}
|
|
|
|
|
@@ -74,6 +74,19 @@ void BoneAnimation::addKeyFrame(double time, Vec3<float> pos, Vec3<float> rot)
|
|
|
frames = tmp;
|
|
|
}
|
|
|
|
|
|
+// adds a keyframe that is the same as the last keyframe with the time time
|
|
|
+// \returns true if the keyframe was added successfully, false if time is maller
|
|
|
+// than the current length of the animation
|
|
|
+bool BoneAnimation::doNothingUntil(double time)
|
|
|
+{
|
|
|
+ if (time > maxTime)
|
|
|
+ {
|
|
|
+ KeyFrame& last = frames[frameCount - 1];
|
|
|
+ addKeyFrame(time, last.pos, last.rot);
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
// calculates the positions and rotation at the next time
|
|
|
// \param time the passed time in seconds since the last call
|
|
|
void BoneAnimation::tick(double time)
|
|
@@ -134,6 +147,12 @@ int BoneAnimation::getBoneId() const
|
|
|
return boneId;
|
|
|
}
|
|
|
|
|
|
+// returns the maximum time of the animation
|
|
|
+double BoneAnimation::getMaxTime() const
|
|
|
+{
|
|
|
+ return maxTime;
|
|
|
+}
|
|
|
+
|
|
|
//! Constructor
|
|
|
SkeletonAnimation::SkeletonAnimation()
|
|
|
: ReferenceCounter(),
|
|
@@ -217,4 +236,25 @@ bool SkeletonAnimation::isFinished() const
|
|
|
if (!animation->isFinished()) return 0;
|
|
|
}
|
|
|
return 1;
|
|
|
+}
|
|
|
+
|
|
|
+// returns the maximum time of the animation
|
|
|
+double SkeletonAnimation::getMaxTime() const
|
|
|
+{
|
|
|
+ double max = 0;
|
|
|
+ for (BoneAnimation* animation : subAnimations)
|
|
|
+ {
|
|
|
+ max = MAX(animation->getMaxTime(), max);
|
|
|
+ }
|
|
|
+ return max;
|
|
|
+}
|
|
|
+
|
|
|
+// returns the animation for a specific bone or 0 if it does not exist
|
|
|
+BoneAnimation* SkeletonAnimation::zAnimation(int boneId) const
|
|
|
+{
|
|
|
+ for (BoneAnimation* animation : subAnimations)
|
|
|
+ {
|
|
|
+ if (animation->getBoneId() == boneId) return animation;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
}
|