Modelling and Rigging a nut and bolt
This tutorial will go through the steps to create a photo realistic model of a nut. It requires that you have some basic modelling skills.
There are a lot of different nuts out there and you can use the same method creating them all. I'm going to model the one in the image
You can use this reference image that I used to follow this tutorial or you can use your own reference and just stick with my method if you like
1 - The image's measurements are 68 by 96 pixels.In Maya create a pPlane (polygon plane) and rename it "pReferencePlane".
Rotate it -90 degrees in Y and 90 in Z. Move it -6 in X.
Under INPUTS type in Width 6.8, Height 9.6 and set both subdivisions to 1.
Create a lambert and call it "lambertRefrenene".
Double click it and click the checkerboard to the right for the color attribute. Now choose file and browse to the gif above. (Since it's a gif Maya will make it transparent for us too)
Now apply this material to the plane by middleMouse-draging it onto the mesh or by selecting the mesh,rightClick the material and choose "Assign Material to selection".
Now I want to set up some 3d reference. "huh, 3d reference?" you might think, but I like to have a visual of how the mesh will look so I use NURBS to "cage" the model. In this particular example I also need a place-holder to help me place the pivot of my NURBS objects. Sounds confusing? Well, it's not. I'll do it step by step below. Important: Make sure you don't move anything away from the worldspace origin!
2 - Create a cylinder and set subdivision axis to 6. Scale this up to match the size of your reference.(It's still important that you remain in the origin). Now use the sideView to draw the countor of theflat side of the nut facing the camera. I use EP curves to draw these. The top- and bottom curveare drawn with the curve degree setting on 1
linear while the other ones were drawn using 3Cubic. When you have drawn this, group the curves and call the group "nurbsGrp". It's important that you draw the top- and bottom curve to match the geometry of the cylinder and not the reference image.
Move the group so it allignes with the side of the polygonCylinder.
Now we can snap the pivot of the group to the origin ( 0 0 0 ) To go to pivot mode press "insert" on your keyboard (above Del) To snap something to the grid you hold "x" while dragging the item you want to snap with the middle mouse button. When you're done, hit "insert" to go back to default mode.
3 - Hint: You don't have to press insert to go into pivot-mode. Hold "d", then hold "x" and do the same operation as above. When you release "d" you'll go back to default mode again.
Now I want to duplicate the NURBSGroup 5 times to get the rest of the "walls" for my nut. I select the group and go to "Edit Duplicate". To the right of "Rotate" you can see three floatFields. These represent x, y and z. I want to rotate the new duplicate 60 degrees in my z- axis. I type in 60 there and I also type in 5 in "Number of copies". 360/6 = 60. There are six sides on this nut so I need five more and they should rotate 60 degrees because there are 360 degrees in a circle.
Remember to go into the duplicate Options and reset the tool for future duplicating :)
I have used NURBS Circles to draw the contour of the rest of the nut. I placed the circles where I found it reasonable to have them since I do not have a top reference for this one.
If you want to have red circles like me, you simply select one and go into the attributeEditor.
Under "Object - Display Drawing Overriders" you can check "Enable Overriders" and choose a color on the colorSlider.
Note that "caging" a model like this is not necessary, but when I don't have any deadlines I like to do it to get a total impression of how the model will look. It can also help you plan where to put your edges and therefore give you a good polyCount. These NURBS Curves can be useful for snapping later because you can snap vertices to curves. But once again, if you have a tight deadline, don't bother doing it.
Enough NURBS- talk. Let's jump over to the polyModeling. Talking about NURBS tend to get people puking.
4 - This is the time when you choose between using a pPlane or the "create polygon" tool. Last time I did this model I used "create polygon", but this time I used a pPlane and to be honest, using the plane is less timeconsuming. By default Maya creates a plane with a subdivision width and -height of 10. We only need a width of 4 and a height of 1. Rotate the plane -90 in Z.
When I created this plane I noticed that my NURBS-cage and my referencePlane was a bit off the origin. I moved them so the new plane hit the curves in the corners. It's more important to have the new plane in the origin than the cage and the reference
When adjusting the plane, try and get the same height for all the faces.
We want the mesh to be perfect before we move on. When you feel that you have done a good job here scale it down a tiny bit and select all the outer edges. Extrude them so that the new edges fit the cage again (Edit Polygons Extrude Edge) Make sure you're in modeling mode (F3) to get to the "Edit Polygons" drop- down menu
As you can see on the image above, I duplicated the new plane (from now on renamed pNutWall) two times.
One to be rotated down and one to be rotated up. My plan is to only create a cake slice and duplicate it 5 times to merge the whole mesh (just like I did with the first NURBSGrp) The reason I duplicated these two is so I get to see how the top and bottom on the pNutWall have to look like to smooth correctly 'cause trust me, the way it looks right now will not result in a pretty smoothing.
I will combine (Polygons Combine) these three three walls and merge (Edit Polygons Merge Vertices) the vertices that overlaps each other so I have one mesh to work on. I would like to have direct feedback on the smoothing so I create a smooth proxy.
"Polygons Smooth Proxy".
Reset the settings in the optionBox (Edit Reset Settings) and under the frameLayout "Display Settings" choose Smooth Proxy Shader - "Keep". Then hit "Smooth".
The first thing I'm going to fix are the corners of the walls. Because the extruded edges earlier was extruded out from the center and I want these to go as a loop throughout the mesh, I use Split Polygon (Edit Polygons Split Polygon) to take the edge further and then I delete the old edges going away from the center
Note that you only have to tweek the wall facing your sideView. The other two are going to be deleted later anyways. Check if the mesh looks ok and select the border edges. You can use the Select Border Edges tool to do this. Works like a charm. (Ctrl + Right-click over the mesh and select it there.) We are going to extrude these edges inwards to create the start of the top of the nut. Just drag the blue arrow after choosing Extrude Edge under Edit Polygons. Merge the three vertices that intersect eachother in the corners. See images below (clickable for larger view).
5 - Now we're going to do a little cool trick. It's actually not that cool really, but we'll do it anyways :).
Remember the cylinder we created for additional reference? Well, select it and set its Subdivision Axis to "18" . " 18/6= 3 " you say "and we have four edges on each wall? Hmm." Hang in there, we'll make sure the wall only needs three edges to connect.
Scale it to fit the circle representing where the hole will be. If you skipped the "caging" scale it up to where you think the hole will be and make sure you follow the reference when you set the top and bottom of the cylinder.
Let's go back to the nut for a second.
Delete the top- and bottom walls so you're left with the one facing your sideView. Use "Split Edge Ring Tool" to split it in half vertically. Press "enter" to finish the tool and click "polySplitRing1" under INPUTS in the channel-Box . Scroll all the way down and change the attribute "Weight" from whatever you got to 0.5. Now select the faces on the right side and delete them.
6 - The smooth proxy will stop updating when we start doing ninjatricks on our mesh in the following steps. You might as well delete it.
Select the two middle edges on the side of the wall and extrude them out a bit. Select the three newly created vertices and scale them in the Z-axis so they allign. Move them to match the first NURBS circle.
Select our wall and duplicate it 5 times with a rotate of 60 (just as we did earlier). Select all of the walls and combine them. Merge all the overlapping vertices. Now you're left with a funny looking mesh. You have the walls and then you have these faces a bit in against the center. Use the "Append Polygon" tool to create a polygon where these gaps are. On the image below-left you can see one of these faces marked orange.
Now snap all the vertices representing the new hole to the cylinder, (hold "v" and use MMB to snap) scale - and move them back out to their starting- position. We do this to get the right topology. We want the hole to look like a circular shape just like the pCylinder's top. Also, the "Split Edge Ring" tool will not work here so if we kept the vertices by the cylinder we would have to cut manually to insert more loops. Now we have the perfect cylinder form so we can just extrude the edges inwards
OK, before we go on I'd like to ask you a question:
"If you stand behind a Lightwave user showing off a model, what does he do?" Lightwave- people have one favourite key they use all the time. If I handed you a keyboard and told you to tell me if this keyboard belonged to a Lightwave user you could probably determine this by looking at the tab-key. If this key is more worn out than the others... That keyboard belonged to a Lightwave user :)
Since our smooth proxy abandoned us earlier we will set up a key like this on our own. We will create a
hotkey that smooths the model when we press it and unsmooths when we release it. Similar to how the tab-
button works in Lightwave. (Note that I have never used Lightwave, but everyone knows what tab does
because of these strange people)
- Open the Hotkey Editor (Window Settings/Preferences Hotkeys...)
- Under "Categories" scroll down to "User" and on the far right press "New".
- Give it a name (e.g. LightwaveKickAssButton or pSmoothUnsmoothPress)
- Write this into the command-field
Then click "Accept" and the recently created command is listed under "Commands"
Assign a hotkey for this operation and make sure "Press" is selected (I assigned mine to |)
Create another command called pSmoothUnsmoothRelease or something similar. Type this into the command field
- Assign it to the same button, but make sure "Release" is checked
What we just did was assigning two different commands to the same key. When we press this ( and hold it ) the model will smooth. You can still navigate, just press alt+mousebuttons while holding the button. When you release it the model will unsmooth. Pretty clever huh? :) So whenever you want to check your model, hit "|"or the other key you assigned it to.
7 - Now select the borderEdges and extrude them four times. (or less if you don't want the nut to be too hard ). Use all views to get a smooth and nice creasing from the walls to the center. You'll probably have to tweek a lot to get it right, but with our new hotkey you'll be able to see the results fast :) When modeling this part the nurbs cage is actually quite comfortable to have as an additional reference.
When you're done tweeking it's time to finish this half.
Select the borderEdges where the hole are and extrude them once more. Move them a tiny bit in the z- axis and scale them down a tiny bit too. This is just to get a nice crease there.
When you have done this go into your sideView, select all the vertices to the right and scale them in the Z- axis. Make sure you move them so they allignes with the grid at Z=0. To allign with snapping, hold "x" while draggin the z-axis on the move tool. You will see that all the vertices snap in that direction.
Below are how mine looked after the last operation. And, hey... It even looks good smoothed.
If this nut was supposed to be screwed around a bolt or if the inside was not supposed to be shown, we'd be finished by mirroring this model. We're going to mirror it, but we're also going to model the tracks on the inside...Displacement is for weaklings.
Mirror the geometry by duplicating it (Check your settings, your last duplicate involved 5 duplicated. You might need to reset it) scale it -1 in Z and combine the two meshes. Merge the vertices in the middle.
Now, since we're going to model the tracks I want you to split the inside 6 times. To get even results use "Split Edge Ring Tool" to split to the left and right side of the center edgeLoop and under INPUTS set the Weight to 0.5. Then you split between the new lines and the center to split this row of faces in half too. Continue this till you hva 7 edgeLoops on the inside of the nut. When you have done that your mesh should look a lot like this and you have eight rows of faces to work on.
The tracks isn't straight so we have to cut it to get them diagonal. I'm going to cut three faces per edgeRing. Let me use a cube to illustrate how I'll proceed with the cutting. Use your favourite splitting method. I used Split Polygons and under INPUTS I set the weight to 0.66 and 0.33. Note that when you split the upper half you get 1.00, 0.66, 0.33 and 0.00, but when you cut the lower half this tends to flip so it reverses the order to 0.00, 0.33, 0.66, 1.00. So when you cut, try and cut somewhere near where the cut is supposed to be so you're not stuck with 0.55778 everywhere. It'll get bitchy when you're going to tweek the inputs
And this is how the first split will look when splitting the nut: ( Selected edges are the ones I want to delete ) It's easier to do this operation if you rotate the nut 90 degrees in the x-axis because orientation is a bit tricky when the nut is standing like it does now
And here is a sideview wire. You can clearly see that this is the track we want.
Now all you have to do is split up the whole thing. When you delete the edges crossing the newly created spiral, you'll be able to see where the next split should go. When you have split one spiral go back up to where it started, cut a new spiral on the edge right below and do a second split. When you reach the bottom go back up to where you started the second split and cut one step backwards. ( Notice that I do not cut the top- and bottom edge-ring
When you're done splitting remember to delete all the vertices that are left after deleting the horizontal lines intersecting the spiral cutting. Go to vertex mode, select the whole mesh and hit "del" on your keyboard.
Now it's time to extrude some tracks. Select every other row of faces and extrude them. It's important that when you hit extrude you use the manipulator tool to move and scale the extrude and do not hit "w" or "r" to scale it globally. Because you want to extrude locally, you use the manipulator tools that appear when you click "extrude". Use the z-axis to move and the y-axis to scale. Extrude and move several times to get a sharp edge.
You're done! I think the nut is a bit thick following this reference so I scaled it a bit. Originally I was going to end this tutorial now, but I just couldn't help myself... When you have modeled a nut, you have to model the bolt too... OK, let's go (bonus feature, wee) I had to dig up the reference for the whole thing now, so here it is.
Duplicate the nut and move it 8 units in the x axis.
8 - The head of the bolt will look very similar to the nut we've just created. The top will be exactly like the nut's,but the side where we want to extrude the bolt itself is flattening out. First you delete the inside ( where the tracks are ) and then you select the edgeloop that's just standing there wondering what it's suppsed to do. Now extrude this loop inwards and merge all the vertices that meet in the center.
On the other side of the head you're left with a big hole. We have to flatten this side so we get something like the reference image above.
Delete the loops you see above-left and do not forget to delete the remaining vertices. Then you scale all the loops together so we can get it flat like we so badly want. I urge you to do one loop at the time so you don't overlap etc. When you have all loops perfectly aligned (you can select all the vertices and grid-snap them in the z-axis. Then you move them back to where they are supposed to be.
Leave the loop to the left on the image below and scale the loop to the right in so we get sharp edges here.
You can do an edgeRingSplit or two and drag the loops to the top and bottom of the head to get even nicer looking edges. Now we're going to focus on the thread for a while. In Maya 7 they were nice enough to include a new primitive called helix.
NOTE: When I started writing this tutorial I didn't know that I was going to model the bolt as well so I didn't take that into consideration when I decided how many tracks I needed inside the nut. As you can see on your own model, we only have three, but if I were to do it again I would have created twice as many. You'll see why in a bit.
Create a pHelix and rotate it 90 degrees in the x-axis. Leave the pivot alone. We want it to be where it is. We want to create one coil and duplicate it how many times we need to complete the bolt. These are the inputs I had to insert to get it to fit in the tracks I created earlier. I also had to move it a bit to get it to fit, but I'll move it to tZ = 0 after I nail the size.
Hide the nut so you're left with the helix. Now I want to create the pattern of the typical American bolt out there so I have to do some manual tweeking to the helix. This is the pattern I'm creating.
- We don't need the two inner edgerings so delete all those faces and delete the two ending faces.
- Select the edgeloop representing the back of our helix (just look at it as if it was a snake) and bevel it. Edit Polygons Bevel.
- The bevel willl make the height go too much down so we need to select that edgering and scale it a bit to raise it. Because you don't want to raise it in all axis, just x and z, you hold ctrl and drag the y-axis when you're scaling. This way Maya excludes this axis and scales the other two.
- Use Maya's split edge ring tool to create two loops to sharpen the top of the thread.
- Select the outer edgeloop and extrude it once just a little bit and then almost all the way over to the next ending of the helix aaaaand then the final tiny bit to hit the mesh. Merge the vertices where you intersect. See the image below for an overview
This will be the base we can copy several times to get the whole bolt. Duplicate it once and move it 1.52 in the z-axis. You'll see that the duplicate lands exactly where the other stops.... Why is that? Because the height of the helix is 1.52.
After merging all the overlapping vertices you see why I went "Ohhh, maaan!" when I realized I had to few tracks. The distance between the threads look stupid.
Therefore I created a new helix with half the height (0.76) and with the same method I created a more correct thread.
When you have created the helix, done all the tweeking above, duplicated, combined and merged you'll have a new mesh you can duplicate. Move it twice as far as last time (for me that was 1.52 this time. If you're still following the older tutorial it would be 3.04) and combine, merge and duplicate again. Now move it four times as far etc. etc. and you'll have this thread up in no time.
I need to figure out how to end this thing now. Both sides will go over to a solid cylinder. Once again I'll use a good old friend of mine called placeHolder. I move him over to the end, scale him to fit and move him where I want the end to be. Now I'll have to model it to fit the placeholder.
It's kind of tricky to get it to round off and stay good looking, but we know how don't we? Well, if not, we will soon... I'll take this part step by step: (images dealing with this section below are clickable for larger view).
Delete these edges and also delete the vertices they leave behind.
Select the outer loop except the one where our ending thread is connected, scale them all together in the z-axis and move them out a bit.
Merge these vertices.
Select all the edges at the end of the end thread and extrude them.
Split the polygon you almost intersect and move the vertex below it to give room to the end thread.
Now move these vertices to get them to fit the mesh more.
Use append polygon to cap the hole we're left with.
since we've been merging vertices etc. here now, the mesh can get uneven again. Select the edges we used earlier to scale this thing together and do it once more. Scale and move so it straightens out.
It's time to connect this mesh all together. We need to get it ready so use split polygon like I did on the image below.
Now merge the vertices right by each other so the mesh gets closed and use append polygon to close it entirely It's time to move the vertices around shaping it like the image below. When you do this you can see that the topology isn't all that great. We'll fix that in abit.
Now use the split polygon tool and delete the edges going up till you get something like this.
That's basically it. If you smooth this one you can see that this is a mesh we can live with. Feel free to tweek it to get it even nicer looking.
All you have to do to finish the end now is to select the edgeloop at the edge of the whole thing and extrude them a couple of times. Shape it like this. All the vertices you get in the middle here while scaling should be merged together
I realize writing a tutorial while you model is not the way to go. I am going to delete half of this mesh to duplicate it, scale it and rotate it. If I used my head before going on I'd just model half of it so I wouldn't have to delete one half now... But what's done is done. Let's just fix it. I delete half of it and duplicate the part I'm left with. I scale it in negative -z and negative -x. Then I rotate it 180 degrees in z and it fits. All I have to do now is to merge the overlapping vertices and tweek the top to be able to attach it to the head.
I'm ready to combine and merge now.
Voila, we did it. Now we have modeled a nut and a bolt to go with it.
Who's up for rigging? :) I sure am. I won't rig this with all the controllers necessary for it to work in all ways. I just thought it would be fun to make a slider that controlled the nut going up and down the bolt.
9 - To get ready for rigging, delete the history for both objects, center their pivots and move them to the origin.
When you have them where you want them, go to Modify Freeze Transformations (Make sure none of them have a rotation in the z- or x- axis before you do this...).
I also want you to select the nut and group it with itself. Rename the group "pNutOffsetGrp". Group this group once more and rename it "pNutConstraintGrp". I'll explain why later.
I also cleaned the scene for all the other stuff we won't be using no more. Reference,nurbsCurves and even our favorite.. the placeholder. Delete all the layers too.
Use topView to draw a curve over the distance you want the nut to travel on the bolt.
10 - Then create a locator and remane it "lNutLocator". This locator will travel up and down our curve and the nut will be constrained to this locator later.
Select the locator and then select the curve. go to Animate Motion Paths Attach To MotionPath. Reset the settings in the optionbox and click Attach.
Don't worry about the settings here really. We're going to break them down to fit our needs anyways.
How does a motionPath work? Well, a motionPath is a curve that works as a path for whatever you want.
The motionPath has a value called U Value that controls the distance traveled. 0 will be the start of the curve and 1 will be the end. You can not exceed these values. Maya will simply ignore higher or lower values. A value of 2 will still represent a value of 1. (end of curve ) and a value of -1 would not get the locator further than the start of the curve. Use topView to draw a curve over the distance you want the nut to travel on the bolt.
11 - Now we're going to do a bunch of stuff :) Start by creating a nurbsSquare or just draw one with the EP-
curve tool. I drew one. Make sure you center the pivot and snap it to the origin. My top and bottom vertices were at -10 and 10 in the z axis. To set the values like that simply select the vertices and click "CVs (click to show" ) in the channelBox. Call it "cSliderArea"..
Create a pCube. This cube will represent a slider we will use to slide the nut up and down our bolt. Call it "pSlider". You should open the attributeEditor and uncheck primary visibility so it doesn't show up in renders. (pSliderShape1 under the Render Stats tab).
Group pSlider and cSliderArea (the square) and rename it "sliderGrp" Move it a bit to the left or right of the bolt. Set the translate limits for the cube to -10 to 10 in the z-axis. (Open the attrEditor and look in the Transform Attributes in the pSlider-tab).
To constrain the nut to the locator simply select the locator and then the "pNutConstraintGrp". Go to "Constrain Parent" and uncheck maintain offset. By unchecking this we make sure the object we want to constrain snaps to the pivot of the object we want to constrain it to. So now the nut snaps to the locator. Notice that it doesn't face the right direction. We obviously want it to face the head of the bolt.
To tweek things like that you can't move the object around. If you select the pNutConstraintGrp you can see that the attributes for translate and rotate are light blue. If you rotate the group it will snap back when you step a frame back of forward in the timeline. I created two groups earlier. A constraintGrp and an offsetGrp. We could use the offset group to rotate the nut, but we're not going to in this occasion. You see, when we create two groups like this we make sure that the top one are constrained. This group will lose it's movement possibilities, but the group below will be able to translate and rotate. If we didn't have an offset-group we would have to move the geometry itself and we don't want that.
However, this time I want to fix this little challenge by using an already built in attribute in Maya. Select the motionPath and under OUTPUTS click motionPath1. Here you can see U Value and a couple of twist attributes.If you taka a look at the U Value you can see that it's colored. This is because it's keyed to the timeline I had when I set the motionPath up. By default Maya keyes it like that.Right click it and choose Break Connections. We want to connect this value to the slider we created.
Use the twist attributes to twist the nut back into place. I had to set "upTwist" to 90. I'm going to use "Set Driven Key" to make the slider control the U Value. If you have read my tutorial on driven keys you know how this works.
This time neutral is not 0 for the motionPath and the cube. It will be for the cube, but when the cube is at 0 the motionPath is at 0.5 so this time my lines of MEL-code will look like this.
setDrivenKeyframe -dv 0 -v 0.5 -cd pSlider.translateZ motionPath1.uValue;
setDrivenKeyframe -dv -10 -v 1.0 -cd pSlider.translateZ motionPath1.uValue;
setDrivenKeyframe -dv 10 -v 0 -cd pSlider.translateZ motionPath1.uValue;
Well, it works, but it looks stupid when it's not rotating... We need to get the nut rotating while translating. Since we created an offsetGroup we could use this, but I want this group to be an open group to the animators so they can use it to whatever they want. Instead I'm going to select the offsetGroup and group it once more to create a rotateGroup. By doing this the constraintGrp will handle the constraint, the rotateGrp will handle the rotation of the nut and finally the offsetGrp can be used to offset in general. The reason I want this group is that, by experience, I often need to offset things that get constrained here and there. It feels good to have additional controls.
12 - Select the offsetGrp, group it and call the new group "rotateGrp". I did a little test and found out that the nut may rotate 1020 degrees on it's way up. You can see a clip here showing how that will look. ( I used colors on the sides of the nut to see the rotation better
To download a movie clip use this link
At first I was thinking that I would solve this with an expression, but now that I know the exact value I want I think I'll go for another Driven Key on this one. Now I'm going to let you guess what that line of MEL-code will look like... ;). If I want to be able to take the nut off the bolt, I'll need a control for that too, but as I said earlier I just wanted a slider for fun.
I think it's time to stop this tutorial now... It's already gone way out of hand. I was only supposed to model a nut:)... But I hope you've enjoyed the read.