Jump to content

Create point on the middle of a primitive


Recommended Posts

Hi, So I'm trying to create a point on the center of a primitive like the picture I've attached. Can anyone help me out?

- Scatter will create the point but it is randomly, not on the middle of the grid

- I've tried other centroid point methods but the point is outside of the mesh. So I'm stuck here :(

snap167.PNG

Link to comment
Share on other sites

Prim wrangle 1 : 
 

int pts[] = primpoints(0,@primnum);
vector center = 0;
foreach(int pt;pts){
    center += point(0,"P",pt);
}
center /= len(pts);
v@center = center;

Wrangle 2 ( run in detail ) :
 

int nprim = nprimitives(0);
for(int i = 0; i < nprim; i++){
    vector center = prim(0,"center",i);
    int pt = addpoint(0,center);
}

or you can use two Sop : Enumerate  Sop and Extract Centroid  sop to do that . 

Edited by nguyenvuquocan
Link to comment
Share on other sites

  • 2 weeks later...

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...