| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -40,10 +40,11 @@ namespace ipc::rigid { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//                CCD_IM_ARRAYSIZE(level_strings))) {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            set_logger_level(static_cast<spdlog::level::level_enum>(log_level));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            set_logger_level(spdlog::level::level_enum::off); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            set_logger_level(spdlog::level::level_enum::off);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            draw_io(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            draw_legends(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (m_has_scene) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                if (ImGui::CollapsingHeader( | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -68,15 +69,8 @@ namespace ipc::rigid { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            ImGui::SetNextWindowSizeConstraints( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    ImVec2(200.0f, 30.0f), ImVec2(legends_width, -1.0f)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            bool _colors_menu_visible = true; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            // TODO: only add edge
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            // ImGui::Begin(
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //     "Legend", &_colors_menu_visible,
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //     ImGuiWindowFlags_NoSavedSettings
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //         | ImGuiWindowFlags_AlwaysAutoResize);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            // {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //     draw_legends();
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            // }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            // ImGui::End();
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } // namespace ipc::rigid
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -103,10 +97,7 @@ namespace ipc::rigid { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            ImGui::EndChild(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (ImGui::Button("Save simulation", ImVec2(-1, 0))) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                std::string fname = igl::file_dialog_save(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                save(fname); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            // if (ImGui::Button("Save OBJ sequence", ImVec2(-1, 0))) {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //     std::string dir_name = igl::file_dialog_save();
 | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -122,7 +113,7 @@ namespace ipc::rigid { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //     }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            // }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (ImGui::Button("Start recording", ImVec2(-1, 0))) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (ImGui::Button("记录gif", ImVec2(-1, 0))) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                std::string fname = igl::file_dialog_save(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                start_recording(fname); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -145,7 +136,7 @@ namespace ipc::rigid { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        m_player_state = static_cast<PlayerState>(player_state); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if (ImGui::Button("Step##SimPlayer", ImVec2(-1, 0))) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if (ImGui::Button("逐步仿真##SimPlayer", ImVec2(-1, 0))) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            m_player_state = PlayerState::Playing; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            pre_draw_loop(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            m_player_state = PlayerState::Paused; | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -161,13 +152,56 @@ namespace ipc::rigid { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    void UISimState::draw_settings() { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        auto config = m_state.get_active_config(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        ImGui::BeginChild( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                "##config", ImVec2(ImGui::GetWindowContentRegionWidth(), 300), false, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        static auto get_display_json = [&](const nlohmann::json &cur_state) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            nlohmann::json display_json = { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    {"总模型", {{"角动量", cur_state["angular_momentum"]}, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                                {"线动量", cur_state["linear_momentum"]}, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                                {"动能", cur_state["kinetic_energy"]}, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                                {"势能", cur_state["potential_energy"]},} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            }; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            auto v_rigid_bodies = cur_state["rigid_bodies"]; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            for (int i = 0; i < v_rigid_bodies.size(); ++i) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                char str_i[10]; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                sprintf(str_i, "刚体%3d", i + 1); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                display_json["子模型"][str_i] = { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        {"角速度", v_rigid_bodies[i]["angular_velocity"]}, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        {"线速度", v_rigid_bodies[i]["linear_velocity"]}, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        {"位置",   v_rigid_bodies[i]["position"]}, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        {"旋转角", v_rigid_bodies[i]["rotation"]}, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                }; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            display_json["时间步"]= m_state.problem_ptr->timestep(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            return display_json; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            // Eigen::Vector3d angular_momentum(current_state[" angular_momentum"][0], current_state[" angular_momentum"][1], current_state[" angular_momentum"][2]);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            // angular_momentum
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            // kinetic_energy
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            // linear_momentum
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            // potential_energy
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            // for () // rigid_bodies
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //      angular_velocity
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //      linear_velocity
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //      position
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //      rotation
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        }; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        ImGui::BeginChild("##config", ImVec2(ImGui::GetWindowContentRegionWidth(), 300), false, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                          ImGuiWindowFlags_HorizontalScrollbar); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            ImGui::TreeNodeJson(config); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//            ImGui::TreeNodeJson(config);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            assert(!m_state.state_sequence.empty()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            auto cur_state = m_state.state_sequence.back(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            auto disp_state = get_display_json(cur_state); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            ImGui::TreeNodeJson(disp_state); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if (ImGui::Button("导出仿真结果", ImVec2(-1, 0))) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            std::string fname = igl::file_dialog_save(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            save(fname); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        ImGui::EndChild(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    void UISimState::draw_legends() { | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -180,18 +214,19 @@ namespace ipc::rigid { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            /// visibility checkbox
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            bool tmp = ptr->visibility(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (!ptr->is_com()) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                if (ImGui::Checkbox(("##UI-" + label).c_str(), &tmp)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                if (ImGui::Checkbox(("网格可视化##UI-" + label).c_str(), &tmp)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    ptr->visibility(tmp); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                /// Color
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                ImGui::SameLine(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                if (ImGui::DoubleColorEdit3( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        (label + "##UI-color").c_str(), ptr->m_color)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    ptr->recolor(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//                /// Color
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//                ImGui::SameLine();
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//                if (ImGui::DoubleColorEdit3(
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//                        (label + "##UI-color").c_str(), ptr->m_color)) {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//                    ptr->recolor();
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//                }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } else if (ImGui::Checkbox((label + "##UI-check").c_str(), &tmp)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                ptr->visibility(tmp); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            break; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |