Move spliced Mesh to Center

   1680   4   1
User Avatar
Member
19 posts
Joined: Dec. 2021
Online
Hi, I want to split my heightfield into mesh and get all sliced mesh set in (0, y, 0) position. So I use labs mesh slice and try to use a fol-loop to seperately move every pieces into center, but when I use detail attr to save the offset values I just move whole mesh by offset of group 0. Is there any way I could do what I want? or it there anyway to set pivot point to the center of the sliced mesh and keep the pivot then output? Thanks!

Attachments:
split_mesh.hip (231.2 KB)

User Avatar
Member
359 posts
Joined: April 2017
Offline
You don't need a for/each loop for this. You can just use the Pack SOP to create a packed fragment with the pivot at the centroid of each piece... you just need a string-type name attribute for the Pack SOP to read. A Primitive Wrangle can convert your i@class into an s@name attribute like this:

s@name = sprintf("piece%g", i@class);

Then pack, and then you can use a point wrangle to set P to (0, y, 0).

Attachments:
split_mesh_toadstorm.hip (634.6 KB)

MOPs (Motion Operators for Houdini): http://www.motionoperators.com [www.motionoperators.com]
User Avatar
Member
8539 posts
Joined: July 2007
Online
or you can append Point Wrangle after your /obj/Split_Mesh_and_Move/mesh_slice2
int class = prim(0, "class", @primnum);
vector centerP = getbbox_center(0, sprintf("@class=%s", class));
v@P -= centerP * {1,0,1};
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
7759 posts
Joined: Sept. 2011
Offline
if you hate wrangles, you can use nodes. No packing loops or vex required

extract centroid(output: attribute) -> promote centroid from prim to point -> transform by attribute ('centroid', invert transform)
User Avatar
Member
19 posts
Joined: Dec. 2021
Online
tamte
or you can append Point Wrangle after your /obj/Split_Mesh_and_Move/mesh_slice2
int class = prim(0, "class", @primnum);
vector centerP = getbbox_center(0, sprintf("@class=%s", class));
v@P -= centerP * {1,0,1};
Thanks! This works for me!
  • Quick Links