• In this tutorial we will continue our work on the robot's left leg.
  • Maya
    Autodesk Maya
  • 13m 49s
Let's continue rigging our robot's leg. So at this point we can reorient each of our leg joints. So I'll show you the manual way, and then we'll use a script to get it done a little bit faster. All right. So the first thing we'd want to do is select each of these. And go ahead and show their local rotation axes. So we can do that under the display menu, transform display, local rotation axes. I'd recommend adding it to your shelf, so let's go ahead and do that. Simply hold down CTRL-Shift, and click the tool. All right, So we can go ahead and turn those on. If you can't see them, just head over to your show menu. Make sure you have handles on. All right, so at this point we can decide the orientation we'll use. I'll just work with the default XYZ that comes default with the joint tool. All right. So with that said we can reorient them using our aim constraint tool. Making sure that the settings reflect the behavior of our joint tool again by default. All right, so what we'd want to do is first select our target joint. The joint that we'd like to aim at. So that's going to be the knee. And then we would grab the source joint, the joint to change. So at this point we can head over to constrain, aim. Go into our options, I will reset the settings. And just go ahead and choose add. So you can see now the x is going to point down to the knee as it should. So what we'd want to do from here is get rid of the aim constraint. I'll just go to the outliner for that. And now selecting our joint that has been reoriented, we now need to make sure that the joint has been oriented properly while leaving our rotation clean. We want to make sure our rotation is as clean as possible. So when this rig is to be baked down, if you decided to take that route, it's a lot easier to read animation in your graph editor. All right so to have that happen we want to transfer these values from the rotate channels to our joint orient channels. More importantly, we'd want to first make sure our joint orient channels are zeroed out. So the joint gets reoriented properly. So I have a script that we can use to get this done just at the click of a button. Then we'll take a look at another script to not only reorient the joint, but then it'll go in and swap our values and clean up our rotation. So let's head over to our script editor. And we can go ahead and clear our history. I'd also recommend under the history menu to go ahead and turn on line numbers and errors. So just in case as you're building your scripts if you encounter a problem we know exactly where it is happening. All right? So now we can go ahead and head over to File. Choose Load Script. Again, we'll go to our scripts folder. And we're going to want to load in the Zero Joint Orientation tool. So we'll go ahead and choose Open. So just to read the code, what it does. We first grab our selection. And if you notice, I'm using a different variable for the selection here as opposed to what we used before and what we will use. It's a good idea to use variables that are unique, even if it's the same command, this is just so you can keep track of what this variable does as opposed to another. All right? So JNT is going to find our selection, and then following that, we find any aim constraints that are tied to the object. We did have one at one point, but it has been removed. And if there any aim constraints it will go in and delete the aim constraint. And then following that it will transfer the values from our rotate channels to our joint orient channels. So what we find here, at the top, is our getAttr command. To grab the value of our rotate channels. So you can see the get adder of our selection will find our rotate X, Y, and Z. And then we use setAttr to set the joint orient attribute. OK? Set our joint orient attributes to the getAttr variables. So X, Y, and Z. And then, lastly, the code will go ahead and 0 out our rotate attributes. So since we already deleted the aim constraint on this you may get a warning that just says it's looking for an aim constraint. But this code will still work. So I'll go ahead and highlight everything, and add it to the shelf. We can go ahead and rename this to 0 joint tool. The tool tip. You can always use the same name as the tool if you like it. Or you'd like to get more descriptive you most certainly can. Now go ahead and rename the icon to ZJT. Save all shelves. All right, so let's go ahead and take a look at this. With the joint selected that we've reoriented, if we were to go ahead and run our tool you'll see that the joint has now been oriented to point at the knee. You'll also see that its rotation has been cleaned up. Those values have been transferred to our joint orient channels. All right, great. So before we finish off it's a good idea to just clean up the orientation a little bit more, which we may need to do. So in this case we do need to do that. Just need to have Y point forward, and follow the angle of the thigh. Just so that when we start to animate the leg it's, again, a lot more convenient. Our preferred angle is exactly the way we it to be. All right? So what I'll do here is go back to the attribute editor. Now just ahead and hold down CTRL over the X channel, joint orient X, and start to twist that so that Y is pointed forward. So in my case it's about a value of 67 or so. That'll work fine. All right, so that's one joint down. Let me go ahead and show you how we can get this done a little bit faster. Let's head over to our script editor again, and we'll go ahead and load in a new script. So the next one we want to find this one is going to, again, reorient the joint and clean up its rotation. It's [? ORY, ?] JNT, XYZ. So let's go ahead and choose Open. So just to read this back what we do is use what we call a procedure. And here's the procedure's name here. We're going to tie that to a window, which we'll see at the bottom of the code. But we get our selection, and then we check our selection. We need to have two objects selected. If we don't have two joints selected we'll get a warning. And then following that we first make sure that the joint is oriented to the world. All right? So we set our rotation and joint orient attributes to 0. That's what the first part of this code does. This is so that the joint will reorient properly when we use the aim constraint command, which is what follows next. So here's our aim constraint. All righty? And then following that we use the less relatives command to find the aim constraint on the second selection. Which is our source joint that we'd like to reorient. And then we delete it. And then following that we go through and we swap our values as we've done before. So we use the getAttr command as we saw before. Then we replace that and add that to our joint orient channels, and then 0 out our rotation. And then following this we just create a window at the end just to have something that pops up. So we can use that to run the tool. So there's our window command, here's the name of the window, and we make it adjustable, and here are instructions. First, select the target joint to aim at. Then the source joint. Then we create a separator just to organize things a little bit more in the window. We create two buttons. One to apply the tool. Here's our procedure that we saw at the top. So once we click Apply this is the procedure that gets run. And then we have a button to close the window, which is simply the delete UI command followed by our window name. And then at the end of this we show the window. All right? So let's go ahead and highlight everything, add it to our shelf. We want to say organized, so we'll go ahead and rename this tool. We can always rename this to orient joint XYZ. And I'll use this name as the tool tip. And then at that point, we can go ahead and rename the icon to JXYZ or something along those lines, and choose save all shelves. All right. So let's go ahead and run this. You'll see a window pops up. All right, so now it's just a matter of first grabbing the target joint. The joint to aim at, which is the ankle, followed by the joint that we'd like to reorient, which is the knee. And we choose apply. Not only has it gone ahead and aimed the joint, but it has cleaned up its orientation. All right? So at this point we just need to fix the twist axis of this knee, so that the Y is pointed forward. If we were to take a look at the thigh you see that it's about a value of 67. So if we were to go to the knee we can start with that value of 67. And that'll get us most of the way there. We might want to bring it in just a little bit more to about 72 or so, but that looks pretty good. All right, great. So this point now it's just a matter of parenting these together. So I'll go ahead and grab the ankle, parent that to the knee. And the knee will have parented to the thigh. Now what about the orientation of the ankle? Well what we could always do with this is go ahead and clean this up using our 0 joint orient tool. And we'll get a little warning. We also have a script to clean up the joint without looking at any aim constraints. So in this case we didn't need a name constraint for our end joint. All we did here was 0 out our rotate channels, and also the joint orient channels. So that the orientation of this matches its parent joint. All right? So we have a script, also, that we can use. We'll take a look at that little bit later. If we're just cleaning that up without looking at aim constraint as the [? ZJNT ?] tool does. All right, so we have our leg joints built. And this is a good start. We're just starting from the foundation of this rig, and then we'll add whatever auxiliary controls we will need after we're done with the base rig. All right, so if you like you can now go through and rename these joints. So just to give an idea of the naming scheme, we do have a renaming tool. It's pretty basic, but I like to use it because it just helps us to use the exact name we'll need for each object. And it helps renaming go by a little bit faster. So we'll take a look at that in the next lesson. But for the thigh we can go with something along the lines of JNT_L_Thigh_01. I'll copy the name, and use that for the knee and ankle. So this is going to be knee, then following that we can go ahead and rename that the ankle joint. And we're good to go. All right, so the leg chain has been created. Let's go ahead and stop the lesson here. And the next lesson we'll work on the toes.
In this tutorial, we will learn the methods that were used to rig the transforming robot. Throughout these lessons, we will learn the tools and techniques used in the setup process of both our robot and truck. The goal is to break this complex idea down into a simple, and manageable form. We'll cover the rigging process in its entirety, and along this journey, we'll be introduced to several tools that will help make this all come together efficiently. By the end of the course, you'll have the set of skills needed to rig your own transforming robot.
Partner
Partner