Some more improvements of editor persistence.
parent
3d387a5dad
commit
bf3189ff49
|
@ -101,7 +101,12 @@ void SkinnedMesh::CalcModelMatrices() {
|
||||||
void SkinnedMesh::DrawSkeleton() {}
|
void SkinnedMesh::DrawSkeleton() {}
|
||||||
|
|
||||||
void SkinnedMesh::DrawDebugUi() {
|
void SkinnedMesh::DrawDebugUi() {
|
||||||
ImGui::Begin("SkinnedMesh");
|
if (ImGui::TreeNode("Bones")) {
|
||||||
|
for (int i = 0; i < m_skeleton.num_joints(); i++) {
|
||||||
|
ImGui::Text(m_skeleton.joint_names()[i]);
|
||||||
|
}
|
||||||
|
ImGui::TreePop();
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::Text("Animations");
|
ImGui::Text("Animations");
|
||||||
|
|
||||||
|
@ -132,6 +137,4 @@ void SkinnedMesh::DrawDebugUi() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::End();
|
|
||||||
}
|
}
|
52
src/main.cc
52
src/main.cc
|
@ -115,13 +115,18 @@ struct ApplicationConfig {
|
||||||
int position[2] = {20, 20};
|
int position[2] = {20, 20};
|
||||||
int size[2] = {800, 500};
|
int size[2] = {800, 500};
|
||||||
};
|
};
|
||||||
|
|
||||||
GraphEditor graph_editor;
|
GraphEditor graph_editor;
|
||||||
|
|
||||||
|
struct SkinnedMeshWidget {
|
||||||
|
bool visible = false;
|
||||||
|
int position[2] = {20, 20};
|
||||||
|
int size[2] = {800, 500};
|
||||||
|
};
|
||||||
|
SkinnedMeshWidget skinned_mesh_widget;
|
||||||
|
|
||||||
bool show_imgui_demo_window = false;
|
bool show_imgui_demo_window = false;
|
||||||
bool show_another_window = false;
|
bool show_another_window = false;
|
||||||
bool show_camera_widget = false;
|
bool show_camera_widget = false;
|
||||||
bool show_skinned_mesh_widget = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void to_json(nlohmann::json& j, const ApplicationConfig& config) {
|
void to_json(nlohmann::json& j, const ApplicationConfig& config) {
|
||||||
|
@ -140,7 +145,12 @@ void to_json(nlohmann::json& j, const ApplicationConfig& config) {
|
||||||
j["graph_editor"]["size"][0] = config.graph_editor.size[0];
|
j["graph_editor"]["size"][0] = config.graph_editor.size[0];
|
||||||
j["graph_editor"]["size"][1] = config.graph_editor.size[1];
|
j["graph_editor"]["size"][1] = config.graph_editor.size[1];
|
||||||
|
|
||||||
j["skinned_mesh_widget"]["visible"] = config.show_skinned_mesh_widget;
|
j["skinned_mesh_widget"]["visible"] = config.skinned_mesh_widget.visible;
|
||||||
|
j["skinned_mesh_widget"]["position"][0] = config.skinned_mesh_widget.position[0];
|
||||||
|
j["skinned_mesh_widget"]["position"][1] = config.skinned_mesh_widget.position[1];
|
||||||
|
j["skinned_mesh_widget"]["size"][0] = config.skinned_mesh_widget.size[0];
|
||||||
|
j["skinned_mesh_widget"]["size"][1] = config.skinned_mesh_widget.size[1];
|
||||||
|
|
||||||
j["camera_widget"]["visible"] = config.show_camera_widget;
|
j["camera_widget"]["visible"] = config.show_camera_widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,8 +187,21 @@ void from_json(const nlohmann::json& j, ApplicationConfig& config) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (j.contains("skinned_mesh_widget") and j["skinned_mesh_widget"].contains("visible")) {
|
|
||||||
config.show_skinned_mesh_widget = j["skinned_mesh_widget"]["visible"];
|
if (j.contains("skinned_mesh_widget")) {
|
||||||
|
if (j["skinned_mesh_widget"].contains("visible")) {
|
||||||
|
config.skinned_mesh_widget.visible = j["skinned_mesh_widget"]["visible"];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (j["skinned_mesh_widget"].contains("position") and j["skinned_mesh_widget"]["position"].size() == 2) {
|
||||||
|
config.skinned_mesh_widget.position[0] = j["skinned_mesh_widget"]["position"].at(0);
|
||||||
|
config.skinned_mesh_widget.position[1] = j["skinned_mesh_widget"]["position"].at(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (j["skinned_mesh_widget"].contains("size") and j["skinned_mesh_widget"]["size"].size() == 2) {
|
||||||
|
config.skinned_mesh_widget.size[0] = j["skinned_mesh_widget"]["size"].at(0);
|
||||||
|
config.skinned_mesh_widget.size[1] = j["skinned_mesh_widget"]["size"].at(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (j.contains("camera_widget") and j["camera_widget"].contains("visible")) {
|
if (j.contains("camera_widget") and j["camera_widget"].contains("visible")) {
|
||||||
|
@ -592,7 +615,7 @@ int main() {
|
||||||
&gApplicationConfig.show_camera_widget);
|
&gApplicationConfig.show_camera_widget);
|
||||||
ImGui::Checkbox(
|
ImGui::Checkbox(
|
||||||
"Skinned Mesh",
|
"Skinned Mesh",
|
||||||
&gApplicationConfig.show_skinned_mesh_widget);
|
&gApplicationConfig.skinned_mesh_widget.visible);
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
ImGui::Checkbox(
|
ImGui::Checkbox(
|
||||||
"ImGui Demo",
|
"ImGui Demo",
|
||||||
|
@ -624,8 +647,23 @@ int main() {
|
||||||
|
|
||||||
draw_grid();
|
draw_grid();
|
||||||
|
|
||||||
if (gApplicationConfig.show_skinned_mesh_widget) {
|
if (gApplicationConfig.skinned_mesh_widget.visible) {
|
||||||
|
ImGui::SetNextWindowPos(ImVec2(gApplicationConfig.skinned_mesh_widget.position[0], gApplicationConfig.skinned_mesh_widget.position[1]), ImGuiCond_FirstUseEver);
|
||||||
|
ImGui::SetNextWindowSize(ImVec2(gApplicationConfig.skinned_mesh_widget.size[0], gApplicationConfig.skinned_mesh_widget.size[1]), ImGuiCond_FirstUseEver);
|
||||||
|
|
||||||
|
ImGui::Begin("SkinnedMesh", &gApplicationConfig.skinned_mesh_widget.visible);
|
||||||
|
|
||||||
|
ImVec2 skinned_mesh_widget_position = ImGui::GetWindowPos();
|
||||||
|
gApplicationConfig.skinned_mesh_widget.position[0] = skinned_mesh_widget_position.x;
|
||||||
|
gApplicationConfig.skinned_mesh_widget.position[1] = skinned_mesh_widget_position.y;
|
||||||
|
|
||||||
|
ImVec2 skinned_mesh_widget_size = ImGui::GetWindowSize();
|
||||||
|
gApplicationConfig.skinned_mesh_widget.size[0] = skinned_mesh_widget_size.x;
|
||||||
|
gApplicationConfig.skinned_mesh_widget.size[1] = skinned_mesh_widget_size.y;
|
||||||
|
|
||||||
skinned_mesh.DrawDebugUi();
|
skinned_mesh.DrawDebugUi();
|
||||||
|
|
||||||
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: add AnimGraph to calculate pose
|
// TODO: add AnimGraph to calculate pose
|
||||||
|
|
Loading…
Reference in New Issue