In this Clip we create the shape of the rail. We do that In a very nerdy way. By using the superformula as basis.
In the third clip of chapter two, we are going to create a shape for the rail. We are going to create this shape in the most nerdy way possible. The starting point will be a result of the super formula. I came to that idea when I made a tutorial on this math formula. I noticed that one of the figures you can get out of it, it kind of looks like a rail.
Obviously we could get to a shape with easier methods, but there is a lot to discover. So let's jump right into it. The super formula gets a bright yellow on my complexity scale. I already have a video on this method and how to implement it in Houdini, but it is part of the rail. So I definitely need to show it one more time, but I keep it very short.
The formula is a way to scatter points on an ellipse of various forms. With different values in its parameters, you can create all kinds of different shapes. But first we need some control data to define the amount of points we are going to use. A radius for the size, the step size, it needs to complete a circle and a vector for the formula itself.
We needed typical parameters. You can find these very quickly on the internet together with examples of the different shapes. For my shape, I need A, and B equals 1, M equals 2 and all three N parameters equals 0.5.
I have the tendency to define most variables at the beginning, but it is not really necessary.
It looks a bit cleaner, although I break that rule anyway, again, and again,
Again, let's just type down the formula. I do recommend to play around with the numbers though. There is a lot you can do with it, but for now we just create the for loop over the defined number of points. And the loop we type in the formula.
You don't have to remember this. Just make a mental note for yourself. Super formula equals many abstract shapes. If you ever needed again, Google Houdini, super formula, and you will find this or my other video. For this current purpose, we have what we need in this value. With it, We get the X and Y position for our point, combining the angle.
The radius and the formula value with the position being prepared, we create a point while we take hold of the created point number. We will need it in a few. We get different positions for each point by increasing the angle by another step, again, using a size that will cover the whole circle. Take a look at what we have so far.
I don't mind having a lot of resolution on this and I want a good number to illustrate future steps. So I bump up the point amount to 100. But for the sake of performance, something around 24 would be more reasonable and more than enough detail, a radius of one should be enough as well. This is the initial shape, the baseline If you will
the ultimate workflow, rather than using a simple circle, why not use a complex math formula to create geometry that is most likely only seen in the background, but at least it will look good.
Now I want to add a bit to it for one. I want the top point slightly extruded. My thinking was that it could be a section that is closer to the train.
Maybe it could be part of an particle emitter since all of these points are created by this wrangle, I can easily jump in and manipulate them. I check if the point number I just created is a specific one that I can define in a channel. If it is that point, I overwrite the position. I am adding a vector on the position to be precise.
And while we already have it here, we also put the point into a fitting group for later use. With that, I can pick any point of the ellipse and offset the position with this slider. Next. I want to create additional features into this shape. I want to pull it apart. I only want to keep the top half for that.
The rest I blast away when the position in Y is smaller than a tiny fraction below zero, I started with 100 points and I want to keep the two outer points. That means after this blast, I should be left with 51 points. I said, I want to pull it apart. So throw down a transform node and push it up a bit.
Since my rain we'll have a wagon above and below the rail, it should be identical on both sides. Create a mirror node and change the direction parameter to the Y axis at this stage. I want to connect the points. Now you can, of course, just use an ad SOP and even use it to create a closed polygon. But there is one advantage if you do it with a wrangle and that is that you can decide if you want to create primitives or not.
I want to connect all of the points and close the resulting line. Meaning the last point connects with 0.0. Again, we create a loop going over all of the points and in it, we not only create a polyline, but also the two vertices to connect it. You can write that in one single line. When you add a primitive, the two parameters stand for two point numbers where a Vertex should be added.
Once this loop is processed, we only need to connect the last point for that. I add another prim and this time adding the vertices as separate commands. I want to point out three things in this short snippet. First, I don't need the in prim in front of the ad, prim it is just a habit to catch returning values in a variable, just in case you need it.
Later. Second, I could have written the ad prim for the last point in the short form as well. There is no specific reason to write the ad Vertex separately. I just want you to see that you can do the same thing in multiple ways. And third, I could have created one single primitive. Before the loop and just at vertices, the result would be the same as using an ad sob, but more on that soon.
And I thought I am responsible for being the chaotic voice.
The points are connected, which is good, but we do have an issue with the point order. The mirror puts the next point on the opposite side. So how could we fix that first? We need to be able to control the mirrored side on its own on the mirror node.
We have the option, keep original. Without that option. We only have the mirror geometry. When we connect that with the previous node into emerge, we are back where we started, but now we can throw down a transform to manipulate the mirrored points, rotate around the Y axis until both halves are aligned correctly.
This could be already enough, but I wanted to add a small change to the shape, just a minor detail, but maybe this turns out to be a small aha moment for you. I want to change the outline of the shape by adding additional points. I want to create an extrusion without having to use poly extrude on the sweeped curve.
And what a surprise. I am going to use a wrangle to do that. I want the geometry of this wrangle to only consist of the new points. So I am connecting the previous node into the second input and keep the first one empty without any incoming points. I have to turn the wrangle to detail. We know that the two outer points are point number zero and number 50 on each side, I want two additional points.
So first I grabbed the position of one side in this case 0.0 and add the two points. Now that I have the point numbers saved, I can change their attributes. I am going to slightly shift them from the original position.
As you can see in the viewport, they basically form something like an extruded edge. Then I all dragged the note over for the other side here. I changed the position. I want a grab to point 50 being on the other side means we also need to change the sign for the offset. Now, when you look at the merge, combining the additional points and what we already had, this can only work.
If we combine the three nodes in exactly this order, the points are numbered in the order that they enter the merge. The two points of the first wrangle become 0.0 and one, while the points from the second wrangle become the last appoints. That means the order stays intact and we can use the connect wrangle if we added the points in the right order.
That is, and indeed I switched up the last two points. I simply swap the point numbers
and here I have my final rail shape using the techniques you have just seen. And by manipulating parameters in the super formula or other nodes, you can get any shape you want.
So does that mean I can get a balloon animal?
you are a God dang liar
with the connected shape in place. We can use a polyfill node to convert this into a single polygon for a good sweep.
I noticed that having done it this way, I need to reverse the patches on the polyfill node. And now we can do the sweep itself, which works incredibly well with the latest sweep node version. So bring in the oriented curve again with another merge. From the curve, we can go directly into the sweep node and then connect the shape into the second input.
As cross section,
you can see by the blue color that we also need to reverse the cross sections here as well. And now we got a nicely sweeped curve giving our rail its form. The rail has no end pieces yet, but you can simply turn them on in the surface tab of the sweep node. And the nice thing with the sweep node is that we get UVS for free already done during the sweep for the rail itself, there is not much left to be done.
We could do some clean up. Of course, we have a number of points on the same positions, so we can make it a bit lighter with a fuse note that brings the complete rail to under 50 K points. Remember, we used a very high resolution, so you can bring that to even less, the sweeped curve already has normals.
So we don't need to bother with that. At last, we can get rid of whatever is still left in the attributes in groups. This is just the mesh for the rail. For any logic, we can use the oriented curve again, that means we can get rid of the roll attribute and also the rail top group. We are going to create a separate stream in a second to deal with that for the better or worse.
I like to pack geometry. If I am not going to use it for anything else anymore, for the material assignment later, I also put the whole geometry into a group called rail. With that we can format this section, according to the guidelines we created now to this group, I still have lying around the rail top.
I can already tell you that I did not use it in the end. After all this project got way to big, even without slapping a particle simulation on top of it. But this was my idea. And the reason why I use the connect lines wrangle over the ad stop, I wanted to isolate the top and the bottom of the rail, the points I extruded on the original shape.
I also wanted to use only procedural methods. So I had to start by isolating this rail top group again, using a blast note that leaves me with a bunch of points that are not connected. Now, the reason I did this section, the way I did was the way this would sort my points. With an ad SOP, or even with a wrangle using only one single primitive, the points would have been an order counting in an alternating pattern with the top and bottom.
But since I created the shape, the way I did, I now have the first half of the points at the bottom and the second half is at the top. That means I can now go ahead and check if a point is smaller than half of the point amount. And if so, I put it into a new group called rail bottom. The affiliation to the rail top group.
I simply toggle off
just to get a clear overview. We can use a split node and see the top or bottom points on their own. Now we have the points isolated. But it is very likely that we would need the orient or at least the normals from the original curve. Since we do have the same number of points in each group, we can use a wrangle and do an attribute transfer.
We can directly read out the correct point by using PT now,
and now that we have this wrangle, we can copy it over for the other group. The lines can stay exactly the same. Again, there are a few things that you could use these for. What I wanted you to see was that there is always a way to get to the data you want. And I also recommend to create your own little library of vex snippets, easy to get hold of.
Then connecting lines through vex becomes as easy, quick and versatile as throwing down a single ed sob.
Whoever writes the comment you could have used an ad saw, gets an arrow to the knee. Now be a good viewer and hit the subscribe button.
Leave a Reply