TerraForge3D  2.3.1
3D Terrain And Landscape Generator
TimeBasedSeedNode.cpp
1#include "Generators/CPUNodeEditor/Nodes/TimeBasedSeedNode.h"
2#include "Generators/CPUNodeEditor/CPUNodeEditor.h"
3
4#include <iostream>
5
6NodeOutput TimeBasedSeedNode::Evaluate(NodeInputParam input, NodeEditorPin *pin)
7{
8 return NodeOutput({(float)val});
9}
10
11void TimeBasedSeedNode::Load(nlohmann::json data)
12{
13 val = data["val"];
14}
15
16nlohmann::json TimeBasedSeedNode::Save()
17{
18 nlohmann::json data;
19 data["type"] = MeshNodeEditor::MeshNodeType::TimeBasedSeed;
20 data["val"] = val;
21 return data;
22}
23
24void TimeBasedSeedNode::OnRender()
25{
26 DrawHeader("Time Based Seed");
27 ImGui::Dummy(ImVec2(200, 10));
28 ImGui::SameLine();
29 ImGui::Text("Time");
30 outputPins[0]->Render();
31 ImGui::NewLine();
32 ImGui::Text("Current Seed : ");
33 ImGui::SameLine();
34 ImGui::PushItemWidth(200);
35 ImGui::InputInt(MAKE_IMGUI_ID(id), &val, 1);
36 ImGui::PopItemWidth();
37 ImGui::NewLine();
38
39 if (ImGui::Button("Regenerate Seed"))
40 {
41 val = time(NULL);
42 }
43}
44
45TimeBasedSeedNode::TimeBasedSeedNode()
46{
47 headerColor = ImColor(VALUE_NODE_COLOR);
48 outputPins.push_back(new NodeEditorPin(NodeEditorPinType::Output));
49 val = 42;
50}
a class to store JSON values
Definition: json.hpp:17860