 Howdy guys, IndiePixel here, and in this next lecture, what I wanted to do was cover how to randomize values when you are using your copy to points node, specifically when you are going to, you know, create lots of copies of a particular type of object, alright. So let's go and create another geometry node here, and what I'm going to do is just call this the random adders, right, for attributes, okay, and I'm going to jump inside there by double clicking, and I'm going to delete the file node there, and what I want to do is I just want to set myself up with, you know, some geometry to test with. So in this case, what I'm going to do is create a new grid, alright. So let's create a grid, and turn on my wireframe there by hitting shift W, and what I want to do is just scatter some points over this. So what we can do is, you know, get rid of, you know, the size here, so you can keep it like one and one, or you can keep the size 10 and 10, but, you know, we can keep the rows and columns to two and two, you know, I've also set up a preset for that, the simple grid, right, because I found myself constantly changing these values just to do some simple scattering, alright, so let's go and just scatter some points here, so I'm going to drop down that scatter node, alright, and I'm going to set the max points to something like, let's just say 100 for now, that's pretty good, alright. So now we have a bunch of points to work with, so let's turn on our point display, and our point numbers right there, and what we want to do is we want the ability to change the rotation and the scale of every copy that we place onto a point here, so every object that we place onto a specific point, so let's get that set up, so first thing I'm going to do is put down a box here, okay, so this is going to be our test subject, and I want to drop down that copy to points node, alright, this allows us to copy a particular object to every point that we are feeding into it, so the first input is our primitive to copies, in this case the box, and the second input is the group of points that we want to copy to, okay, so you can see there by turning on the display flag, I have a box at every single point, alright, so let's change the initial uniform scale there by a little bit so we can see all these guys, so we're copying a box at every single point there, so what we want to do is we want to go in and give this some randomization, alright, so this is one of those core things, you know, when you start working with VEX that you should know, alright, so just how do we create random values and how do we get it to propagate down to the copy to points node, alright, so this is just a good, you know, exercise in, you know, the intro or fundamentals of, you know, using VEX inside of Udini, so what I'm going to do is drop down an attribute wrangle node here, okay, I'm just going to drag and drop it right in the middle there, and I'm going to call this node the random adders, okay, awesome, alright, so what we can do is we can go and let's actually start with the random rotation, okay, so what I'm going to do is I'm going to come into the attribute wrangle node and we're going to run over points because we're feeding in a bunch of points, so for each point we want to create a random attribute, okay, so what I'm going to do is select this guy and inside of the VEX expression what I can do is I can create a new float, this is a local attribute or local variable I should say it's on an attribute, okay, so we're going to say float angle is equal to rand at ptnum, alright, so for the, for every single point number we're going to get a random value, so the random function here is going to return a value between 0 and 1 for us, okay, and each time we feed in a new point number we're going to get a different value, okay, so what we need to do is we need to put that into a range, we need to fit it into a range and in order to do that we can use the fit function and in this particular case because this random function that we're declaring here returns a value between 0 and 1 I'm going to use the fit01 function now there's there's quite a few different fit functions if we actually just hover over this particular function here and hit F1 on our keyboard, what'll happen is the help for that particular function will come up, alright, so let Houdini load this up here really quickly or moderately quickly, alright, there we go looks like it's now getting the data, alright, so what we're going to do is utilize the fit01 and this takes a value that is in the range of 0 to 1 and then shifts it to the corresponding value in a new range, so we can, we can define a new range for that and this is really useful for rotation because I want to say, you know, whenever this random value returns some value between 0 and 1 I want to remap that to let's say a negative 40 degree to a positive 40 degree rotation angle, alright, so I can I can do that with this particular function and there are actually quite a bit of other functions that allow you to change the different ranges of values, so there's the fit fit01, fit10 and fit11, so I definitely encourage you to go check this out because this is something that we do a lot when we are working with effects, so in this case because I already know I'm getting a value from 0 to 1 I'm just going to put in a value of negative 35 and 35, positive 35, this means I'm going to get a random angle, a rotation angle from negative 35 to 35, so something within that range, so what we can do is we can actually then assign this value to a rotation value that sits on the point and this particular point here, alright, is actually looking for, the copy to points note, is actually looking for these specific attributes, alright, and so these attributes in this case is going to be that atRot attribute, this is one of those built-in attributes at SideFX or Houdini provides you, so what we're going to do is we're going to say atRot is equal to a quaternion and a quaternion is a type that deals with rotations, okay, so we're not going to go into too much depth in this particular course or lecture I should say about quaternions, all we need to do is make sure that we feed the quaternion into this particular attribute, okay, so what we're going to do is we're first going to provide it the angle, alright, so we're generating this random angle here and then we want to give it an axis that we are going to rotate on and in this case I'm just going to rotate on the Y axis and so to do that we just put in the curly braces and then 0, 1, 0, 1 for the Y axis, the X and Z axis these will be ignored, alright, so let's go and show our geometry spreadsheet here, okay, you can see that now we are getting a rotation, okay, so we're getting a nice rotation there and if I turn out my copy of points you can see automatically we are now getting rotation values, random rotation values per copy, excellent, and that's exactly what I was looking for, alright, so you can take this even further, alright, and we can do float min max angle, alright, and we could say CHF for channel, a float channel, okay, and I'm going to call this the min max angle, okay, and then what we need to do is actually create that particular min max angle property by hitting this little button right here and if I set this to something like 65 now and then feed that into this particular function right here, this fit01 function so I'm just going to copy the local variable name and paste it in for those two hard coded values there, there we go, so now we actually have control over our min and max, alright, so we are on our way, so the last thing that I really want to show you guys in this video is how we then go about randomizing the size of the object, okay, so good practices here, let's go and add a comment, let's just say randomize rotation, like so, okay, and then we're going to come down here, we're going to say randomize scale and you need two of those forward slashes there, okay, so one thing I should note, if you're inside of this Vex expression area here, you can hit alt E on the keyboard and that will bring up the code editor inside of Houdini here, okay, it makes a lot easier, you can actually scale it up and you don't feel so constrained when you're coding there so it feels like, you know, your normal IDE, you know, it is a very stripped down IDE but at the same time it is, you know, a nice way to start to code more lengthy Vex scripts, okay, so if I go and actually spell this correctly here, there we go, so randomize the scale, so what we're going to do is we are going to go and create a random scale, so I'm going to say float scale, creating another local variable and what I'm going to do is this time I'm just going to start typing out a fit01 because I know I'm going to put this within a range, okay, and I'm going to do atptnum and just say plus 23, all right, so we can actually create a seed value out of that and so what I want to do is I want to say our new range is between 0.2 and 1.2, let's just start there and then we'll assign the atp scale, this is another one of those attributes that is built in that the copy to points node is actually looking for, so I'm going to say atp scale is equal to scale with a semicolon there and hit apply in the script editor here and right off the bat, let's say accept as well, right off the bat, now we have randomized scale, perfect, so we could take this even further, all right, let's actually provide the user the ability to define a min and max, so I'm going to say float min scale is equal to chf, we want it to be a float value, so it's chf, okay, and we're going to say min scale like so and then we want a max scale, okay, so we'll say chf is equal to a max scale property or parameter like so and what we want to do is we're going to feed that min scale into the first argument here or I should say it's the second argument and then the last argument in the fit01 function is going to be that max scale like so, all right, we'll hit apply and accept and you'll notice that everything will get zeroed out, no scale at all, it's because we don't have our parameters created, so I'm going to hit the little button right here and let's just put this to 0.1 and let's say 0.8, there we go, so now we can actually define our min and max scale, all right, super powerful, so that's what I wanted to show in this particular video, these are one of those, you know, kind of base vex recipes that you always want to use, this is how you create randomization, this is how you give users control and you know, it's just one of those foundational concepts that you should know, so I thought it would be a great addition to the intro to vex series, so thanks so much and I really appreciate all you guys' support, I'll see you guys in the next video.