Kinematics Animation Multithread
main.cpp
Go to the documentation of this file.
1#include <iostream>
2#include <vector>
3
4#include <igl/opengl/glfw/Viewer.h>
5#include <igl/opengl/glfw/imgui/ImGuiPlugin.h>
6#include <igl/opengl/glfw/imgui/ImGuiMenu.h>
7#include <igl/opengl/glfw/imgui/ImGuiHelpers.h>
8#include <igl/slim.h>
9
15
22int main(void)
23{
24 // Initialize viewer
25 igl::opengl::glfw::Viewer viewer;
26
27 // Attach a menu plugin
28 igl::opengl::glfw::imgui::ImGuiPlugin plugin;
29 viewer.plugins.push_back(&plugin);
30 igl::opengl::glfw::imgui::ImGuiMenu menu;
31 plugin.widgets.push_back(&menu);
32
33 // Menu handler
34 MenuHandler menu_handler(&menu);
35
36 // Generate lamda function pointing to the menu callback
37 auto lamda_menu_fun = [&menu_handler]() { return menu_handler.callback(); };
38 menu.callback_draw_viewer_menu = lamda_menu_fun;
39
40 // Initialize left exoskeleton handle
41 Exoskeleton left_exoskeleton;
42
43 // Initialize animated hand handler
44 AnimatedHand anim_hand;
45
46 // Initialize kinematic animation
48 ka.initialize(&viewer, &left_exoskeleton, &anim_hand, &menu_handler);
49
50 // Generate lamda function pointing to the animation loop member function
51 auto lamda_anim_fun =
52 [&ka](igl::opengl::glfw::Viewer& viewer) { return ka.animation_loop(viewer); };
53
54
55 // Set animation
56 viewer.data().show_overlay_depth = false;
57 viewer.data().line_width = 1;
58 viewer.data().show_lines = false;
59 viewer.callback_pre_draw = lamda_anim_fun;
60 viewer.core().is_animating = true;
61 viewer.core().animation_max_fps = 30;
62 viewer.launch();
63}
Class Exoskeleton.
Definition: exoskeleton.h:20
Class KinematicAnimation.
void initialize(igl::opengl::glfw::Viewer *viewer, Exoskeleton *left_exo, AnimatedHand *anim_hand, MenuHandler *menu_handler)
Initialize animation.
bool animation_loop(igl::opengl::glfw::Viewer &viewer)
Animation loop callback.
Class MenuHandler.
Definition: menu_handler.h:23
void callback(void)
Menu callback function.
int main(void)
This is the main execution function. It first initiates the libigl viewer and then calls the menu han...
Definition: main.cpp:22