Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

newHeatMap #1451

Merged
merged 1 commit into from
Oct 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions zeno/src/nodes/prim/PrimitiveHeatmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,54 @@ ZENDEFNODE(HeatmapFromImage,
"visualize",
}});

struct HeatmapFromImage2 : zeno::INode {
virtual void apply() override {
auto image = get_input<zeno::PrimitiveObject>("image");
int w = image->userData().get2<int>("w");
auto heatmap = std::make_shared<HeatmapObject>();

auto spos = get_input2<float>("startPos");
auto epos = get_input2<float>("endPos");
int start = zeno::clamp(spos, 0.0f, 1.0f) * w;
int end = zeno::clamp(epos, 0.0f, 1.0f) * w;
std::vector<vec3f> temp;
for (auto i = start; i < end; i++) {
temp.push_back(image->verts[i]);
}

auto resample = get_input2<int>("resample");
if (0 < resample && resample < w) {
for (auto i = 0; i < resample; i++) {
float x = i / float(resample);
x = zeno::clamp(x, 0, 1) * temp.size();
int j = (int) zeno::floor(x);
j = zeno::clamp(j, 0, temp.size() - 2);
float f = x - j;
auto c = (1 - f) * temp.at(j) + f * temp.at(j + 1);
heatmap->colors.push_back(c);
}
}
else {
heatmap->colors = temp;
}

set_output("heatmap", std::move(heatmap));
}
};

ZENDEFNODE(HeatmapFromImage2,
{ /* inputs: */ {
"image",
{"float", "startPos", "0"},
{"float", "endPos", "1"},
{"int", "resample", "0"},
}, /* outputs: */ {
"heatmap",
}, /* params: */ {
}, /* category: */ {
"visualize",
}});

struct PrimitiveColorByHeatmap : zeno::INode {
virtual void apply() override {
auto prim = get_input<zeno::PrimitiveObject>("prim");
Expand Down
Loading