Skip to content

Commit

Permalink
Merge pull request #1339 from zenustech/HFgradientdisplace
Browse files Browse the repository at this point in the history
gradient displacement subgraph v1.0
  • Loading branch information
zhouhang95 authored Aug 2, 2023
2 parents 9eff2d6 + ec8d0aa commit ce75daf
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions zeno/src/nodes/prim/WBPrimBend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1740,6 +1740,41 @@ ZENDEFNODE(PrimHasAttr,
"erode",
}});

struct HF_rotate_displacement_2d : INode {
void apply() override {
auto terrain = get_input<PrimitiveObject>("prim_2DGrid");

auto& var = terrain->verts.attr<vec3f>("var");
auto& pos = terrain->verts.attr<vec3f>("pos");

auto angle = get_input<NumericObject>("Rotate Displacement")->get<float>();
float gl_angle = glm::radians(angle);
glm::vec3 gl_axis(0.0, 1.0, 0.0);
glm::quat gl_quat = glm::angleAxis(gl_angle, gl_axis);

#pragma omp parallel for
for (int i = 0; i < terrain->verts.size(); i++)
{
glm::vec3 ret{};// = glm::vec3(0, 0, 0);
ret = glm::rotate(
gl_quat,
glm::vec3(var[i][0], var[i][1], var[i][2])
);
pos[i] -= vec3f(ret.x, ret.y, ret.z);
}

set_output("prim_2DGrid", get_input("prim_2DGrid"));
}
};
ZENDEFNODE(HF_rotate_displacement_2d,
{ /* inputs: */ {
"prim_2DGrid",
{"float", "Rotate Displacement", "0"}
}, /* outputs: */ {
"prim_2DGrid",
}, /* params: */ {
}, /* category: */ {
"erode",
} });
} // namespace
} // namespace zeno

0 comments on commit ce75daf

Please sign in to comment.