Вопрос ImGui Menu Animation

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
4 Июн 2022
Сообщения
73
Реакции
10
So I have been working with imgui lately and was wondering if anyone could give example code for an animation such as aimware v5 when the menu is opened.
It comes from the centre and expands all directions and was wondering how to do a smooth animation like that in imgui.
 
Try using lerp animations, I don't think aimware uses those but it would probably be even better, do like size.x = lerp(size.x, new_size.x, frame_time)
 
Outside Menu Void:
Expand Collapse Copy
float ui_dpi_scale = 0.0f;
Menu Void:
Expand Collapse Copy
ui_dpi_scale = ImLerp(ui_dpi_scale , menu_open ? 1.0f : 0.0f,  0.5f * (12.0f * ImGui::GetIO().DeltaTime));

ImGui::SetNextWindowSize(ImVec2(800 * ui_dpi_scale, 600 * ui_dpi_scale));
ImGui::Begin("MyMenu", nullptr);
   
//your code
   
ImGui::End();
 
making element per element animation, add a check ("if one animation finish, then play another, repetitive till every animation is done") to play the animation progressively from each elements till one finish. voila. aimware animation.
 
It comes from the centre and expands all directions and was wondering how to do a smooth animation like that in imgui.
u just need to setwindowpos to a (center - window_size/2) and setwindowsize(window_size)
for smooth window_size changing u can use ImLerp function
window_size = ImLerp( window_size, opened ? max_window_size : zero_size, ImGui::GetIO().DeltaTime * animation_speed /*10.f for example*/ );

(or u can achieve it with a cliprect, it will be better since menu elements won't be moved during animation)
 
Последнее редактирование:
Назад
Сверху Снизу