Jump to content

VEX "for loop" for Points


juleslin

Recommended Posts

Hi all,

I am a MAX user for 10 years, able to write some very simple maxscript. Just started to explore Houdini a few months ago and trying to learn VEX. I hope someone could show me a very simple VEX sample to help me solve the question.

I created a grid, applied a scatter node to generate 100 points on the surface. And I would like to add different values (5 | 10 | 20) to these point's attribute (i@prob) by using attribute wrangler "for loop". In max, I would do something like this:

for n in 1 to $.count do
(
$[n].scale = [2,2,2]
)

Sorry that the question is too "fundamental"...

Link to comment
Share on other sites

for static values you can just use a "attribute create" node.

for wrangles, if they run over "Points" that means it is already looping over all points, so the following should be enough:

v@prob = set(5, 10, 20); // if you want to store the data as a vector

or you could do, if you want to pick an integer randomly from your list:

int probAr[] = {5, 10, 20};
int index = int(rint(rand(@ptnum) * 2)); //rint is for rounding the value to the nearest integer
i@prob = probAr[index]; 

// you could even put this entire code in one line if you would like, like this:
i@prob = int({5, 10, 20}[int(rint(rand(@ptnum) * 2))]);

 

Edited by acey195
Link to comment
Share on other sites

  • 2 weeks 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...