| 60 | } |
| 61 | |
| 62 | void MeshData::onGUI(const std::string & name) |
| 63 | { |
| 64 | // rendering mode |
| 65 | static const std::string renderModeStrs[3] = { "Points", "Lines", "Fill" }; |
| 66 | |
| 67 | if (ImGui::BeginCombo(("##render_mode_" + name).c_str(), renderModeStrs[(int)renderMode].data())) { |
| 68 | for (int t = (int)meshType; t >= 0; --t) { |
| 69 | if (ImGui::Selectable(renderModeStrs[t].data(), t == (int)renderMode)) { |
| 70 | renderMode = (Mesh::RenderMode)t; |
| 71 | } |
| 72 | } |
| 73 | ImGui::EndCombo(); |
| 74 | } |
| 75 | ImGui::NextColumn(); |
| 76 | |
| 77 | //alpha |
| 78 | ImGui::SliderFloat(("##alpha_" + name).c_str(), &alpha, 0, 1); |
| 79 | ImGui::NextColumn(); |
| 80 | |
| 81 | //user color |
| 82 | static const std::string colorModeStrs[2] = { "User-defined", "Vertex" }; |
| 83 | if (ImGui::BeginCombo(("##color_mode_" + name).c_str(), colorModeStrs[(int)colorMode].data())) { |
| 84 | if (meshPtr && meshPtr->hasColors()) { |
| 85 | if (ImGui::Selectable(colorModeStrs[VERTEX].data(), colorMode == VERTEX)) { |
| 86 | colorMode = VERTEX; |
| 87 | } |
| 88 | } |
| 89 | if (ImGui::Selectable(colorModeStrs[USER_DEFINED].data(), colorMode == USER_DEFINED)) { |
| 90 | colorMode = USER_DEFINED; |
| 91 | } |
| 92 | ImGui::EndCombo(); |
| 93 | } |
| 94 | if (colorMode == USER_DEFINED) { |
| 95 | ImGui::SameLine(); |
| 96 | ImGui::ColorEdit3(("##color_picker_" + name).c_str(), &userColor[0], ImGuiColorEditFlags_NoInputs); |
| 97 | } |
| 98 | ImGui::NextColumn(); |
| 99 | |
| 100 | //rendering options |
| 101 | if (ImGui::ArrowButton(("##OptionsArrow" + name).c_str(), ImGuiDir_Down)) { |
| 102 | ImGui::OpenPopup(("##Options_popup_" + name).c_str()); |
| 103 | } |
| 104 | if (ImGui::BeginPopup(("##Options_popup_" + name).c_str())) { |
| 105 | ImGui::Checkbox(("Depth Test##" + name).c_str(), &depthTest); |
| 106 | if (meshType == TRIANGLES) { |
| 107 | ImGui::Checkbox(("Cull faces##" + name).c_str(), &backFaceCulling); |
| 108 | ImGui::Checkbox(("Swap back/front##" + name).c_str(), &frontFaceCulling); |
| 109 | } |
| 110 | if (renderMode == Mesh::PointRenderMode) { |
| 111 | ImGui::PushItemWidth(75); |
| 112 | ImGui::SliderInt(("PointSize##" + name).c_str(), &radius, 1, 50); |
| 113 | ImGui::PopItemWidth(); |
| 114 | } |
| 115 | if (meshType == TRIANGLES) { |
| 116 | ImGui::Separator(); |
| 117 | ImGui::Checkbox(("ShowNormals##" + name).c_str(), &showNormals); |
| 118 | if (showNormals) { |
| 119 | static const std::string normalModeStrs[2] = { "Per-triangle", "Per-vertex"}; |
no test coverage detected