Jump to content
Sign in to follow this  
stonegrange

grouped prims on a plane

Recommended Posts

I am trying to make a procedural meadow with fields within that are 'chunked' off into groups (like the example pic) and the number of fields altered randomly with a seed. Any help or pointers would be appreciated.

My current method creates groups that are too 'stringy' and feel like there is a bit of a simpler way that I am not seeing

field HDA explanation.png

meadowHDA.hip

Share this post


Link to post
Share on other sites

Are you looking for something like this:

field.thumb.png.4ec7d68bc0880007a48e0e6c7b77105f.png

 

If so, this is really easy to achieve with Scatter, enumerate those points, and attribute transfer the Index attribute on the grid, attribute promote from point to prim, then primitiveSplit on that attribute

After that, you have a clean set of non overlapping primitives built on the initial grid, and it's trivial to find center points, build roads, fences and whatnot.

 

  • Like 1

Share this post


Link to post
Share on other sites
Posted (edited)
//regular boxes copy
int dim = 50;
int bls[];
int bool;
int pt;
int max_s= 15;
int min_s = 3;
int size;
int area;
int dist;
vector ori_pos;
vector pos;
for(int i;i<dim*dim;i++){
    ori_pos= set(i%dim,i/dim);
    addpoint(0,ori_pos);
    if(removevalue(bls,i)){
    append(bls,i);
    
    continue;
    }
    
    dist = 0;
    int k = i;
    while(1){
    
    if(k%dim== dim-1){
    
        dist ++;
        break;
        }
        
    if(removevalue(bls,k)){
    append(bls,k);
    break;
    }
    
    dist++;
    k++;
    }
    
    size = min(dist,floor((max_s-min_s)*rand(i+ch("seed"))+min_s));
    area = size *size;
    for(int j;j<area;j++){
    pos = ori_pos+set(j%size,j/size);
    pt = pos.y*dim+pos.x;
    append(bls,pt);
    setpointattrib(0,"class",pt,i);
    setpointattrib(0,"Cd",pt,vector(rand(i)));
    
    }
    
    }

@stonegrange
 

dfss5.jpg

Grid partion.hiplc

sdrr.jpg

Edited by Librarian

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  

×