-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Half People edited this page Apr 14, 2024
·
12 revisions
Overall, all you need to focus on writing is the CallBack function :)
Only two main functions need to be used in this library
HAnimationSystem::Play
HAnimationSystem::updata
This function has communicated with the bottom layer and will automatically dispatch the queue for you (repeated triggering will ignore your trigger when playback is not completed. Of course, if you want, you can stop playback manually)
//callback (Animation overprocessed.See AnimationPlayerCallBack comments for details)
//MaxFrame (The largest Frame among animations)
//value (The value transferred to the callback)
//out (Animation sequence returns)
//speed (Play speed)
//FPS (Max FPS : Lift (-1) )
//IsLoop (keep looping)
HAnimationSystem::Play(PlayerCallBack::AnimationPlayerCallBack callback, size_t MaxFrame, HValue value = nullptr, HAnimationSystem::AnimationSequence** out = 0, float speed = 5, int FPS = 60, bool IsLoop = false)
//Animation Manager Update (used in main loop)
//delta_time (Please use ImGui to obtain ImGui::GetIO().DeltaTime)
void updata(float delta_time);
//- Animation Manager Update (used in main loop)(Manager FPS limit, Animation sequences will be disabled FPS limit)
//- Recommended Use : void updata(float delta_time);
void updata(float delta_time, int MaxFPS);
This one is the function callback for HAnimationSystem::Play
//example : function callback
void Sequencer(int32_t Frame, HAnimationSystem::HValue value)
{
const std::vector<int> keys = { 0 , 30 , 64 };
const std::vector<float> values = { 80,200,80 };
HAnimationSystem::PlayerCallBack::HInterpolationInfo info = HAnimationSystem::PlayerCallBack::GetInterpolationInfoFromKeys(keys, Frame);
HAnimationSystem::HValue_Get<float>(value) = HAnimationSystem::PlayerCallBack::LinearInterpolation(values[info.PreviousKey], values[info.LastOneKey], info.alpha);//There are many plug-in tools in `HAnimationSystem::PlayerCallBack`. Of course, you can write your own
}
...
static float value;
static HAnimationSystem::AnimationSequence* Sequence; //Introduction to waiting array
HAnimationSystem::Play(Sequencer, ...,&value,&Sequence);
//example : lambda
HAnimationSystem::Play([](int32_t Frame, HAnimationSystem::HValue value)
{
const std::vector<int> keys = { 0 , 30 , 64 };
const std::vector<float> values = { 80,200,80 };
HAnimationSystem::PlayerCallBack::HInterpolationInfo info = HAnimationSystem::PlayerCallBack::GetInterpolationInfoFromKeys(keys, Frame);
HAnimationSystem::HValue_Get<float>(value) = HAnimationSystem::PlayerCallBack::LinearInterpolation(values[info.PreviousKey], values[info.LastOneKey], info.alpha);//There are many plug-in tools in `HAnimationSystem::PlayerCallBack`. Of course, you can write your own
}, ...);
You can use the function HAnimationSystem::AnimationSequence::getinfo()
to read and write
Essentially the code is just
T& HValue_Get(HValue value)
{
return *static_cast<T*>(value);
}