Jump to content
JKeil

Pt Num Shuffle (REV)

Recommended Posts

Hey All--revising my earlier question

Simple question here.  Id like to randomly reorder the points on a line WITHOUT using the sort node.  I dont want positions to change (@P) just the ids (ptnums)-- self imposed technical challenge.  
Example start: 
ptnum 1 @P {0,1,0};
ptnum 2 @P {0,2,0};
ptnum 3 @P {0,3,0};
ptnum 4 @P {0,4,0};
ptnum 5 @P {0,5,0};
ptnum 6 @P {0,6,0};

Example Desired result

ptnum 3 @P {0,1,0};
ptnum 2 @P {0,2,0};
ptnum 1 @P {0,3,0};
ptnum 5 @P {0,4,0};
ptnum 6 @P {0,5,0};
ptnum 4 @P {0,6,0};

 I know you can do this with a Sort Sop (random) but I'd like to do it in a Vex Sop Specifically, and then in a wrangle afterwards--its a tech challenge thing.  I feel like this is simple and Im missing something pretty basic.  

 This is what it says about the Random method for Sort
Random
Using the random seed, each point or primitive is assigned a random priority. They are then reordered according to that priority. This has the effect of generating a random ordering of the points or primitives.  

Helpful info or not in this case?
If so, how can I apply this in a Vop Sop, and then later on if possible an Attribute Wrangle.  All the random operators within the point vop give arbitrary new positions, so I dont really know how to go about doing this.  In python,  the solution is a prexisting method for random so that is not helpful here either.  

import random
>>> x = [1,2,3,4,5]
>>> random.shuffle(x)
>>> x
[5, 2, 4, 3, 1]

 

 A pointer in the right direction would be appreciated.  


Thanks

Also, bonus question, what is the difference between ptnum and id in vop globals?  They are behaving as if they were the same thing when I am running orders (say random) across points within the point Vop.  

Thanks!

Share this post


Link to post
Share on other sites

@ptnum cannot be changed like a normal attribute. If you have one point, it's @ptnum is 0. If you wrangle @ptnum = 1;, it will not change. It is a different kind of attribute.

To do that re-arrangement, you will need to swap the @P. Or use @id instead of @ptnum. Or make a dummy attribute that is your @ptnum and go from there. 

The difference between @ptnum and @id. @id is used in a particle system, a unique integer given at birth that does not change as the particle count increases.

If you have points 0-9. and you blast point 0 - all ptnum will decrease by 1. If you did the same, but blasted by @id, the values would remain the same.

@id is not dependant on the point count. If you make a simple particle sim, and blast some points - you will see random points removing as the count increases. As ptnum is changing as points are added.

  • 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

×