summaryrefslogtreecommitdiffstats
path: root/dev/a4-dance/motion_clip.h
diff options
context:
space:
mode:
authorJessie Speert <speer034@umn.edu>2021-03-08 19:09:55 -0800
committerJessie Speert <speer034@umn.edu>2021-03-08 19:09:55 -0800
commitf30fcc505dc3ce2df25dce16b329c90c32049862 (patch)
tree88e51f09844d0df1627643ccc3a1335d5fd74cbf /dev/a4-dance/motion_clip.h
parentAdded Assignment 3 worksheet and code (diff)
downloadcsci4611-f30fcc505dc3ce2df25dce16b329c90c32049862.tar
csci4611-f30fcc505dc3ce2df25dce16b329c90c32049862.tar.gz
csci4611-f30fcc505dc3ce2df25dce16b329c90c32049862.tar.bz2
csci4611-f30fcc505dc3ce2df25dce16b329c90c32049862.tar.lz
csci4611-f30fcc505dc3ce2df25dce16b329c90c32049862.tar.xz
csci4611-f30fcc505dc3ce2df25dce16b329c90c32049862.tar.zst
csci4611-f30fcc505dc3ce2df25dce16b329c90c32049862.zip
Uploading Assignment 4
Diffstat (limited to 'dev/a4-dance/motion_clip.h')
-rw-r--r--dev/a4-dance/motion_clip.h79
1 files changed, 79 insertions, 0 deletions
diff --git a/dev/a4-dance/motion_clip.h b/dev/a4-dance/motion_clip.h
new file mode 100644
index 0000000..d676adc
--- /dev/null
+++ b/dev/a4-dance/motion_clip.h
@@ -0,0 +1,79 @@
+
+#ifndef ANIMATION_CLIP_H_
+#define ANIMATION_CLIP_H_
+
+#include <mingfx.h>
+#include "pose.h"
+#include "skeleton.h"
+
+
+/** A MotionClip is a series of poses that can be applied to an animated character.
+ In addition to storing that list, this class provides some utility functions for
+ editing the clip, including triming unwanted frames from the front or back or
+ prepended or appending additional frames to the clip. You can also make the clip
+ loop smoothly. */
+class MotionClip {
+public:
+ /// Creates an empty clip.
+ MotionClip();
+ virtual ~MotionClip();
+
+ /// Loads a clip from a file in the AMC mocap data format. A reference to
+ /// the skeleton used during the data capture is required in order to know
+ /// the proper bone names and hierarchical arrangement.
+ void LoadFromAMC(const std::string &filename, const Skeleton &skeleton);
+
+ /// Adds a single pose to the beginning of the motion clip, shifting all
+ /// frames later by 1.
+ void PrependPose(const Pose &pose);
+
+ /// Adds a single pose to the end of the motion clip.
+ void AppendPose(const Pose &pose);
+
+ /// Combines this motion clip and another by prepending the other. If you
+ /// wish to smoothly blend (i.e., cross disolve) between the two clips, then
+ /// use a value > 0 for num_blend_frames.
+ void PrependClip(const MotionClip &clip, int num_blend_frames);
+
+ /// Combines this motion clip and another by appending the other. If you
+ /// wish to smoothly blend (i.e., cross disolve) between the two clips, then
+ /// use a value > 0 for num_blend_frames.
+ void AppendClip(const MotionClip &clip, int num_blend_frames);
+
+ /// Turns the motion clip into a continuous loop by blending the last
+ /// num_blend_frames/2 poses with the first num_blend_frames/2 poses.
+ void MakeLoop(int num_blend_frames);
+
+ /// Removes some poses from the front of the motion clip.
+ void TrimFront(int num_frames);
+
+ /// Removes some poses from the end of the motoin clip.
+ void TrimBack(int num_frames);
+
+ /// Runs through the motion clip, frame by frame, and calculates the relative
+ /// translation from one frame to the next, storing the results in each pose.
+ /// This is not needed if the motion clip will only be used for playback in
+ /// an absolute positioning mode, but it is needed for playback in a relative
+ /// positioning mode.
+ void CalcRelativeTranslations();
+
+ /// Returns the length (in number of frames) of the motoin clip.
+ int size() const;
+
+ /// Returns the character's pose for the given frame.
+ Pose pose(int frame_num) const;
+
+ /// Returns the character's pose for the given frame.
+ Pose& pose(int frame_num);
+
+ /// Returns the character's pose for the given frame.
+ Pose operator[](const int frame_num) const;
+
+ /// Returns the character's pose for the given frame.
+ Pose& operator[](const int frame_num);
+
+private:
+ std::vector<Pose> frames_;
+};
+
+#endif