-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
2,670 additions
and
518 deletions.
There are no files selected for viewing
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,53 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
#include <magic_enum.hpp> | ||
|
||
namespace zeno { | ||
|
||
enum struct CurveType { | ||
|
||
QUADRATIC_BSPLINE, | ||
RIBBON_BSPLINE, | ||
CUBIC_BSPLINE, | ||
|
||
LINEAR, | ||
BEZIER, | ||
CATROM | ||
}; | ||
|
||
static unsigned int CurveDegree(zeno::CurveType type) { | ||
|
||
switch( type ) { | ||
case CurveType::LINEAR: | ||
return 1; | ||
|
||
case CurveType::QUADRATIC_BSPLINE: | ||
case CurveType::RIBBON_BSPLINE: | ||
return 2; | ||
|
||
case CurveType::CUBIC_BSPLINE: | ||
case CurveType::BEZIER: | ||
case CurveType::CATROM: | ||
return 3; | ||
} | ||
return 0; | ||
} | ||
|
||
static std::string CurveTypeDefaultString() { | ||
auto name = magic_enum::enum_name(CurveType::CUBIC_BSPLINE); | ||
return std::string(name); | ||
} | ||
|
||
static std::string CurveTypeListString() { | ||
auto list = magic_enum::enum_names<CurveType>(); | ||
|
||
std::string result; | ||
for (auto& ele : list) { | ||
result += " "; | ||
result += ele; | ||
} | ||
return result; | ||
} | ||
|
||
} //zeno |
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,35 @@ | ||
#include <zeno/types/PrimitiveObject.h> | ||
#include <zeno/types/CurveType.h> | ||
#include <zeno/types/UserData.h> | ||
#include <zeno/zeno.h> | ||
|
||
#include "magic_enum.hpp" | ||
|
||
namespace zeno { | ||
|
||
struct AsCurves : zeno::INode { | ||
virtual void apply() override { | ||
|
||
auto prim = get_input2<zeno::PrimitiveObject>("prim"); | ||
|
||
auto typeString = get_input2<std::string>("type:"); | ||
auto typeEnum = magic_enum::enum_cast<CurveType>(typeString).value_or(CurveType::LINEAR); | ||
auto typeIndex = (int)magic_enum::enum_index<CurveType>(typeEnum).value_or(0); | ||
|
||
prim->userData().set2("curve", typeIndex); | ||
set_output("prim", std::move(prim)); | ||
} | ||
}; | ||
|
||
ZENDEFNODE(AsCurves, | ||
{ { | ||
{"prim"}, | ||
}, | ||
{"prim"}, //output | ||
{ | ||
{"enum " + zeno::CurveTypeListString(), "type", zeno::CurveTypeDefaultString() } | ||
}, //prim | ||
{"prim"} | ||
}); | ||
|
||
} // namespace |
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,43 @@ | ||
#include <zeno/types/PrimitiveObject.h> | ||
#include <zeno/types/CurveType.h> | ||
#include <zeno/types/UserData.h> | ||
#include <zeno/zeno.h> | ||
|
||
#include "magic_enum.hpp" | ||
|
||
#include <filesystem> | ||
#include <vector> | ||
|
||
namespace zeno { | ||
|
||
struct CyHair : zeno::INode { | ||
virtual void apply() override { | ||
|
||
auto path = get_input2<std::string>("path"); | ||
bool exist = std::filesystem::exists(path); | ||
bool yup = get_input2<bool>("yup"); | ||
|
||
if (!exist) { | ||
throw std::string("CyHair file doesn't exist"); | ||
} | ||
|
||
auto out = std::make_shared<zeno::PrimitiveObject>(); | ||
out->userData().set2("yup", yup); | ||
out->userData().set2("path", path); | ||
out->userData().set2("cyhair", true); | ||
|
||
set_output("out", std::move(out)); | ||
} | ||
}; | ||
|
||
ZENDEFNODE(CyHair, | ||
{ { | ||
{"readpath", "path"}, | ||
{"bool", "yup", "1"}, | ||
}, | ||
{"out"}, //output | ||
{}, | ||
{"read"} | ||
}); | ||
|
||
} // namespace |
Oops, something went wrong.