1#include "Generators/CPUNodeEditor/Nodes/PixelateNode.h"
2#include "Base/ImGuiShapes.h"
3#include "Generators/CPUNodeEditor/CPUNodeEditor.h"
7#include "Base/ImGuiCurveEditor.h"
18 float currX = input.x / input.maxX;
19 float currY = input.y / input.maxY;
20 float currZ = input.z / input.maxZ;
21 float boxX = floorf(currX / pixelSize);
22 float boxY = floorf(currY / pixelSize);
23 float boxZ = floorf(currZ / pixelSize);
24 input.x = boxX * pixelSize * input.maxX;
25 input.y = boxY * pixelSize * input.maxY;
26 input.z = boxZ * pixelSize * input.maxZ;
28 if(inputPins[0]->IsLinked())
29 return NodeOutput({ inputPins[0]->other->Evaluate(input).value });
35 pixelSize = data[
"pixelSize"];
41 data[
"type"] = MeshNodeEditor::MeshNodeType::Pixelate;
42 data[
"pixelSize"] = pixelSize;
46void PixelateNode::OnRender()
48 DrawHeader(
"Pixelate Node");
49 inputPins[0]->Render();
51 inputPins[1]->Render();
53 if (inputPins[1]->IsLinked())
55 ImGui::Text(
"Pixel Size");
60 ImGui::PushItemWidth(100);
61 ImGui::DragFloat((
"##" + std::to_string(inputPins[0]->
id)).c_str(), &pixelSize, 0.01f, 0.001f, 1);
62 ImGui::PopItemWidth();
67 outputPins[0]->Render();
68 ImGui::Text(
"Pixelates the input");
71PixelateNode::PixelateNode()
75 outputPins.push_back(
new NodeEditorPin(NodeEditorPinType::Output));
76 headerColor = ImColor(OP_NODE_COLOR);
a class to store JSON values