Jump to content

Separate a building in two parts with a curve


Recommended Posts

Hey everyone, 

I try to separate a building using a curve, to drive an rbd simulation, but I'm struggling a lot : 

image.thumb.png.e95817305e55120358ea0b1dec57cccc.png

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,

Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

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 !

  • Like 1
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...