add timeline for anime loader
This commit is contained in:
@@ -6,15 +6,6 @@
|
||||
|
||||
namespace basalt::shared::anime_loader {
|
||||
|
||||
//struct KeyFrame {
|
||||
// math::Index frame_index;
|
||||
// math::Matrix4x4 transform;
|
||||
//};
|
||||
|
||||
//struct KeyFrameCompare {
|
||||
// bool operator()(const KeyFrame& lhs, const KeyFrame& rhs) const { return lhs.time < rhs.time; }
|
||||
//};
|
||||
|
||||
struct KeyFrame {
|
||||
math::Vector3 position;
|
||||
math::Quaternion rotation;
|
||||
@@ -29,6 +20,21 @@ namespace basalt::shared::anime_loader {
|
||||
math::Quaternion next_rotation; ///< 后一帧的摄像机旋转。
|
||||
};
|
||||
|
||||
class Timeline {
|
||||
public:
|
||||
Timeline();
|
||||
~Timeline();
|
||||
|
||||
public:
|
||||
void add_key_frame(math::Index frame_index, KeyFrame frame_data);
|
||||
math::Index max_frame() const;
|
||||
KeyFrameSpan tick(math::Index frame_index) const;
|
||||
|
||||
private:
|
||||
math::Index max_frame_cache;
|
||||
std::map<math::Index, KeyFrame> keyframes;
|
||||
};
|
||||
|
||||
struct AnimeLoaderConfig {
|
||||
char_types::BSString filename; ///< The file to be loaded by loader.
|
||||
};
|
||||
@@ -53,8 +59,8 @@ namespace basalt::shared::anime_loader {
|
||||
/**
|
||||
* @brief
|
||||
* @remarks
|
||||
* \li 重写时只允许往frames里插入数据。
|
||||
* \li 重写时务必保证frames里插入的数据大于2个,且初始节点的Key总是0。动画帧个数必须大于4。
|
||||
* \li 重写时只允许往timeline里插入数据。
|
||||
* \li 重写时务必保证timeline里插入的数据大于2个,且初始节点的Key总是0。动画帧个数必须大于4。
|
||||
*/
|
||||
virtual void load(AnimeLoaderConfig&& config);
|
||||
KeyFrameSpan tick();
|
||||
@@ -63,7 +69,7 @@ namespace basalt::shared::anime_loader {
|
||||
AnimeLoaderStatus status;
|
||||
AnimeLoaderConfig config;
|
||||
math::Index time;
|
||||
std::map<math::Index, KeyFrame> frames;
|
||||
Timeline timeline;
|
||||
};
|
||||
|
||||
} // namespace basalt::shared::anime_loader
|
||||
|
||||
Reference in New Issue
Block a user