Jump to content

grouped prims on a plane


stonegrange

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

Link to comment
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
Link to comment
Share on other sites

//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
Link to comment
Share on other sites

  • 4 months 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...