From the course: Cinema 4D Weekly

Selecting every other clone or polygon - CINEMA 4D Tutorial

From the course: Cinema 4D Weekly

Selecting every other clone or polygon

- [Instructor] Welcome to another Cinema 4D weekly. Now have you ever had the need to select every other clone or polygon in a project, maybe even every fourth clone or somethin' like that? Well in this video, I'm going to show you a simple formula called modulo that can allow you to select every other, every third, every fourth, et cetera, clone or polygon very, very easily. All right, so let's get a little bit geeky here and let's talk about what modulo actually is. Well, modulo is the remainder of two numbers that you divide. So here I have this little setup here, where if you divide zero by two, you actually have no remainder, the remainder would be zero. If you divide one by two, you can do that, but then you have a remainder of one and then if you divide two by two, that equals one, you have no remainder there, so you can keep going up from zero to nine, or to infinity and all of the remainders, the alternation between zero and one, zero one, zero one, zero one, that is the modulo okay? So you're modulating between these different values of remainders okay? And this is with the value of two okay? So let's take modulo and these remainders of going from zero to one, zero to one, zero to one, and have this affect say every other clone, so like zero percent strength, 100% strength, zero, one, zero, 100, all that good stuff okay? So, let's go ahead and let's talk about this little function that we need to use to create this kind of modulo effect to affect every other clone, and that function is mod, parenthesis, id; or semi colon, two, and then close parenthesis. Now, mod is modulo, so it's taking the remainder of two different numbers that you're dividing together. Okay, so just like we have over here and we get that modulo remainder, that's what we're having here as well. So, here we have two different numbers, actually the ID's not a number, but it actually is, so what is the ID in this formula? ID is the number of the clone, the ID number of the clone. Now you can find this in your cloner. If we go to transform and we go to display, and we choose index, okay? If this is, this is typically set to none, but if you change this to index with the ID, you can reveal what the ID number of all these clones are. So you can see they just go from zero to 10. I just have a cloner that is just counting to 11 clones and so we start at zero, we have zero to 10 and, basically, ID is the number of the clone and then we're just dividing it by two. So, the remainder of the ID is divided by two, so basically we have this same setup here, only visualized as clones, all right? So let's go ahead and to apply this formula, we're going to use a formula effector and we're going to apply this to our cloner object here. So if I turn on my formula effector and here on the formula tab, I just enter in that modulo, mod, parenthesis, id, colon, that's basically divided by, two, and let's just click off there, and basically, you can see with this scale activated, I just have scale activated, just scaling up, you can see that with this modulo formula, this is translating the remainder from zero to one, zero to one, zero to one, and translating it to zero percent strength of this formula effector to 100% to zero, to 100, zero, 100, zero, 100. So hopefully this makes a lot more sense, visualized now again. So, again, we're basically going to this alternate between zero one, zero one, zero one, translating it to strength of an effector on some clones. So let's do this with divided by four, okay? And here we have everything the same, only instead of dividing by two, we're dividing by four and we have the same setup where we have zero divided by four, remainder zero, we have one divided by four, we have that one as the remainder so that's the remainder. If we have two divided by four, can't divide into that, so the remainder's two, same thing with three divided by four, can't do that, so the remainder's three. Four divided by four though is one, so the remainder value is zero. Five divided by four, you can divide once, but then you have that remainder of one, okay, and so on and so forth. So actually between the divided by two and divided by four, we're not alternating between zero one, zero one, we're actually alternating zero, one, two, three, zero, one, two, three, zero, one, two, three, so on, so forth. Okay and you can see this represented in this modular ID divided by four, okay, and everything's the same, but what we have as far as how it's represented with the formula effector, is this scale strength is slowly ramping up over three clones or four clones, actually, so we have zero percent and then like 33% strength, then 66, then you know 100% strength, throughout this modulo setup using the divided by four. But, this doesn't really help us because what if we wanted to select every fourth clone. Well, what we can do is actually add onto our formula and say you know what, I want every modulo represented that just equals zero. So that means, unless the remainder is zero, it is actually going to just give a value of 100%, so you're either zero percent or 100%, depending on if you're a number other than zero, or remainder other than zero. So let's just add that, so we're going to do equals zero, hit enter, and you can see what happened. But now, we only have every fourth clone selected and actually scaling up because we said only add this scale to the modulo that equals zero. So you can see that zero divided by four, which is the first ID, will get zero remainder, so that'll get 100% strength of that scale or of that formula effector. Same with four divided by four or the fourth clone here. We'll also get that modulo strength or that formula effector strength and then, eight divided by four is two, no remainder, so that eighth clone, eighth ID will get that strength. So it's a little geeky, but it's a little easier to understand when you actually put this in practice, okay? So, what we can do is, maybe we divide this by six and you can see that we get every sixth clone, so this is very predictable. If I do three, that's every third clone, so very predictable when you understand what's going on with the mod formula here. So it's basically the modulo, understand the remainders, ID is the number of the clone, divided by, which is a semicolon four, and then if you want to just filter out and just apply the strength to the remainder, or the modulo, that equals zero, you can do that once you understand what modulo is okay? So, this becomes very powerful when we use this on say polygon selections, using the formula field, not just formula effector. So let's go into a different example here and here are some different setups here that I already have set up. You can basically see that okay, I have a bevel deformer and you can set a selection. So let's go ahead, so then add our selection here, let's just go to select and set selection and on that selection tag, I can say use fields. And here we can just delete that freeze field and use a formula field to control which polygons are being selected. So instead of clones, we can select every third or fourth polygon, okay? So let's go to formula field and in the formula field, you will see that there is this formula we have. So let's just go ahead and delete that and let's go and in this formula field, let's just type in mod, and let's do ID, colon, again we're dividing and then let's do, let's select every four, fourth clone, close parenthesis and then we'll just do the equal zero, okay? So if we enter that and then we go and we activate this bevel deformer and we just drag and drop that polygon flexion in there, you'll see that because we're using that formula field, selecting every other polygon, we can then bevel and extrude those polygons that we have selected, which is every fourth polygon there. So now we can go and you adjust the offset, we can go into our formula field and we can just adjust this as well, so let's see what every other polygon looks like so we'll put in a value of two and now you can see that we're getting like these cool little lines, so this is really great for, you know textural type of things. Let's see what three looks like, so every third, so that's every third, we get this cool diagonal kind of thing. Again, if we use four, that's kind of like a hexagon or honeycomb kind of deal and if we do five, we get something completely different, we get these cool stripes, so hopefully this gives you a very good idea of the different ways you can use modulo, not only with clones but also with, you know, mo extrudes and beveled deformers and stuff like that, very, very powerful stuff. So it is pretty crazy how if you just wrap your head around what modulo is and how to utilize this function, in different aspects of Cinema 4D, how powerful it can be. So I hope you found this week's quick tip a little useful, might've gotten a little bit too mathy, but I hope it's useful and I'll see you again next week. So you don't want to wait until next week to learn something new? No problem. Here's some other ways to feed your creative brain to keep you busy. You can check out my other courses in the Linked In Library, visit my website, eyedesyn.com for more tutorials, subscribe to my YouTube channel and be alerted when I post a brand new tutorial, join my Facebook for daily mo graph inspiration and keep up to date on all my latest mo graph creations on Instagram, thanks so much for watching and I'll see you here again next week.

Contents