Skip to content

Commit

Permalink
Merge pull request #1894 from zenustech/create_directories
Browse files Browse the repository at this point in the history
CreateFolder
  • Loading branch information
zhxx1987 authored Sep 29, 2024
2 parents e7f9da2 + 74a4dbc commit 24b27af
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
43 changes: 43 additions & 0 deletions zeno/src/nodes/prim/SimpleGeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <glm/vec2.hpp>
#include <glm/vec3.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <filesystem>

#define ROTATE_COMPUTE \
auto gp = glm::vec3(p[0], p[1], p[2]); \
Expand Down Expand Up @@ -1412,5 +1413,47 @@ ZENDEFNODE(CreateCylinder, {
{},
{"create"},
});
struct CreateFolder : zeno::INode {
virtual void apply() override {
namespace fs = std::filesystem;
auto folderPath = fs::u8path(get_input2<std::string>("folderPath"));
if (!fs::exists(folderPath)) {
fs::create_directories(folderPath);
}
}
};

ZENDEFNODE(CreateFolder, {
{
{"directory", "folderPath"}
},
{},
{},
{"create"},
});

struct RemoveFolder : zeno::INode {
virtual void apply() override {
namespace fs = std::filesystem;
auto folderPath = fs::u8path(get_input2<std::string>("folderPath"));
if (fs::exists(folderPath)) {
std::error_code errorCode;
fs::remove_all(folderPath, errorCode);
if (get_input2<bool>("clean")) {
fs::create_directories(folderPath);
}
}
}
};

ZENDEFNODE(RemoveFolder, {
{
{"directory", "folderPath"},
{"bool", "clean", "false"},
},
{},
{},
{"create"},
});
}
}
6 changes: 5 additions & 1 deletion zeno/src/nodes/prim/UVProjectFromPlane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,10 @@ struct WriteImageFile_v2 : INode {
stbi_flip_vertically_on_write(1);
stbi_write_png(path.c_str(), w, h, n, data.data(),0);
}
else if(type == "hdr"){
stbi_flip_vertically_on_write(1);
stbi_write_hdr(path.c_str(), w, h, 3, (float*)image->verts.data());
}
else if(type == "exr"){
std::vector<float> data2(w * h * n);
for (int i = 0; i < w * h; i++) {
Expand Down Expand Up @@ -768,7 +772,7 @@ ZENDEFNODE(WriteImageFile_v2, {
{
{"image"},
{"writepath", "path"},
{"enum png jpg exr pfm", "type", "png"},
{"enum png jpg exr pfm hdr", "type", "png"},
{"mask"},
{"bool", "linear_to_srgb_when_save", "0"},
},
Expand Down

0 comments on commit 24b27af

Please sign in to comment.