1#include "Generators/CPUNodeEditor/Nodes/HillNode.h"
2#include "Base/ImGuiShapes.h"
3#include "Generators/CPUNodeEditor/CPUNodeEditor.h"
7#include "Base/ImGuiCurveEditor.h"
9#define SQUARE(x) (x) * (x)
10#define MIN(x, y) x > y ? x : y
17 if (inputPins[0]->IsLinked())
19 xC = inputPins[0]->other->Evaluate(input).value;
27 if (inputPins[1]->IsLinked())
29 yC = inputPins[1]->other->Evaluate(input).value;
37 if (inputPins[2]->IsLinked())
39 hC = inputPins[2]->other->Evaluate(input).value;
47 float xN = input.x / input.maxX;
48 float yN = input.z / input.maxZ;
51 float h = 1 - (SQUARE((yN - yC) / radius) + SQUARE((xN - xC) / radius));
52 h *= pow(2.71828, -p * (SQUARE(xN - xC) + SQUARE(yN - yC)));
58 pos[0] = data[
"posX"];
59 pos[1] = data[
"posY"];
60 pos[2] = data[
"posZ"];
61 height = data[
"height"];
62 radius = data[
"radius"];
69 data[
"type"] = MeshNodeEditor::MeshNodeType::Hill;
70 data[
"posX"] = pos[0];
71 data[
"posY"] = pos[1];
72 data[
"posZ"] = pos[2];
73 data[
"height"] = height;
74 data[
"radius"] = radius;
79void HillNode::OnRender()
82 ImGui::Dummy(ImVec2(150, 20));
85 outputPins[0]->Render();
86 ImGui::PushItemWidth(150);
87 ImGui::DragFloat2(MAKE_IMGUI_LABEL(inputPins[0]->
id,
"Position"), pos, 0.01f);
88 ImGui::DragFloat(MAKE_IMGUI_LABEL(inputPins[1]->
id,
"Height"), &height, 0.01f);
89 ImGui::DragFloat(MAKE_IMGUI_LABEL(inputPins[2]->
id,
"Radius"), &radius, 0.01f, 0.00001f);
90 ImGui::DragFloat(MAKE_IMGUI_LABEL(inputPins[3]->
id,
"Plane Factor"), &p, 0.01f, 0.00001f);
91 ImGui::PopItemWidth();
101 outputPins.push_back(
new NodeEditorPin(NodeEditorPinType::Output));
102 headerColor = ImColor(MATH_NODE_COLOR);
103 pos[0] = pos[1] = pos[2] = 0;
a class to store JSON values