Skip to content
Half People edited this page Apr 14, 2024 · 12 revisions

Welcome to the HImGuiAnimation wiki!

Overall, all you need to focus on writing is the CallBack function :)

BaceFunction

Only two main functions need to be used in this library HAnimationSystem::Play HAnimationSystem::updata

1.HAnimationSystem::Play

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)

2.HAnimationSystem::updata

//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);

3.HAnimationSystem::PlayerCallBack::AnimationPlayerCallBack

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
}, ...);

4.HAnimationSystem::AnimationSequence

  • HAnimationSystem::AnimationSequence::information //Structure used to save underlying variables

You can use the function HAnimationSystem::AnimationSequence::getinfo() to read and write

  • HAnimationSystem::AnimationSequence::Stop Exit animation playback

  • HAnimationSystem::AnimationSequence::Pause pause animation

  • HAnimationSystem::AnimationSequence::Play Resume paused animation

  • HAnimationSystem::AnimationSequence::IsPlaying Whether animation is playing

  • HAnimationSystem::AnimationSequence::getinfo Get underlying information (All information can be dynamically adjusted Speed,IsLoop ...) (!Please do not use this adjustment MaxFPS,data,MaxFrame,pos,callback!)

  • HAnimationSystem::AnimationSequence::updata_MaxFPS Please use this to dynamic adjust MaxFPS

5.HAnimationSystem::HValue_Get Convert HValue variables

Essentially the code is just

T& HValue_Get(HValue value)
{
    return *static_cast<T*>(value);
}