-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔀 Merge remote-tracking branch 'origin/dev/Meshing'
# Conflicts: # Cool # src/App.h # src/Module/Module.h
- Loading branch information
Showing
38 changed files
with
1,031 additions
and
150 deletions.
There are no files selected for viewing
Submodule Cool
updated
29 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include "Command_Meshing.h" | ||
#include "App.h" | ||
|
||
namespace Lab { | ||
|
||
auto Command_Meshing::to_string() const -> std::string | ||
{ | ||
return fmt::format("Convert SDF to Mesh, from node {}", reg::to_string(node_id)); | ||
} | ||
|
||
void Command_Meshing::execute(CommandExecutionContext_Ref const& ctx) const | ||
{ | ||
ctx.app().open_meshing_window_for_node(node_id); | ||
} | ||
|
||
} // namespace Lab | ||
|
||
#include "CommandCore/LAB_REGISTER_COMMAND.h" | ||
LAB_REGISTER_COMMAND(Lab::Command_Meshing) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#pragma once | ||
#include <Cool/Nodes/NodeId.h> | ||
#include "CommandCore/CommandExecutionContext_Ref.h" | ||
|
||
namespace Lab { | ||
|
||
struct Command_Meshing { | ||
Cool::NodeId node_id; | ||
|
||
void execute(CommandExecutionContext_Ref const& ctx) const; | ||
|
||
auto to_string() const -> std::string; | ||
|
||
private: | ||
// Serialization | ||
friend class ser20::access; | ||
template<class Archive> | ||
void serialize(Archive& archive) | ||
{ | ||
archive( | ||
ser20::make_nvp("Node id", node_id) | ||
); | ||
} | ||
}; | ||
|
||
} // namespace Lab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,7 @@ void GalleryPoster::imgui_open_sharing_form(std::optional<Cool::AspectRatio> con | |
|
||
void GalleryPoster::imgui_window(std::function<std::string(img::Size)> const& render_png) | ||
{ | ||
_window.show([&]() { | ||
_window.show([&](bool /*is_opening*/) { | ||
Cool::ImGuiExtras::markdown("Your image will be visible on [Coollab's gallery](https://coollab-art.com/Gallery)."); | ||
Cool::ImGuiExtras::markdown("If you want to edit or remove it, send an email at [[email protected]](mailto:[email protected]) from the email address that you will provide below."); | ||
Cool::ImGuiExtras::separator_text("Artwork"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#include "MeshingGui.hpp" | ||
#include <Cool/ImGui/ImGuiExtras.h> | ||
#include <Cool/Path/Path.h> | ||
#include "Cool/ImGui/IcoMoonCodepoints.h" | ||
#include "Cool/ImGui/icon_fmt.h" | ||
#include "Cool/Mesh/export_mesh.hpp" | ||
#include "Nodes/Node.h" | ||
#include "gen_mesh_from_sdf.hpp" | ||
|
||
namespace Lab { | ||
|
||
MeshingGui::MeshingGui() | ||
: _window{Cool::icon_fmt("Export a 3D Model", ICOMOON_COGS), Cool::ImGuiWindowConfig{.is_modal = true}} | ||
{ | ||
} | ||
|
||
void MeshingGui::open_window(Cool::NodeId const& main_node_id) | ||
{ | ||
_main_node_id = main_node_id; | ||
_window.open(); | ||
} | ||
|
||
static void gen_and_export_mesh(Cool::NodeId const& main_node_id, MeshingSettings const& meshing_settings, Cool::MeshExportSettings const& mesh_export_settings, DataToPassToShader const& data_to_pass_to_shader, DataToGenerateShaderCode const& data_to_generate_shader_code) | ||
{ | ||
// auto const maybe_node = data_to_generate_shader_code.nodes_graph.try_get_node<Node>(main_node_id); | ||
// auto const node_def = data_to_generate_shader_code.get_node_definition(maybe_node->id_names()); | ||
// is_shape_3D(node_def->signature()); | ||
|
||
auto const maybe_mesh = gen_mesh_from_sdf(main_node_id, meshing_settings, data_to_pass_to_shader, data_to_generate_shader_code); | ||
if (!maybe_mesh) | ||
return; // TODO(Meshing) Error message should be handled here | ||
export_mesh(*maybe_mesh, mesh_export_settings); | ||
} | ||
|
||
void MeshingGui::imgui_window(Cool::MeshExportSettings& mesh_export_settings, DataToPassToShader const& data_to_pass_to_shader, DataToGenerateShaderCode const& data_to_generate_shader_code) | ||
{ | ||
_window.show([&](bool is_opening) { | ||
if (is_opening) | ||
mesh_export_settings.set_file_name_to_an_unused_name(); | ||
|
||
_meshing_settings.imgui(); | ||
ImGui::Separator(); | ||
mesh_export_settings.imgui(); | ||
|
||
Cool::ImGuiExtras::before_export_button(mesh_export_settings.path); | ||
if (ImGui::Button(Cool::icon_fmt("Export 3D Model", ICOMOON_UPLOAD2).c_str())) | ||
{ | ||
gen_and_export_mesh(_main_node_id, _meshing_settings, mesh_export_settings, data_to_pass_to_shader, data_to_generate_shader_code); | ||
_window.close(); | ||
} | ||
}); | ||
} | ||
|
||
} // namespace Lab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#pragma once | ||
#include "Cool/ImGui/ImGuiWindow.h" | ||
#include "Cool/Mesh/MeshExportSettings.hpp" | ||
#include "MeshingSettings.hpp" | ||
#include "Module/ShaderBased/DataToGenerateShaderCode.hpp" | ||
#include "Module/ShaderBased/DataToPassToShader.hpp" | ||
|
||
namespace Lab { | ||
|
||
class MeshingGui { | ||
public: | ||
MeshingGui(); | ||
|
||
void open_window(Cool::NodeId const& main_node_id); | ||
void imgui_window(Cool::MeshExportSettings&, DataToPassToShader const&, DataToGenerateShaderCode const&); | ||
|
||
private: | ||
Cool::ImGuiWindow _window; | ||
MeshingSettings _meshing_settings{}; | ||
Cool::NodeId _main_node_id{}; | ||
|
||
private: | ||
// Serialization | ||
friend class ser20::access; | ||
template<class Archive> | ||
void serialize(Archive& archive) | ||
{ | ||
archive( | ||
ser20::make_nvp("Settings", _meshing_settings) | ||
); | ||
} | ||
}; | ||
|
||
} // namespace Lab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include "MeshingSettings.hpp" | ||
#include "Cool/ImGui/ImGuiExtras.h" | ||
|
||
namespace Lab { | ||
|
||
void MeshingSettings::imgui() | ||
{ | ||
// TODO(Meshing) GUI for the other settings | ||
if (ImGui::InputScalarN("Samples Count", ImGuiDataType_U32, glm::value_ptr(samples_count), 3, nullptr, nullptr, "%u")) | ||
{ | ||
// Ensure that the sampling count is at least 1 | ||
samples_count = glm::max(samples_count, glm::uvec3(1)); | ||
} | ||
Cool::ImGuiExtras::help_marker("The number of samples to take along each axis of the volume.\nIncreasing it will increase the precision of the mesh, but will take longer to export and add more vertices."); | ||
} | ||
|
||
} // namespace Lab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#pragma once | ||
|
||
namespace Lab { | ||
|
||
struct MeshingSettings { | ||
glm::vec3 box_size{2.f}; // TODO(Meshing) Clarify : is this the radius or diameter of the box? | ||
glm::uvec3 samples_count{75}; /// Must always be >= 1 on each axis | ||
// TODO(Meshing) expose step_size in the GUI, and deduce samples_count from it | ||
auto step_size() const -> glm::vec3 { return box_size / static_cast<glm::vec3>(samples_count - glm::uvec3{1}); } | ||
|
||
void imgui(); | ||
|
||
private: | ||
// Serialization | ||
friend class ser20::access; | ||
template<class Archive> | ||
void serialize(Archive& archive) | ||
{ | ||
archive( | ||
ser20::make_nvp("Box size", box_size), | ||
ser20::make_nvp("Samples count", samples_count) | ||
); | ||
} | ||
}; | ||
|
||
} // namespace Lab |
Oops, something went wrong.