TerraForge3D  2.3.1
3D Terrain And Landscape Generator

◆ Load()

void TextureNode::Load ( nlohmann::json  data)
virtual

Implements NodeEditorNode.

Definition at line 113 of file TextureNode.cpp.

114{
115 scale = data["scale"];
116
117 if (isDefault && data["isDefault"])
118 {
119 return;
120 }
121
122 isDefault = data["isDefault"];
123 npScale = data["npsc"];
124 inv = data["inv"];
125 autoTiled = data["autoTiled"];
126 numTiles = data["numTiles"];
127 posi[0] = data["posiX"];
128 posi[1] = data["posiY"];
129 rota = data["rota"];
130
131 if (isDefault)
132 {
133 delete texture;
134 texture = new Texture2D(GetExecutableDir() + PATH_SEPARATOR "Data" PATH_SEPARATOR "textures" PATH_SEPARATOR "white.png", false, false);
135 }
136
137 else
138 {
139 std::string hash = data["texture"];
140
141 if (!ProjectManager::Get()->AssetExists(hash))
142 {
143 ShowMessageBox("Failed to Load Texture : " + hash, "Error");
144 isDefault = true;
145 }
146
147 else
148 {
149 delete texture;
150 texture = new Texture2D(ProjectManager::Get()->GetResourcePath() + PATH_SEPARATOR + ProjectManager::Get()->GetAsset(hash));
151 Log("Loaded Cached Texture : " + hash);
152 }
153 }
154
155 // TODO : Load Image
156}
std::size_t hash(const BasicJsonType &j)
hash a JSON value
Definition: json.hpp:5240