Jump to content

Coloring Points With Vex


PlatinumFishy

Recommended Posts

SO, I am currently trying to make mini planets with procedurally generated  biomes (Probably too ambitious since I'm still new at Houdini, especially with vex but oh well). I fist scattered a few points around a sphere then assigned those to a group. After merging the new group of points (radial) with the original sphere I wanted to make it so that points within a certain radius of the scattered dots would be colored red. I got everything in a VEX statement but I cant seem to figure out how to color the points nearby, only the point the wrangle is working on.

For those who do not want to open a file.


int check = inpointgroup(0, "radial" , @ptnum);

if (check==1)
   {
   int near[] =  nearpoints(0,  @P, 5);
   
   foreach( int i; near)
   
   @Cd = {1,0,0};
    }

 

 

 

Biome.hipnc

Edited by PlatinumFishy
Link to comment
Share on other sites

You find the near points, and that's ok, but then you just color red the @ptnum and not the points the nearpoints function has returned.

 

I guess it should be something like this:

 


int check = inpointgroup(0, "radial" , @ptnum);
vector red = set(1,0,0);


if (check==1)
   {
   int near[] =  nearpoints(0,  @P, 0.1,5);
   
   foreach( int i; near)
   
   setpointattrib(0, "Cd", i,red);
   
    }

 

Note that I added an additonal parameter to the nearpoints function to indicate the maximum distance (0.1) (edit: now I realise this parameter it's not necessary, but anyway I think it's better to hace more control. Whatever floats your boat):

int [] nearpoints(string geometry, vector pt, float maxdist, int maxpts)

 

Edited by mine
Link to comment
Share on other sites

8 minutes ago, mine said:


   foreach( int i; near)
   
   setpointattrib(0, "Cd", i,red);
   

Thank you! that did the trick. While I was waiting I was trying to input all the points in the "near" array into a group and /then/ color it.

I do have one question though, isn't "i" just a place holder for the " near" array? Meaning not the actual point number? 

Link to comment
Share on other sites

Glad to help.

in every iteration "i" stores the value of the array, so as the function nearpoints returns an aarray containing the point number of every point found, in every iteration "i" stores the pointnumber of a "near point".

The you can use that point number to set his color attribute

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