'Maya'

 
'Modelling and Rigging a nut and bolt'
by Martin Andersson


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. If not you can go read about it here.

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.

 

 


Click for larger image

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.



Cedric_Seaut_Character_Modeling





Page 8


3D Total Homepage