DonRomano Posted August 6, 2019 Share Posted August 6, 2019 Hey everyone, I try to separate a building using a curve, to drive an rbd simulation, but I'm struggling a lot : Here's what I get when I try to separate the building pieces in two parts using a wrangle node, I've written : vector pos0 = point(0, "P", @ptnum); vector pos1 = point(1, "P", @ptnum); if(pos0.x > pos1.x){ setpointgroup(0, "right_side", @ptnum, 1, "set"); } else{ setpointgroup(0, "left_side", @ptnum, 1, "set"); } But the separation is not following the curve, and I don't really know where I miss something. If anyone has another method or the solution, it will be much appreciated ! Cheers, Quote Link to comment Share on other sites More sharing options...
Lucy Coleclough Posted August 6, 2019 Share Posted August 6, 2019 so it looks like you're comparing every point on the building to a point on the curve with a corrosponding point number. This won't work unless you put some work into somehow co-ordinating the point numbers beforehand. What I would do is look for the closest position on the curve geometry using: int prim=0; vector primuv={0,0,0}; xyzdist(1,v@P,prim,primuv); this will give you the closest prim and the position on that prim. then use: vector nearPos= primuv(1,"P",prim,primuv); to interpolate the point positions on the prim to that primuv location. then compare the current position with the nearestPosition: if(@P.x> nearPos[0]){ setpointgroup(0, "right_side", @ptnum, 1, "set"); } else{ setpointgroup(0, "left_side", @ptnum, 1, "set"); } This setup will only work in one plane, currently the x axis. To expand it and to prevent against looping curves you could look into using a cuttting plane and then analyzing the dot product of the nearest faces normal. 1 Quote Link to comment Share on other sites More sharing options...
DonRomano Posted August 6, 2019 Author Share Posted August 6, 2019 16 minutes ago, ColecloughGeorge said: so it looks like you're comparing every point on the building to a point on the curve with a corrosponding point number. This won't work unless you put some work into somehow co-ordinating the point numbers beforehand. What I would do is look for the closest position on the curve geometry using: int prim=0; vector primuv={0,0,0}; xyzdist(1,v@P,prim,primuv); this will give you the closest prim and the position on that prim. then use: vector nearPos= primuv(1,"P",prim,primuv); to interpolate the point positions on the prim to that primuv location. then compare the current position with the nearestPosition: if(@P.x> nearPos[0]){ setpointgroup(0, "right_side", @ptnum, 1, "set"); } else{ setpointgroup(0, "left_side", @ptnum, 1, "set"); } This setup will only work in one plane, currently the x axis. To expand it and to prevent against looping curves you could look into using a cuttting plane and then analyzing the dot product of the nearest faces normal. Thank's a lot, works perfectly ! 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.