 Howdy guys. IndiePixel here. I first just wanted to give a shout out to all the new subscribers. Thank you so much for subscribing. It really does motivate me to want to make more tutorials. Okay, so in this part three of the Intro to Vex series, what we're going to do is cover how to create this spiraling effect on the line that we have created in the last two videos, okay? And what we can do is we can actually go and determine the amount of spirals that we get. So you can have just the one spiral and you can just keep twisting it and twisting it. So it's a good technique to have in your toolbox of Vex, okay? So what we're going to do with all that is we're eventually going to go and just create a really basic staircase because I don't want to get into modeling out of full on high quality staircase here. I just want to show the just the technique, okay? And then once we're done with that, we're going to go over and take a look at how to set up these hanging lines like so, all right? So we're just going to write really, really basic Vex node that produces these draping lines, which can be used for cables and like your sci-fi room. It could be used for like power lines, those kinds of things. So really good again to having your toolbox of Vex techniques, okay? So let's start with the staircase, all right? So what I'm going to do is go over here and drop down a new geometry node like so, all right? And I'm going to actually go and copy the line node just because I don't really need to recreate that. We've seen that one plenty. So there you have our custom line that we created in the last video, all right? So we have the length, again we have the amount of points and a direction. So because this is a staircase, I'm going to leave it in this vertical direction, so a direction of one and y, okay? And what we want to do now is drop down another wrangle node like so, oops, and let's just call this rotated normals. And this is actually pretty easy. So you'll notice right off the bat, we don't have any normals on this, okay? If we're actually going into the points here, there's just a position, there's no normal information. So we can initialize that in vex really quickly by just typing in dollar n is equal to a set. And I'm going to set these to a direction of one in the z-axis like so. And now we have normals. And so what we want to do is we want to say as we go from the bottom to the top, we want them to make a full 360 degree rotation all the way around, okay, just one spiral. So in order to do that, we need a value that moves from zero to one. So again, we are going to create that gradient value. So we're going to say gradient is equal to pt num divided by the number of points minus one, all right? We'll just put that into the parentheses and cast it to a float. Again, you don't have to do that. I've noticed that it actually does just work now without casting it. So there we go. So now we have the float like so. So now we have a value going from zero to one. All right, so all we need to do now is utilize our sine and cosine to basically rotate the normal. And all we're really doing is we're saying that as we provide this gradient value, as we go from zero to one, we want to rotate around a circle. And that's why we use the sine and cosine, right? Because that will return us radians that are basically the x and y position around a unit circle. Hopefully that makes sense. So let's go and say that the dollar n dot x is equal to the sine of the gradient. Sorry, we'll do the gradient. Okay, let's just leave it at that and see what we get. And we'll say the dollar n dot z, right? Because I don't want to affect the y position. We don't need this. We don't need this to or the normals to point up or down or anything. We just want to rotate around a circle as though we are on the xz plane, okay? So then what I want to do is I want to say dollar n dot z is equal to the cosine of the gradient. All right, I missed something. Oh, there it is right there. All right. So now we're starting to get something. But you notice that we're only getting basically 90 degrees. Well, not even 90 degrees. It's like 45 degrees. And that's because we need to multiply this by that two times pi. So we need to say times two times dollar pi for pi. So I'm just going to copy this, do the same for that. And boom, we have a spiral. Pretty simple, huh? So with that, we can actually build a whole staircase just from that information, that basic information. Okay. And you'll notice too, also, when we increase that point line, you can really start to see the effect of that spiraling. Super cool. That's why I like math. Math is fun. Okay. Let's do this. And let's go and first create a grid. And this is going to become the stair step. So this grid is going to, let's actually make it visible. So let's just do one and one, like so. And give it just two rows. So we just end up with a quad. And I want this to face in Z, right? Because when we copy anything to points that have a normal direction, it's going to orient it along the Z axis. So this, the stair step is actually oriented in the Z axis. It'll actually be fit perfectly to the direction of these normals when it copies it to the points on the line. Okay. So let's go and just call this the step. And so I want it to point in the Z direction. Okay. So we want it to be on the X, Y, X plane, or X, Y plane. And we need to reverse it like so. And we're definitely going to have to make it a lot smaller. So let's do a point one and point one, see what we get. And then we'll just make it a little bit thinner in the Y direction there. Okay. So at this point, I just want to go and do a extrude. Okay. And I'm going to just push that out a little bit. And that makes our stair step. And I want to output the back. So we get that piece. So what we can do now is just copy it. And because again, like I said, because it's pointed in that Z direction, when we copy it to the points, it's going to orient it in that direction of that normal. So I'm going to say copy to points. Excellent. So now we have the basic stair step. And you notice the normals are getting all kind of walky there. So we can add some normals to the stair step itself. And then we'll fix that right up. All right. So the next thing that we want to do, let's say we want to add a tube. So let's just add a tube and make it the same length as this custom line over here. So I'm just going to make a tube. And this tube is going to be a polygon. And we're going to change this global radius right here to something like that. And I want to set the center to the length of this or the height of this. So I'm just going to say the height is copy parameter. And then we're going to paste it multiplied by point zero five. So that way it sits directly on the grid. And then we can feed in this length parameter right here. So I'm just going to copy this, the one that we created, and just have that drive this parameter. So now this tube is always that same height. So now we literally just control the whole staircase from this single node over here. And I'm going to reduce the amount of columns that we have. All right. So now we can merge these guys together like so. So select them both. Boom. Now we have a staircase. Pretty simple. So let's say we wanted to increase the amount of spirals. So all we need to do is just multiply the gradient value. So instead of going from zero to one, we go to something like zero to two. And that way we'll get two spirals. Pretty simple stuff. So I'm going to create an int and call this spiral count. And we'll do a ch i for spiral count. And we'll do a space actually. And we actually have to make an underscore because it won't work with the space. So there we go. Perfect. We'll create that. And let's just give it a value of something like two so we can see it working. So then I just want to multiply that gradient by that spiral count. Same down here. So you could also just create another float that says spiral val is equal to the gradient times that spiral count. And there we go. That way now I can just control that one argument right here. This one value instead of having to type it twice. Just do that. And now when we increase the spiral count, you can see that we're getting many, many spirals. So we just need more points to see that in effect. There we go. Cool. All right. So the last thing I wanted to show is just how to make the railing on the outside. Because I find that always kind of stumps people. The grouping inside of Houdini can be quite mysterious. So let's take the line again and the points that we have over here with the normals on it. And what we want to do is we actually want to create a line and copy a line. All right. That's pointing in the z direction because we want this line to point out along those normals that are on this line right here. And I'm going to copy that line to the points. So let's do this here. And I'm just going to pull this guy over here. This is kind of an organizational thing. And you can hold down ALT on the keyboard now and click on one of the lines to create kind of these intercepting deals on the lines there on the connector lines. Pretty cool. Okay. All right. So now we have these lines pointing out the normal direction there. And I'm just going to make that a little bit smaller like so. We don't need the normals turned on anymore. And so what we want to do now is we want to find all the points that are on the outside. So we're going to do a group by range for this. So let's do a group by range. Okay. And what I'm going to do is do the dollar OS so that it picks up the name from the node. So these are the outside points like so. And what we want to do is we want to say we want to select one of two. So every other point. And the reason why this works is because you'll notice that we're going zero, one, two, three. So everything in the middle here is all an even number. Everything on the outside is an odd number. So if we do one of two, we set this to points. So that is the inner points. And if we offset it by one, we get the outer points. Boom. Okay. So now we can just blast those, blast those guys, say delete none selected. So this would be odd points. And then you can make another one of these guys. And that'll be your even points or your inner points, whatever you want to call it. There you go. So now the even and the odd points. But we're just going to work with the odd points here. So now I'm going to use an add node to make a line out of that again. So we go to the polygons tab, say by group. And we have a line that we can use. So now to make that into some sort of railing or whatever, right? All we really need to do is just sweep a circle around it. So let's make a circle like so. I'm going to make this a polygon. And we'll drop down a sweep node. All right, wire this guy up. There we go. So you'll notice that let's take a look here. Let's make this a lot smaller. So we're going to do 0.01. Let's take a look and see what we got here. And we need to orient the circle correctly. So if we go to zxyz, there we go. But you'll notice that they're all vertical. And that's because the line doesn't have any normals. So what we can do is use the polyframe over here. Okay, what we want to do is have normals that are actually pointing along the axis. You can see that the normals got picked up from the copy to points node, which is fine. So we use a polyframe, turn off the normal name, and in the tangent, we'll just put the normal attribute. And now you'll notice that the normals are spiraling down that line. And we can use that now to orient the circle along the spiral. There we go. Okay, so for the output and the sweep there, all we need to do is do a skin with auto closure, and then provide some normals. Super cool. All right, so there is our railing. So let's just merge these two guys together. Like so. And we have our railing that's a little bit too far in right now, right? And that's just because the extrusion amount and this line length are not in sync. So what we need to do for this extrusion, we need to copy this distance value. And you could do it either or, like the line can control the extrusion, or in this case, the extrusion is going to control the line. So I'm going to say copy parameter and set that as the relative reference. And now we're right up on the side of the edge. And what we can do now is actually just transform this guy upwards. I know we have some sort of like railing. And we can go in there and add vertical posts and everything like that to make it official. But I'll let you guys do that. I really just wanted to go over the technique here, because it's super cool. And you can make a lot of stuff out of this, just using that sign and cosine. There's so many useful ways in which you can actually use sign and cosine. It comes up all the time every day. I've noticed. So that is the spiral staircase. Okay, so let's move on and do the hanging cables. Okay, so let's make another geometry node over here. Awesome. And what I'm going to do is copy my custom line. So this custom line, sorry, the one inside of the hanging cable. So this custom line actually does split up the the primitives. So per segment. Okay, so I'm going to drop this guy in here. And I went over that in, I think part one. So now if we were to look at this line, there is going to be a primitive per segment. So zero, one, two, three. Okay, so let's go and actually make these guys drape. Very cool. Okay, so what I'm going to do is I'm going to drop down a for each subnetwork. Okay, so this way we can loop through each primitive. Okay, so I'm going to select this for each. And I'm going to set it to each primitive. And what I want to do is jump inside. And now we can actually loop through each of those primitives and perform the draping operation on it. Okay, so all we need to do at this point is a resample. So let's resample it so we get some more points. Okay, and I'm going to do the maximum segments. That way we have control over how many points there are in each section of these cables or these hanging cables. And then I'm going to drop down a wrangle node, like so. All right, so again, we need to create that gradient value. So let's look at our point numbers. So we want a value that goes from zero to one based off the number of points. So gradient, one of these things I'll make a preset for this, but practice does make perfect numpt minus one float and float. All right, so now we have that gradient value. And now that we have a value that moves the length of this line, so it moves from zero to one, we can, once again, use the, well, not once again, we can use an exponential type of expression. So instead of it, if we were to do something like y equals x squared, okay, so let's just say that this gradient value is x, we could also use the x position or the z position in this case, but because I want to keep it what they, how they refer to as unitized, I'm keeping it from zero to one. Okay, so let's just say that the at p dot y is equal to the power of gradient second. We get an exponential curve. Okay, but what we want is we want this offset a little bit. So what we would do, okay, is we need to say, and this is just the algorithm for us, so we're going to say two times the gradient minus one to the second power like that. And what happens is it offsets it. Okay, so now we're getting that draping effect. Okay, it's like we offset the whole graph. If you remember from your algebra or trigonometry classes in high school, it just offsets the graph. So now we're getting the negative and positive sides of the graph of that exponential graph. Okay, so it's just two times the gradient minus one. All right, and you can then offset this. So we could say plus 0.05 or something like that. And you can see that that offsets it. Let's subtract it and that pushes it down. What we really want to do is multiply this by some sort of scalar value. All right, so we can adjust that intensity there. Okay, so let's do that. So I'm going to take a float value and just call this amount. How about that? We'll say ch. We'll call this amount. Okay, create that parameter. And now let's just give it a default value of something like 0.5. And we'll multiply this whole thing by that amount. And that just kind of pulls it back. So you can see that it is basically affecting that y position on both sides. Whereas if, let me comment this out for a sec. Whereas if we were just to do the simple version of that exponential expression, where we just say gradient to the power of 2, all right, and then we were to multiply that by amount, we're just getting half of the graph. But that is also super useful too. Imagine doing the end cables for a bridge. That's basically what you're looking for. Okay, so we do want this one up here, at least in this case. I just wanted to show both. So now we get the full negative side of the graph and the positive side of the graph. And we have control over the amount of draping. So you might be wondering yourself, well, that's all cool and everything, but I wanted to actually drape from its original position up here. Right, I wanted to go downward. So really quick fix for that. You could do that in math, but what I want to do is just show you how to do the quick fix version. Sometimes you don't want to spend all your time in code. We'll just take the current y max and negate that. There you go. So now what we can do is create a null, the digital asset null. And I'm just going to call or open up the parameter interface, create a float over here. And we'll just call this hang. This is the actual name. So hang amount, then hang amount. And we'll give it a range of something like zero to just we'll say one, because one was pretty intense. And we'll do a default of 0.25. Hit apply, accept. So now I can just take this value, go back into that for each node and have that drive this guy. So now we can control the draping amount outside of that for each loop. Cool. So we did it. Now we have the draping cable effect. And we have spiral staircase. Pretty cool stuff. All right, so I'm going to leave you guys there. And I will work on part four. Thanks so much.