Jump to content
catchyid

VEX code to create new points

Recommended Posts

Hi, 

I am trying to create random points using VEX. Basically, It's a Geo node with only one Detail Attribute Wrangle node:

for(int i = 0; i < 100; ++i)
{
    vector pos=set(rand(0.1*@Frame),rand(@Frame),rand(10*@Frame));
    addpoint(geoself(),pos);
}

I get 100 points, but all have the same location? Any idea why all rand() is producing the same position for all points?

Thanks,

 

 

Share this post


Link to post
Share on other sites

rand always produces the same results unless you have a different seed. All 100 points are getting the same seed on each axis, so every point is in the same position. I suppose you would need to vary the seed of each axis across the points.

  • Like 1

Share this post


Link to post
Share on other sites

Oh my god :) how embarrassing ! not sure what made me thought the seed was different! I did not ask this question :D

  • Like 1

Share this post


Link to post
Share on other sites

you're getting different results for each frame, good, but for each frame, the 100 points are the same.

So you need another tie breaker, the 'i', just mult each Frame with i

for(int i = 0; i < 100; ++i)
{
    vector pos=set(rand(0.1*@Frame*i),rand(@Frame*i),rand(10*@Frame*i));
    addpoint(geoself(),pos);
}

Edited by Noobini
  • Like 1

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

×