diff options
author | KT <tran0563@umn.edu> | 2021-10-19 14:03:28 -0500 |
---|---|---|
committer | KT <tran0563@umn.edu> | 2021-10-19 14:03:28 -0500 |
commit | 12b0b74d43b7d93eee82ae6fa3dced499cd8a1f6 (patch) | |
tree | 8e89330e51de3aa45ad3fafc57dc14eb5e1786e2 /dev/a4-dance/motion_clip.h | |
parent | Publish a3 (diff) | |
download | csci4611-12b0b74d43b7d93eee82ae6fa3dced499cd8a1f6.tar csci4611-12b0b74d43b7d93eee82ae6fa3dced499cd8a1f6.tar.gz csci4611-12b0b74d43b7d93eee82ae6fa3dced499cd8a1f6.tar.bz2 csci4611-12b0b74d43b7d93eee82ae6fa3dced499cd8a1f6.tar.lz csci4611-12b0b74d43b7d93eee82ae6fa3dced499cd8a1f6.tar.xz csci4611-12b0b74d43b7d93eee82ae6fa3dced499cd8a1f6.tar.zst csci4611-12b0b74d43b7d93eee82ae6fa3dced499cd8a1f6.zip |
Publish a4
Diffstat (limited to 'dev/a4-dance/motion_clip.h')
-rw-r--r-- | dev/a4-dance/motion_clip.h | 79 |
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 |