Jump to content
Sign in to follow this  
nghiatranduc94

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

Share this post


Link to post
Share on other sites
Posted (edited)

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×