Sunday, 15 December 2013

Car Rigging


Rigging the car without skinning can be a very fun and fast process if you know what and how to do. But if you don't it cant become frustrating very quickly, especially on the turning wheels.

In previous post we covered almost all our weapons. In this post I want to talk about two more. Very simple and lightning fast methods to connect attributes of different objects. And also how to lock and unlock attributes.

1. Hiding Attributes.

Simply select Attributes that you want to hide (so animator would not mess up your work) and Rclick -> Lock or Lock and Hide Selected.
But make sure that object was frozen before you hid the att. Because to freeze transformation you will have to get those attributes back and unlock them.
to do that go to Window->Genereal Editors-> Channel Control and move att back.





2. Connection Editor.

You select two object which attributes you want to connect and go to
Window->General Editors->Connection Editor
Here you can link any attribute of one object to any attribute of another, it's like SDKs but much faster and unlimited.

And a bit about limiting attributes, you can do that in Attribute Editor, under Limit information in Translate,Rotate or Scale relatively.

3. Expressions.


The most reliable thing in my opinion. I had so much trouble because I started using constraint on the front wheels and they messed up something in there. After breaking connection on the att (Rclick->break connection) constraint nodes stay in the outliner, so you need to delete them by hand, I didn't know that and had so many different hidden constraint in there no wonder wheel did this.

Maybe that was not the only reason why that happened. It is very important to keep your model clean, sometimes undergroups can be all clean, frozen, but the main group have some numbers. Amd who knows if it can affect your undergroups. Tu fix this issue I had to do some major cleaning, bringing back all the attributes to freeze transformation of the main wheel group, deleting all the constraints, checking everything 100 times. Then I decided to go 100% expression mode. Because they are fast, clean, and don't leave any nasty stuff after deleted.

to make expression you go to Window->Animation Editors->Expression Editor
You write expressions in the object that you want to control, not in the controller. But you will need controllers name.
So you select your controller,then att that will be controlling, in Selected object line you will get the name, copy it. Now go to your object, select the att that going to be controlled, paste into expression window what you copied from the controller, now copy Selected object and Attribute line and paste it before controllers name, hit space = and space again. So my expression for hood looks like that, notice that hood is selected, not the controller.

So rotation of the hood group on X axis is controlled by translation of the controller on Y axis.

What is *-25 you would ask, well that is the most awesome thing about it. Unlike connection of the attributes where you get 1 to 1 motion, in expressions you can multiply the effect if its not enough or divide it if its too much. You also can invert the motion by adding -. I used expressions for everything apart from mirrors and steering wheel (turn of wheels is controlled by expression). On them I used orient constraints, just for variation.

4.Combining curves.

One last thing, very useful. To create nice looking controllers you will need to combine curves sometimes. And for some mysterious reason Maya can't simply combine them, you can combine meshes but not curves, sometimes software makes you angry when simple things are made more complicated than they should be. It is still simple,but takes more time to do.

You create your curves,freeze transformation (this is very important, otherwise it will not work), then create a group in outliner (empty one), name it how you want your controller to be named e.g. Hood_ctrl, then in outliner go Display->Show Shapes. now open little groups of your curves and select shapes directly, select your empty group last. Now go to MEL and type   parent -r -s
Go to Display and turn off show shapes. Now you have your nice combined curve.

This was a long journey, but I liked it, though sometimes it tortured me. Learned many new things while creating these rigs.

The End.




Friday, 13 December 2013

Character Rig

With character rig it is very important to create a good base, good skeleton. You need to think very carefully about where you place your joints. First I made many mistakes with legs and had to redo them, placement of my joints was very wrong, and I forgot to orient them. When it came to skinning I also found out that I've chose not really best position for shoulder joints, that made skinning part harder. 
-So what is a good base?

1. Properly placed joints, and right amount of them. Make sure you made legs and arms bent slightly so when you add IK it will know to which side it should bend. To create a new pivot point for some group of joints simply select them -> Ctrl+G (Group) -> change the pivot to where you need it. That will increase the variety of movement that controllers will be able to create. Like Ball lift and Toe Roll.

2. All joints must be named, we already learned that while skinning the car. Order is very important, it is pleasant to work with a model that is well organised. It also looks beautiful :)

3. One more very important step in creating a good base i orienting your joints. This is extremely important, because after IKs are applied to skeleton joint can't be oriented. This is how I screwed up my first skeleton.
To orient joints select your bones then go to -Skeleton->Orient Joint Tool and set it as you feel comfortable to. I usually use world oriented.


The orientation of last joint, the end joint, is not important as it has no further bones and will not rotate anything. Orientation is extremely important at the fingers, make sure that your joints are properly aligned.
Otherwise you are going to get the effect of broken fingers when bend them.

4. Correct usage of IKs, IKR for legs and hands (goes from hip to joint and from shoulder to wrist) and IK Spline for Spine (goes from pelvic neck base joint).
To create IK you go to >Skeleton-> IK handle Tool -> IKR or IKS, other settings are like on screenshot below.

When IKs are on their place it is good to add Pole Vectors. They will not only allow you to adjust the direction where knees and elbows are pointing but with that you also will get the rotation of the whole leg and arm.


IKR is very simple and doesn't need an explanation.

IKS is pretty simple too. It creates a curve that will work as axis on which joints will bend. 
To help us work with IKS we've got tools like clusters.
Clusters can group several CVs of the curve, that way we are getting more of control over it.
Simply select two bottom CVs, go to Create Deformers->Clusters
Repeat same thing with upper two CVs.

5. Creating properly working controllers. That means clean history, frozen transformation (everything is at 0,0,0.) named and with pivots in the right spots. Some controllers need to be parented with others for a more comfortable use. 

This is a very nasty thing unless you know how to fix it. When all the controllers are parented to master controller to allow movement of the whole character figure, if you move it clusters will trigger this stretching.
to fix it, select clusters ->go to Att Editor -> and tick Relative.

I also had one more trouble with my rig. I am not sure what triggered that error, but controllers for the spine suddenly stopped working. They were moving clusters like they should, but clusters stopped moving bones. However if I would select the clusters directly and move them, they worked properly and moved bones. The simple solution was to create Orient and Point constraint from controllers to clusters.


That should be it for the base. Now when it is all nice and shiny we can start skinning. But first lets look at blend shapes and Set Driven Keys.

For facial expressions a decided to use blend shapes on this character. This is a very nice, simple and fast way. To create blend shapes we need to duplicate the mesh, change it (e.g. crossed brows) then select changed mesh, then shift select original mesh ->Create Deformers->Blend Shape. To access the blendshapes that you created go to ->

If you intend to create several blandshapes for one mesh and want them to blend between each other you need create all the changed meshes first, then shift select them with original mesh selected last and apply blendshapes. Otherwise, if you will make them one by one, it will create separate groups that can't be blended together.


There is one more tool that is very useful, Set Driven Keys. Unlike constraints or parenting this tool allows you to bind ANY! attribute of one object to absolutely ANY! attribute of other object. Isn't that absolutely amazing!? To open SDK go to Animate->Set Driven->Set. Then simply select your driver object and click load driver -> select Att which will controll, select driven object and click load driven, select Att that is going to be controlled. As you can see on the screen below you can set few driven objects, in this case joints of the finger.

To make it work you need to key them in default position (at 0) and then at changed position. Sometimes you will need to move or rotate driven object by inserting numbers directly in Att line instead of moving it by hand, because it can give different results (like rotation on all three axis when rotating just on Z)

I used SDKs in many places, one of them was head controller. I created new attributes for it (in channel box ->Edit->Add Att. Set it to min -10, default 0, max 10 if object is moving to both sides, like to the right,default,to the left. Set it to min 0, def 0, max 10 if it only moves to one side.)
These attributes had names of blendshapes, because I wanted to link my blendshapes to head controller for more comfortable use, I also united blendshapes like brows down and up in one Att.


Skinning
Now we really can start skinning.
-Some people may say that skinning is nasty process. But when all your bones are properly named and you remember all the hierarchy it can be even fun at simple areas like torso and legs. Though fingers can give you a bit of trouble. It wasn't that bad for me because I used popular this days technique where last three fingers are controlled by one finger bone.

We already learned how to apply smooth skin and use Component Editor with our car. But this time we will take a look at interactive skin weight painting and envelope technique.

- I preferred to start my character rig with envelope skinning first to get a cleaner base to work on. To apply it select top of the bones hierarchy, shift select mesh, go to Skin->Bind Skin->Interactive Skin Bind. Keep Max influence at 2.

I recommend to save it on your Quick Access panel (Ctrl+Shift+Rclick on Interactive Skin Bind)
That way if you accidentally will go out of this mode you just select mesh and click INB to return into envelope mode. 


Resize envelopes so the are not touching the parts you don't want. To do this just move the edges or use the move/scale/rotate GUI that you can see inside the envelope. Do not press E,W or R as it will go out of INB mode. The best thing about this method is that if your model is in the center of the grid it will automatically mirror it to the other side. Be quick with this stage, don't go too far, define just the major shapes.

When you are done, select the mesh, Rclick it and go to Pain Skin Weights.
Now you can adjust the Radius of your brush, radius of its fallout, and value of weight where 1 is 100% and 0 is 0%.

At this stage DO NOT! delete your history, unless you want to get rid of your skin weights completely :) .
Remember to save all the time. You also can export your skin weights by going to 
Skin->Edit Smooth Skin->Export Smooth skin Maps, resolution is number of vertices in your model. This can be a savior in some cases. It was for me as when I finished skinning I found out that Maya decided that I don't need my blendshapes and just deleted them. Even though I had all meshes saved, it would not allow me to to apply them again, saying Nondeformable object. So I just exported my weights, went to my older saves where I had both blendshapes and skinning on, and imported skin weights. 
Skin->Edit Smooth Skin->Import Maps, in files format select all files and choose document file, hit import. It will do it's magic and hopefully you will get everything in place. If not try to make sure that you entered right number of vertices on export, and remember that you still can paint out some minor errors. I had slight problem at the beginning, but that was because resolution was to small, why I entered the right amount of vertices everything was perfect.

Mirroring weights.

Another nice tool that helps you to finish things faster. Especially helpful when object is perfectly symmetrical.
YZ!! not XY
Even if object is not perfectly symmetrical it will mirror everything that is. For example in this case it didn't mirror the whole hand because they are different, however it mirrored the thumb :) 
Remember that you are not limited to painting, you still can use Component editor.

Remember when we selected Max Influence 2? It is good for making nice bend at knee and elbow.
Here is an example of how I painted leg. You can see that vertices, in the are where knee joint is, are influenced by two bones, upper and lower leg.

There is really no certain way to skinning, as every object can be a bit different, but it becomes easier to do with every next time. You just need to know how things must look at make your best attempt at achieving it. Make sure you not only paint it in one position, try moving rig, bend it, to see if everything folds nicely. To get back to painting simply select mesh-> Rclick-> Paint Skin Weights.

Finishing.

When your model is all skinned and you think 'this is the end!', there is one more little thing that need to be done. In order for blenshapes and skinning work together properly, skinning must come first in your Channel Box list. To do this you select the mesh->Rclick->Inputs->All Inputs. Here you Middle Click+Drag the blendshapes under skinning.

This is it! The character rig is done!









Skinning a car

1. combine mesh

2.Create Root_bone (name it)   Animation-Skeletone-Joint Tool
   - create all other joints from the root bone ( in outliner select the Root_bone every time before drawing a new joint) This will parent them to root bone
   - NAME THEM ALL!  This is very important, you will need those names when it will come to skinning


3. create controllers - Create-NURB Primitives- circle  (name them for each part)

4. when controllers positioned snap pivot of controllers to joint's centre where required and then Freeze transformation and delete history.

5. lock attributes of controllers that you don't want to be moved ( Transition/Rotation Y/X/Z exc. )
6. Select controller - shift select joint - use constrain ( when you you've done constrain joint must become purple every time you click on controller, if it is other way around then it means you've done constrain wrong. Parent must be selected first.)

7. When all the controllers are created, frozen with clear history and parented or constrained to the right joint, you can start skinning. But even when model is skinned new joint can be added and constrained to other controllers.

8. To skin the model select top of your joint hierarchy, then mesh, then go to Skin-bind skin-smooth bind. it is preferable not to select more than 2 Max Influences (that means one vertex can be influenced by two joints) But for hard surface it probably better to set it to 1.

Now when skin is applied the best way to skin hard surface object is with component editor. Select the vertices, e.g. all wheel vertices, then go to
-Window->General Editors->Component Editor
-there select Smooth Skin
- and set the influence of the joint you want to 1 (100%) and all joint you don't want to 0 (0%)
-not it's just a matter of time to finish it.




Friday, 27 September 2013

Constraints

There are 5 main types of constraints : Point (only mimics Translate attribute), Aim (where child aims at parent),Orient (only mimics Rotation), Scale (mimics uniform scale change) and Parent (mimics Translate and Rotate attributes). Unlike in Parenting in Constraints the first selected object becomes Parent, and also children can't move independently.




Unlike the parenting, constraints can be toggled on and off , it can be animated.

Thursday, 26 September 2013

Parenting

If you want to group things, parenting is the way to go. It is important thought to remember which object is parent (last selected object becomes parent after hitting 'P' key) because 'children' can move independently from parent, but when you start to move parent object all children objects will follow it. 
(to unparent hit shift+P)



Like you can see here, door is a parent for glass, when I move the door glass goes with it, but if I move glass,door stays on it's place.