1#include "Generators/CPUNodeEditor/Nodes/CurveNode.h"
2#include "Base/ImGuiShapes.h"
3#include "Generators/CPUNodeEditor/CPUNodeEditor.h"
7#include "Base/ImGuiCurveEditor.h"
12static void ReserveVector(std::vector<t> &vec,
int amount)
14 int size = vec.size();
16 for (
int i = size; i <= amount; i++)
22static const char *axises[3] = {
"X",
"Y",
"Z"};
56 return NodeOutput({ ImGui::CurveValueSmooth((axisVal/axisMax), maxPoints, curve.data()) });
61 maxPoints = data[
"maxPoints"];
62 ReserveVector(curve, (maxPoints > data[
"curveSize"].get<int>() ? maxPoints : data[
"curveSize"].get<int>()));
66 curve[tmp[
"index"]] = ImVec2(tmp[
"x"], tmp[
"y"]);
76 data[
"type"] = MeshNodeEditor::MeshNodeType::Curve;
79 for (ImVec2 point : curve)
89 data[
"curveSize"] = curve.
size();
90 data[
"maxPoints"] = maxPoints;
95void CurveNode::OnRender()
97 DrawHeader(
"Curve Editor");
98 ImGui::Dummy(ImVec2(150, 10));
101 outputPins[0]->Render();
102 ImGui::Text(
"Max Points");
103 ImGui::PushItemWidth(100);
105 if (ImGui::DragInt((
"##dI" + std::to_string(
id)).c_str(), &maxPoints, 1, 10, 256))
107 ReserveVector(curve, maxPoints);
110 ImGui::PopItemWidth();
113 if (ImGui::Curve((
"##" + std::to_string(
id)).c_str(), ImVec2(200, 200), maxPoints, curve.data()))
117 ImGui::Text(
"Current Axis: ");
119 ImGui::Text(axises[axis]);
121 if (ImGui::Button((
"Change Axis##" + std::to_string(
id)).c_str()))
132CurveNode::CurveNode()
134 outputPins.push_back(
new NodeEditorPin(NodeEditorPinType::Output));
135 headerColor = ImColor(OP_NODE_COLOR);
137 ReserveVector(curve, maxPoints);
size_type size() const noexcept
returns the number of elements
void push_back(basic_json &&val)
add an object to an array
a class to store JSON values