- [Instructor] The name of this video is 3D Surface Matrix Example Two Part One. So in this video we're going to start by looking at a previous example that we used earlier in lesson five, was our 2D Surfaces Example Two, and we're going to adapt that to our 3D code. And we can take a quick look at that if you don't remember that. Go ahead and run it on the surface. Okay, so that was producing using a centroid point and my matrix corner points to produce curves. And then I joined them together for this outer curve. And then this inner curve was also a product of the four corner points and then it was scaled around the centroid. I then drew a profile curve from a corner point to the starting point of that inner curve, and then use that to sweep between the two curves using them as rails. So to make that 3D, we're gonna look at our model here. And what I'm essentially doing is pulling those curves apart. Let's zoom in on this. So pulling those curves apart, I'm duplicating the point matrix curve, making a second one and then pulling this inner sort of aperture up all the way to the top. And I can do that because in this surface normal system, since I can scale the normal, I can scale it to any direction I want, any value I want from the point matrix. I could also go in a negative. You could do a negative scale too which is going to create geometry on the backside of your surface. I won't do that in this, but you'll get the idea of how that's possible. So the first problem is to create these curves actually before I do that, I need to create these normals in our point matrix code. So let's take a look at that. So how do I create those different scales? Well, since I'm gonna be scaling the vector, this is the first one, so this is where I'm finding the surface normal. I then unitize that vecNorm because I'm gonna scale it. And then I scale it here and I'm scaling the first one, that's this one. I'm gonna scale by 0.5. Try it right here. And then save that and I can do this in one line of code I can do it at my PointAdd so I'm adding the vector to the matrices point. And I'm simultaneously saving it in this dictionary srfNorm01. Then for the second one srfNorm02. Unitize the vector again, setting it back to one. And then I scale it. I wouldn't have to do that here because I'm setting that value, scale value to one and that's essentially what unitizing does, but if I ever wanna change that to something else, it would be a good idea. It's almost always a good idea to unitize the vector before you scale it, it sort of clears it's slate, brings it back to one, and then you can scale it to whatever you want. So I'm scaling that one by one, and then I'm doing the PointAdd here. The only reason I've did this sort of separately here is because I had these other lines of code here, which were using the vecNorm, where I want it to visualize the point and I want to add a line and so I've just shut those off. But so I could do it this way and then I'm adding that to that dictionary or I could do it all in one line. So there's always different ways of doing those things. So that's now saved in that dictionary. So now I have my three point dictionaries so the i, j structure for point matrix for srfNorm01 and srfNorm02. And then I'm gonna call my GenerateGeometry function here. And I'm sending those three dictionaries and the interval values to that function. Then in that function I go through the loop. I'm using my midpoint function, which I have down here to find my centroid. (clears throat) So this is creating that first curve, what I'm calling the first curve, which is this one down here. So I'm using all the values from the point matrix code. So those are creating the edge curves then I'm joining them together. This is creating the second curve. So I find a different centroid for that, which is here. And this is all the values related to srfNorm01. So that's all here, then join those. And then the third curve, choosing all the values for srfNorm02. And I just draw that circle and then I scale it based on that centroid. So scale right here. So let's run that on the surface and see how that generates the curves. So it's generating the curves in space for each module. And then the last step of this is to loft these curves together. And when we do a loft, particularly when we start to do it with multiple curves, we have a number of different options. So I'm gonna unhide this loft. So I did this loft between these three curves and I decided on straight sections. So it's going straight between the points it's rather than being rounded because I wanted it to adhere to that, those curves as much as possible, I also didn't have it simplified. So if we look under, in our coding, if we look under add, AddLoftSrf, (clears throat) we got a lot of options, so you can choose. So here I'm choosing straight sections, and then I'm also choosing none does not simplify here. I can also choose a start point and an end point, but I don't wanna choose those, those are optional. So question is how do I get from my IDs to skip these two and then get to these two. And then I'm not concerned about these. So I'm gonna leave those out so we can take a look at that in the code, how I write that. And that's right here. So inputting my three curves in order, which is important, so first, second, and third. And I'm putting them in parentheses, making a tuple out of them, which it's, since it's asking for a list of curves in order. And then I wanted to skip those two, the start and the end point. So I've skipped those, just writing none. So if you wanna skip some argument, you just have to write none and if it's optional. And then put it two for straight sections and then zero to not simplify. And then the rest of the arguments are optional so I can just leave them out after that. So let's take a look see how it generates our surface. Okay, so sometimes this happens with loft for some reason, it's putting the back-faced on the outside and it probably has to do with the directionality of the curves. Now I could go back into the code and change the directionality by changing the order in which I drew these curves. And I'd have to do that for each one because I need to keep them in line with each other or else I'll get a twist in my loft, which I don't want. So being the lazy person I am, there's another solution rather than going and redrawing those. And I could just flip the direction of the curves by reversing them. So I just need to reverse the direction of each curve and then before the loft. Okay, so we're going to that net in the next video, we're gonna look at how we can apply that to a multi-surface object. And then maybe also produce some variation in it, changing the depth of the module in relation to its position on the surface, maybe add some color to it, maybe change the dynamics of the aperture, could we make the aperture bigger or smaller depending on where it is within the matrix. So we're gonna look at how we can now take that 3D geometric system and apply it to a multi-surface object. And we also wanna look at a couple of ways that we can produce variation within our module, besides just changing its numbers. I'll go ahead and run the code that we have so far from part one, just on one of those surfaces and I'll run it at eight U intervals. You might notice something different about this surface from the other ones that I did, the vertical surfaces, in this case the vertical is the U, the horizontal is the V and that just happens to be the result of how I created the geometry. And so I'm just gonna deal with that difference in the code. So I'm gonna have my U intervals at eight and then set my V intervals to two. And so we'll produce eight by two parts. The parts vary a little bit because of the nature of the surface. But they're pretty similar. Their thickness this way, doesn't change and the aperture doesn't change that much, it's always 40% of the module size. What are some of the things we can do? Well, we could apply that unequal code to this. So we could try doing that first to see what that produces and its effect. So let's undo this and we'll go to the code to see how we do that. The only thing that we're gonna have to change in that is that since again my U is my vertical now, and I want it to change exponentially in its verticality, I'm gonna use the U domain. So that's the arguments that I need to send to that function. And then in my loop, I need to turn off the original U step value, and then turn on that new one. This has to be i since U is in the i loop. So let's see what that produced. So it's subtle, but you can see a change in the dimension they're bigger at the bottom, and then they get smaller as they get towards the top so that's one change. Now I know that (clears throat) we went over in the first part, how the position of these curves is a product of the scaling of the vector from the original surface scaling of that vector normal. So that could be something else I could change. I could change maybe this first one to have it go from thicker at the bottom to thinner at the top. And I could have it respond to its distance from my CPlane. So that's a function that we haven't looked at yet, it's a simple function. So distance to plane, so it's gonna measure the distance to a plane that the closest point on that plane to any point in space. So I'm gonna use the point from my matrix, from my EvaluateSurface here. So I'm gonna use that point. I can find my or use my WorldXYPlane, so which is this plane here, that's my X world XY plane. So I can return that, save that in a variable plane. And then it finds a distance to plane. Now I'm not gonna go through printing this out. What I did was (clears throat) I printed out that distance because I wanna use that distance as something to effect the scale. So I want it to really change within a range of one from bottom to top. So I had to experiment with the distance that, that was returning. So I printed it out and then I divided it by a number at first, and then I needed to subtract that number from one, so I start out with a one at the bottom, so it's thicker and then it diminishes as it goes up because it's subtracting this value. So that's why that's written that way. So we can take this 0.5 value out, put it here, and then we'll put in our equation. Okay, so that's gonna change our vector, the scale of that vector first vector for srfNorm01, which is the profile that's in the middle. So now we can see it starts out thicker at the bottom, and then it gets thinner as it goes up to the top, scaling. What's something else we could change? We could change the size of this aperture, so we could use that the same equation, same set of tools that we used with the distance, from that plane that we just use, we could use it to change that scale. So let's do that. So it's down in this, creating the geometry part of the code. In this case I can't use the point, but I can use where it's saved because I'm in this different loop, different function. But that amounts to the same thing, then finding that plane, and then I'm gonna replace my 40% aperture value with that same equation three times. So it keeps it, makes it a uniform scale. Let's see what that does. So now it's giving us a much larger aperture at the bottom. I think it's smaller as it goes up. So now I have for one, two, three, three changes, we could do a fourth, we could do color. That's easy to bring back since it's right here. The only change I need to make to this, because again I wanna change from bottom to top in a vertical direction. So I'm using U I'm using my interval, so I need to change it to my i. So I do that both in the ObjectColor and that MaterialColor. A quick look at that and render. Okay, let's do all the surfaces. And that's already set up to go in the main. If I set this up with surfaces, the fact that this is a list it doesn't matter, it'll run fine with inputting one surface so I can input one or as many surfaces as I want with this. So I can select them all. We could produce another one, just move that over. So let's produce another one, changing our U and our V values. So let's change it to 20 and five. It's gonna have to think for a bit to do that, a lot more geometry. Still thinking. Here we go. It scales, scales pretty well. This is nice, you really see a different, see a much greater sort of gradient in these pieces and a much greater gradient in color. I have more pieces there. All the geometry looks good. All right so (clears throat) have fun with your modular tower assignment. And I hope these two examples give you some ideas for what you can do. And remember, it's probably gonna take a bit of time in your manual modeling here to come up with a pseudo code that you want to then build in the code. So don't skimp on that time because that's really where all your work is done. And then your code should follow in a fairly straightforward way from that.