Jump to content

# Coloring Points With Vex

## 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};
}

Edited by PlatinumFishy

#### Share this post

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

#### Share this post

##### 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?

#### Share this post

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

#### Share this post

##### Share on other sites

for reference:

@Cd = {1,0,0};

only affects the point itself (that it is currently processing)

So it would apply the "sun" color to the "sun", one time for every point found, but since it is the same color,
that would be hard to see of course.

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

×