Вопрос ImGui Menu Animation

Начинающий
Статус
Оффлайн
Регистрация
4 Июн 2022
Сообщения
71
Реакции[?]
10
Поинты[?]
2K
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.
 
Начинающий
Статус
Оффлайн
Регистрация
26 Сен 2022
Сообщения
66
Реакции[?]
9
Поинты[?]
0
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)
 
Начинающий
Статус
Оффлайн
Регистрация
15 Окт 2022
Сообщения
7
Реакции[?]
1
Поинты[?]
0
Outside Menu Void:
float ui_dpi_scale = 0.0f;
Menu Void:
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();
 
Пользователь
Статус
Оффлайн
Регистрация
3 Июл 2019
Сообщения
137
Реакции[?]
77
Поинты[?]
2K
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.
 
ставь чайник, зажигай плиту
Эксперт
Статус
Оффлайн
Регистрация
22 Май 2020
Сообщения
1,444
Реакции[?]
1,092
Поинты[?]
10K
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)
 
Последнее редактирование:
Сверху Снизу