 Howdy guys IndiePixel here and today we are going to be talking about how to group with Vex All right, so we're going to walk through a bunch of different ways of how to group with Vex And we are going to build this chessboard not the little pawn pieces or anything like that. I just put that there for fun But we're going to go and learn how to use grouping to make this chessboard I know it's not very complicated, but if you're new to Vex learning how to group using Vex is very important All right, so before I get started. I wanted to do a quick shout-out to all the patreon members that I have now on the IndiePixel patreon page. All right, so I wanted to say a big thanks to David Tavon Jason Willis Max Crowe Michael Smith and Mitch Herald I really appreciate all the support and if you guys are interested in the IndiePixel patreon page Go and check it out. The link should be on the screen now. All right, so with that Let's get started with grouping in Vex All right, so let's go and make our own chessboard So I'm going to go create a new geometry node and we'll call this the video board All right, and I'm going to turn off this board And hit shift Z on the keyboard to bring up my groups and I want to display all my pawns We could actually just hit the Little display button there and then hide those guys. You don't need to see all that right now All right, cool So I'm going to jump inside this geometry node and let's just drop down a grid Let's just start there. We're gonna keep this relatively basic So we learn the fundamentals of how to group stuff with Vex. All right So with this grid in place We have some geometry and this geometry is made up of points and primitives All right So what we want to do is we want to go and learn how to group certain primitives in this case All right, it works for for points, too So let's drop down a wrangle node. All right, so you can do an attribute wrangle node And we're going to switch it over to primitives now if you just want the quick way you can just do a primitive wrangle All right, and all that that's doing is just switching this over to primitives there for you I'm just so used to dropping down an attribute wrangle node and setting this to whatever I need All right, so first things first what I want to do is go in here and just start to select some stuff so Really quick way to do this. I'm going to say if the at-prim num All right, so this is going to store the primitive number currently All right for each of the primitives because remember this wrangle node is going to loop through all each of these prim primitives here All right, so I'm going to say if your prim num is less than 10 then we want to put you into a group All right, so first way to go about doing this is To use the set prim group so we can set set prim group And if we were to highlight this guy and hit f1 on the keyboard over here That'll pop open the help here inside of Houdini There we go, which is very very handy to have because then we could see all the arguments that we need So in this case we have quite a few arguments really we have the geo handle All right, and that is going to be the geometry that we want to sample from and then we have a string That's going to be the name of the group and then we have an integer And that's going to be the current prim num that we want to put into this group We have a value and usually this is between this is zero or one because we either want to be in a group Or we don't want to be in a group and then we have a mode where we can set it and we have a bunch of different types of Strings that we could put in there We could use the set which will just set it or we could toggle it so we can toggle it on and off basically Okay, so with that what I'm going to do is type in zero because that's the Geometry that is coming into this first input right here, and then I want to give it a name This is going to be called my group and we're going to give it the current prim num So we're going to say prim num, and I keep putting the capital there there we go And then we want to set it to one so we set it and we want to tell it to set that group And I need to make sure this is correct. There we go. Cool. So now we can go and switch over in the geometry spreadsheet to Look at our group and you could see that all of the primitives that are less than 10 are now in this group we can also go up here and Take a look at our group itself so we can highlight it and see that zero through nine is in that group So if we're to do something like less than or equals we now include 10 All right, so that's one way to do that very cool Let's do something a little bit different now We're gonna say we're gonna do the shorthand version of this So I'm gonna say if prim num the current prim num that we're on is Less than or equal to 10 them. Well, I want to do is I want to do use the short form for this. So I'm gonna say I at group underscore my group Is equal to one All right, you can see it does the exact same thing super cool All right, so now we have this my group. So that's just your short form instead of typing out Set prim group and typing out all the arguments. We're gonna just use that short form for that Okay, so what I'm gonna do now is I'm gonna come over here and I need to get some sort of alternating pattern So I want to select every other Primitive in here to create our chessboard So we're just gonna change the condition up here. We're gonna say if that prim num We're gonna use the modulo to All right, if that's true then we're gonna put every other or eat all the odd Primitives basically are gonna go in there. So just to make this a little bit more clear. I'm gonna say I at group odd These are all the odd primitives So there we go. So now we get this checker pattern Pretty cool. We can come up here, too We can create a channel or an integer channel. We can say we're gonna just call this mod So we can change that value so you can see what different kinds of patterns you can get By just doing that little bit of math Super cool modulo is very powerful when working in your procedural modeling workflows They use it all the time Alright, so if you're not an odd primitive, then we want to put it into another group So I'm gonna say I at group underscore even is equal to one So now we've got two groups. We've got the even and the odds And let's actually pull this all the way over. So there we go So now we have an alternating pattern now this is really really cool because What I can do is I can come in here now and assign the color to each one of those groups so if I go to color and we're gonna go and pump that guy into there and I'm going to select all the odds. I'm gonna set our color to Primitive and I'm gonna set this guy to you know, not totally black, but a black there we go and Then we can come and create another one of these So I just hold down alt and left-click and drag to create a copy of that color node And I'm gonna set this guy to the even All right, so we're gonna say even and these guys are gonna be like an off-white Cool. So now we have the beginnings of our checkerboard now a couple of the things I want to note if we come up here to the side effects Help you can see all of the vex functions that are related to grouping with vex All right, and there's actually quite a few So currently we're just using the shorthand version, but we did cover these guys right here So you can see that you can group your primitives so you can group your points All right, and the point in the vertex groups work exactly the same way the arguments are exactly the same here Okay But let's go and take a look at some of these other guys before we go and finish up our Chestboard here. So and primitives group this will actually get the number of elements in a group This is very useful if you want to query basically how many primitives you have in a group You could do some sort of math there some sort of if else Conditional statement type of thing. So let's drop down an attribute wrangle node and this time I'm gonna put this on to a detail. All right So let's go and put this on to a detail just so we have a single Attribute to look at all right So let's go and say that I at Total prims or total we'll say odd prims. How about that? Say odd prims is equal to our n prim count or n primitives group and We want to feed it the geometry and the name of the group. So we want to query the odd group And look at that. We now have 40 Primitives in our odd prims detail attribute now if I want to do the events it'd be exactly the same So we just change this to even and We'll change this guy to even Look it out. We now have 41 primitives and even Now let's say you wanted to go and you wanted to find out all the indices For the numbers for each one of those primitives So I want to get a list of all the primitives that are in this group This is great because I know the total number of primitives that are in those groups But if I want the actual numbers of all the primitives in that group in one list one array So to do that if you come back to our documentation over here, you can see that we can get the List of point primitive numbers so we can expand the prim group Awesome, so let's go and test that out So for this to work we need to do an eye and we need to use the square brackets because we're making an array and we're gonna say at Prim list, let's just call it that or actually let's stick to our naming convention. We'll do odd There we go. So now I want to use the expand prim group and we're going to give it zero and the group name Now look at that. We now have a list of all those primitives all the numbers in the odd group All right, so we looked at how to create a Group using the long form and the short form And we also looked at how to get the number of primitives in a group as well as the list of all those primitives That are in that group very handy stuff All right, so from there, let's go and finish up our checkerboard here or chessboard actually All right, so with that I am going to That's pretty much good for the board itself Let's go and just duplicate this grid over here and I'm gonna keep it at the same size but I'm gonna make a two by two and I am then going to Do a divide. Let's just have a little bit of fun here And see how quickly we can make a chessboard. All right, so I'm going to get rid of Let's do a blast and let's get rid of Primitive zero There we go. It leaves me with a triangle I'm going to use this as a profile for the wood on the outer part of the chessboard All right, and then let's go and drop down a sweep node here And let's get this guy all hooked up So we need to go and get this oriented correctly. So let's drop down a transform node Now and let's rotate this 90 degrees. I believe. Yeah, very cool So now we got that but I need it to actually sit the bottom here to sit on the top of the grid there So let's do let's utilize actually a new node here. We're gonna do the game to have axis align here And there we go look at that by default. It'll set it up Right in the center there and now I want to set up the x-axis so that it's also at the min So now we have those guys right there Look at that pretty cool So let's go and do a transform and let's just scale this down a little bit like so And scale down in the Y. I don't need you know huge Shape there or anything like that. Let's go and do a polybevel to this. I'm just going to bevel all those points Let's get that bevel there. There we go. Very cool. And I'm gonna set this to points like so And then we're gonna go and make sure that we save this sometimes I find that the Polybevel will crash Houdini. So always important to save when you're using the polybevel Cool. There we go. We now have our profile. Let's go and just Skin with auto-closure when we have the outside now. So let's do a color for this guy here and Set it to primitives and that's because I'm putting all the color on primitives over here as well So let's move all these guys down here So you want those to be the same so that way when we go and merge these two we don't get any sort of conflicting Attributes. All right, let's set this to some sort of you know kind of a cherry wood type of color with darker nice Okay, so now I'm just going to select both these guys I'm going to hold down alt on the keyboard I'm going to select one of the outputs and then drag it out And that'll automatically create a merge node for me and look at that. We now have a chessboard Pretty cool. Nice and quick too. All right, so That was a little bit of modeling fun and some vex fun all in one video. How about that? All right, so I'm gonna basically leave you guys there and If you haven't go and check out the any pixel patreon page I'm adding new content. It just started up. So things are getting going I really really want to thank all the patrons that have already subscribed really appreciate it makes everything possible Thanks so much guys