TerraForge3D  2.3.1
3D Terrain And Landscape Generator
OutputNode.cpp
1#include "Generators/CPUNodeEditor/Nodes/OutputNode.h"
2#include "Generators/CPUNodeEditor/CPUNodeEditor.h"
3
4#include <iostream>
5
6NodeOutput OutputNode::Evaluate(NodeInputParam input, NodeEditorPin *pin)
7{
8 if (inputPins[0]->IsLinked())
9 return NodeOutput({ inputPins[0]->other->Evaluate(input)});
10 return NodeOutput({value});
11}
12
13void OutputNode::Load(nlohmann::json data)
14{
15 value = data["value"];
16}
17
18nlohmann::json OutputNode::Save()
19{
20 nlohmann::json data;
21 data["value"] = value;
22 data["type"] = MeshNodeEditor::MeshNodeType::Output;
23 return data;
24}
25
26void OutputNode::OnRender()
27{
28 DrawHeader("Output");
29 inputPins[0]->Render();
30
31 if (!inputPins[0]->IsLinked())
32 {
33 ImGui::PushItemWidth(100);
34 ImGui::DragFloat(("##" + std::to_string(inputPins[0]->id)).c_str(), &value, 0.01f);
35 ImGui::PopItemWidth();
36 }
37
38 else
39 {
40 ImGui::Dummy(ImVec2(100, 40));
41 }
42}
43
44OutputNode::OutputNode()
45{
46 name = "Output";
47 value = 0;
48 headerColor = ImColor(OUTPUT_NODE_COLOR);
49 inputPins.push_back(new NodeEditorPin());
50 outputPins.push_back(new NodeEditorPin(NodeEditorPinType::Output));
51}
a class to store JSON values
Definition: json.hpp:17860