Skip to content

Commit 59c19d0

Browse files
committed
Add ExportAsCubemap node
1 parent d8d2ffa commit 59c19d0

File tree

5 files changed

+82
-5
lines changed

5 files changed

+82
-5
lines changed

Hesiod/app/darkstyle.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ R""(
146146
border: 1px solid #5B5B5B;
147147
}
148148
149-
QPushButton,
149+
QPushButton:checked,
150150
QToolButton:checked
151151
{
152152
background-color: #4772b3;
@@ -155,20 +155,20 @@ R""(
155155
outline: none;
156156
}
157157
158-
QPushButton,
158+
QPushButton:hover,
159159
QToolButton:hover
160160
{
161161
background-color: #8B8B8B;
162162
color: #DFE1E2;
163163
}
164164
165-
QPushButton,
165+
QPushButton:pressed,
166166
QToolButton:pressed
167167
{
168168
background-color: #ABABAB;
169169
}
170170
171-
QPushButton,
171+
QPushButton:selected,
172172
QToolButton:selected
173173
{
174174
background: #5B5B5B;

Hesiod/include/hesiod/model/nodes/node_factory.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ DECLARE_NODE(dilation)
105105
DECLARE_NODE(distance_transform)
106106
DECLARE_NODE(erosion)
107107
DECLARE_NODE(expand_shrink)
108+
DECLARE_NODE(export_as_cubemap)
108109
DECLARE_NODE(export_asset)
109110
DECLARE_NODE(export_cloud)
110111
DECLARE_NODE(export_heightmap)

Hesiod/src/model/nodes/node_factory.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ std::map<std::string, std::string> get_node_inventory()
145145
{"Erosion", "Operator/Morphology"},
146146
{"ExpandShrink", "Filter/Recast"},
147147
{"ExportAsset", "IO/Files"},
148+
{"ExportAsCubemap", "WIP"}, // "IO/Files"},
148149
{"ExportCloud", "IO/Files"},
149150
{"ExportHeightmap", "IO/Files"},
150151
{"ExportNormalMap", "IO/Files"},
@@ -351,6 +352,7 @@ std::shared_ptr<gnode::Node> node_factory(const std::string &node_type
351352
SETUP_NODE(Erosion, erosion);
352353
SETUP_NODE(ExpandShrink, expand_shrink);
353354
SETUP_NODE(ExportAsset, export_asset);
355+
SETUP_NODE(ExportAsCubemap, export_as_cubemap);
354356
SETUP_NODE(ExportCloud, export_cloud);
355357
SETUP_NODE(ExportHeightmap, export_heightmap);
356358
SETUP_NODE(ExportNormalMap, export_normal_map);
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/* Copyright (c) 2023 Otto Link. Distributed under the terms of the GNU General
2+
* Public License. The full license is in the file LICENSE, distributed with
3+
* this software. */
4+
5+
#include "highmap/export.hpp"
6+
7+
#include "attributes.hpp"
8+
9+
#include "hesiod/logger.hpp"
10+
#include "hesiod/model/enum_mapping.hpp"
11+
#include "hesiod/model/nodes/base_node.hpp"
12+
#include "hesiod/model/utils.hpp"
13+
14+
using namespace attr;
15+
16+
namespace hesiod
17+
{
18+
19+
void setup_export_as_cubemap_node(BaseNode *p_node)
20+
{
21+
LOG->trace("setup node {}", p_node->get_label());
22+
23+
// port(s)
24+
p_node->add_port<hmap::Heightmap>(gnode::PortType::IN, "input");
25+
26+
// attribute(s)
27+
ADD_ATTR(FilenameAttribute,
28+
"fname",
29+
std::filesystem::path("cubemap.png"),
30+
"PNG (*.png)",
31+
true);
32+
ADD_ATTR(IntAttribute, "cubemap_resolution", 64, 32, INT_MAX);
33+
ADD_ATTR(FloatAttribute, "overlap", 0.25f, 0.1f, 5.f);
34+
ADD_ATTR(IntAttribute, "ir", 16, 1, INT_MAX);
35+
ADD_ATTR(BoolAttribute, "splitted", false);
36+
ADD_ATTR(BoolAttribute, "auto_export", true);
37+
38+
// attribute(s) order
39+
p_node->set_attr_ordered_key({"fname",
40+
"cubemap_resolution",
41+
"overlap",
42+
"ir",
43+
"splitted",
44+
"_SEPARATOR_",
45+
"auto_export"});
46+
}
47+
48+
void compute_export_as_cubemap_node(BaseNode *p_node)
49+
{
50+
Q_EMIT p_node->compute_started(p_node->get_id());
51+
52+
LOG->trace("computing node {}", p_node->get_label());
53+
54+
hmap::Heightmap *p_in = p_node->get_value_ref<hmap::Heightmap>("input");
55+
56+
if (p_in && GET("auto_export", BoolAttribute))
57+
{
58+
hmap::Array z = p_in->to_array();
59+
std::string fname = GET("fname", FilenameAttribute).string();
60+
61+
hmap::export_as_cubemap(fname,
62+
z,
63+
GET("cubemap_resolution", IntAttribute),
64+
GET("overlap", FloatAttribute),
65+
GET("ir", IntAttribute),
66+
hmap::Cmap::GRAY,
67+
GET("splitted", BoolAttribute),
68+
nullptr);
69+
}
70+
71+
Q_EMIT p_node->compute_finished(p_node->get_id());
72+
}
73+
74+
} // namespace hesiod

0 commit comments

Comments
 (0)