|
@ -15,7 +15,9 @@ |
|
|
// WARNING: Use an anonymous namespace when including gif.h to avoid duplicate
|
|
|
// WARNING: Use an anonymous namespace when including gif.h to avoid duplicate
|
|
|
// symbols.
|
|
|
// symbols.
|
|
|
namespace { |
|
|
namespace { |
|
|
|
|
|
|
|
|
#include <gif.h> |
|
|
#include <gif.h> |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#include "SimState.hpp" |
|
|
#include "SimState.hpp" |
|
@ -28,11 +30,15 @@ class UISimState : public igl::opengl::glfw::imgui::ImGuiMenu { |
|
|
|
|
|
|
|
|
public: |
|
|
public: |
|
|
UISimState(); |
|
|
UISimState(); |
|
|
|
|
|
|
|
|
virtual ~UISimState() override {} |
|
|
virtual ~UISimState() override {} |
|
|
|
|
|
|
|
|
enum PlayerState { Playing = 0, Paused, TotalPlayerStatus }; |
|
|
enum PlayerState { |
|
|
|
|
|
Playing = 0, Paused, TotalPlayerStatus |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
virtual void init(igl::opengl::glfw::Viewer *_viewer) override; |
|
|
virtual void init(igl::opengl::glfw::Viewer *_viewer) override; |
|
|
|
|
|
|
|
|
virtual void draw_menu() override; |
|
|
virtual void draw_menu() override; |
|
|
// virtual bool mouse_down(int button, int modifier) override;
|
|
|
// virtual bool mouse_down(int button, int modifier) override;
|
|
|
// virtual bool key_pressed(unsigned int key, int modifiers) override;
|
|
|
// virtual bool key_pressed(unsigned int key, int modifiers) override;
|
|
@ -41,59 +47,59 @@ public: |
|
|
get_data(const std::string &data) const; |
|
|
get_data(const std::string &data) const; |
|
|
|
|
|
|
|
|
virtual void launch(const std::string &inital_scene); |
|
|
virtual void launch(const std::string &inital_scene); |
|
|
|
|
|
|
|
|
virtual void load_scene(); |
|
|
virtual void load_scene(); |
|
|
|
|
|
|
|
|
virtual void redraw_scene(); |
|
|
virtual void redraw_scene(); |
|
|
|
|
|
|
|
|
virtual bool pre_draw_loop(); |
|
|
virtual bool pre_draw_loop(); |
|
|
|
|
|
|
|
|
virtual bool post_draw_loop(); |
|
|
virtual bool post_draw_loop(); |
|
|
|
|
|
|
|
|
bool custom_key_pressed(unsigned int unicode_key, int modifiers); |
|
|
bool custom_key_pressed(unsigned int unicode_key, int modifiers); |
|
|
|
|
|
|
|
|
bool load(std::string scene_filename) override |
|
|
bool load(std::string scene_filename) override { |
|
|
{ |
|
|
|
|
|
if (scene_filename != "" && m_state.load_scene(scene_filename)) { |
|
|
if (scene_filename != "" && m_state.load_scene(scene_filename)) { |
|
|
load_scene(); |
|
|
load_scene(); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
bool save(std::string scene_filename) override |
|
|
|
|
|
{ |
|
|
bool save(std::string scene_filename) override { |
|
|
return m_state.save_simulation(scene_filename); |
|
|
return m_state.save_simulation(scene_filename); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bool save_obj_sequence(const std::string& dir_name) |
|
|
bool save_obj_sequence(const std::string &dir_name) { |
|
|
{ |
|
|
|
|
|
bool success = m_state.save_obj_sequence(dir_name); |
|
|
bool success = m_state.save_obj_sequence(dir_name); |
|
|
m_state.problem_ptr->state( |
|
|
m_state.problem_ptr->state( |
|
|
m_state.state_sequence[m_state.m_num_simulation_steps]); |
|
|
m_state.state_sequence[m_state.m_num_simulation_steps]); |
|
|
return success; |
|
|
return success; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bool save_gltf(const std::string& filename) |
|
|
bool save_gltf(const std::string &filename) { |
|
|
{ |
|
|
|
|
|
return m_state.save_gltf(filename); |
|
|
return m_state.save_gltf(filename); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void get_window_dimensions(int& width, int& height) const |
|
|
void get_window_dimensions(int &width, int &height) const { |
|
|
{ |
|
|
|
|
|
width = m_viewer.core().viewport[2] - m_viewer.core().viewport[0]; |
|
|
width = m_viewer.core().viewport[2] - m_viewer.core().viewport[0]; |
|
|
height = m_viewer.core().viewport[3] - m_viewer.core().viewport[1]; |
|
|
height = m_viewer.core().viewport[3] - m_viewer.core().viewport[1]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void save_screenshot(const std::string &filename); |
|
|
void save_screenshot(const std::string &filename); |
|
|
|
|
|
|
|
|
void start_recording(const std::string &filename); |
|
|
void start_recording(const std::string &filename); |
|
|
|
|
|
|
|
|
void end_recording(); |
|
|
void end_recording(); |
|
|
|
|
|
|
|
|
void reload() |
|
|
void reload() { |
|
|
{ |
|
|
|
|
|
m_reloading_scene = true; |
|
|
m_reloading_scene = true; |
|
|
m_state.reload_scene(); |
|
|
m_state.reload_scene(); |
|
|
load_scene(); |
|
|
load_scene(); |
|
|
m_reloading_scene = false; |
|
|
m_reloading_scene = false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void simulation_step() |
|
|
void simulation_step() { |
|
|
{ |
|
|
|
|
|
igl::Timer timer; |
|
|
igl::Timer timer; |
|
|
timer.start(); |
|
|
timer.start(); |
|
|
m_state.simulation_step(); |
|
|
m_state.simulation_step(); |
|
@ -103,8 +109,7 @@ public: |
|
|
redraw_scene(); |
|
|
redraw_scene(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void log_simulation_time() |
|
|
void log_simulation_time() { |
|
|
{ |
|
|
|
|
|
spdlog::info("total_simulation_time={:g}s", m_simulation_time); |
|
|
spdlog::info("total_simulation_time={:g}s", m_simulation_time); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -121,10 +126,13 @@ public: |
|
|
bool m_show_vertex_data; |
|
|
bool m_show_vertex_data; |
|
|
|
|
|
|
|
|
protected: |
|
|
protected: |
|
|
void draw_io(); |
|
|
virtual void draw_io(); |
|
|
void draw_simulation_player(); |
|
|
|
|
|
void draw_settings(); |
|
|
virtual void draw_simulation_player(); |
|
|
void draw_legends(); |
|
|
|
|
|
|
|
|
virtual void draw_settings(); |
|
|
|
|
|
|
|
|
|
|
|
virtual void draw_legends(); |
|
|
|
|
|
|
|
|
private: |
|
|
private: |
|
|
std::shared_ptr<igl::opengl::MeshData> mesh_data; |
|
|
std::shared_ptr<igl::opengl::MeshData> mesh_data; |
|
|