Thursday, February 10, 2011

Animating with Deformers in Maya

Although animating with deformers is a commonly used technique in the VFX industry, a lot of people don’t know about it’s benefits. Well, after this tutorial that’’s going to change. We’ll be looking at how to animate complex expressions with deformers, along with why they can be extremely useful. Enjoy!

Step 1

First of all, open Maya and import your model. For this tutorial I’ll be using a version of ZBrush’s standard head model as it will help to easily show the main benefits of deformer-based animation, however this technique will apply across all models no matter how complex. Now go to the front view, duplicate your model (Ctrl+d) and rename the new copy. Be sure to use a descriptive name as this will later become the name of your blend-shape – in this case, I’ve used Male_Head_Smiling. Position both models next to each other to make things easier to work with. Now I’m going to actually deform the second mesh to make it smile!

Step 2

First we need to setup our mesh selection tools. In the top menu, go to Modify > Transformation Tools > Move Tool > Option Box. Turn on Soft SelectFalloff radius. This is, of course, a relative value due to the fact the every model you work with will likely be different in size. In this case I want to select an area just large enough to move the cheek a little bit to create the realistic effect I’m going for, so have chosen a value of about 0.35. Now turn on the Reflection setting, lower the Tolerance to about 0.04 and set the Reflection axis to X. This enables us to easily make the same changes to one side of the model as we do on the other, saving us time! We can now start deforming! and set the

Step 3

Next, right-click on the model and go to Vertex mode, which will allow us to move the vertexes instead of the mesh itself. As I’m intending to make the model smile, I’m going to be affecting the vertexes around the corners of the mouth, so I start by dragging a selection from the right corner of the mouth, slightly to the right and then slightly upwards. As you can see below, both sides of the model are affected because of the Reflection setting we previously enabled. The brightly colored areas represent the extent of our falloff.

Step 4

So with our vertexes selected, and with our falloff in place, now activate the move tool. To make this model smile, I needed to move the affected verts slightly to the right and slightly up, and with a little bit of trial and error, this is my result :

Step 5

Now that we’’ve got our original model and our deformed model, we need to create the blend shape deformer itself, so first select the Animation menu-set and then in the top menu choose Create Deformers > Blend Shape > Option Box. In the background, first select the deformed model (in my case the smiling man), then shift click the original model (it’s very important to select the model you want to have the blendshapes implied to last of all.) Enter a name for our deformer in the BlendShape node box, for instance something like Smile.
Now we come to a very important setting – Origin. The default setting is Local, and although you may need to choose World for some rare circumstances, the Local deformer the most useful one. Just to cover it quickly, if you set the origin to World, all deformations are created as relative to the model, meaning that if you move the model around the scene, the won’t move with it! So, for now we’re going to stick to the Local setting. Leave the other settings as they are and then click Create.

Step 6

To use the blend shape we’’ve just created, go to Window > Animation Editors > Blend Shape. You should now have a single slider there (in my case Male_Head_Smiling) and if you move it up and down you’ll quickly start to understand the advantage of animating using deformers – if you move the slider halfway, you see a mix of both models, meaning that with a few blend shapes you can create literally thousands of expressions!

Step 7

To do a little animation test, go to the first frame, move the slider all of the way to the bottom and click Key. Now move forward a few frames, move the slider to the top, and click Key again. If you play back the animation you can actually see the mouth moving.

 You can actually add as many blend shapes together as you want, so I’m going to add another one to control my model’s eyebrows.

Step 8

Start by duplicating your original mesh, moving it over to the left of the original, and renaming it, in my case to Eyebrows. Now repeat step 3 as above. This time I moved the area above the eyes downwards slightly, ensuring the eyes themselves remained untouched. Now go to Create Deformers > Blend Shape > Option Box, and select first your newly deformed mesh, and then shift-click the original. Give the blend shape a name and then click Create. On returning to the Blend Shape editor you can see we now have two sliders, in my case one for the mouth and one for the eyebrow expressions.

Step 9

To have more control we can do something else that you may have seen before – interactive controlling. Interactive controlling uses geometry ‘rig’ to control the motion of the blend shapes – something that can be very handy for facial expressions!
In the top menu go to Create > EP Curve Tool, and draw a curve something like that in the picture below – in my case, as this will be the eyebrow controller, I’ve styled it to match. Now go to Modify > Center Pivot, then duplicate your curve and move the duplicate to one side. Select both curves and group them by going to Edit > Group and give the group a clear name – in my case, Eyebrows_Controller. Finally select both of your curves and go to Modify > Freeze Transformations to reset their initial positions.

Step 10

We’’ll now setup the curves to control the blend shapes, using Maya’s Set Driven Keys. First of all ensure that all of your blend shapes are set to 0 – this is very important! Then go to Animate > Set Driven Key > Set to bring up the Set Driven Key window.
Open the Outliner and select your controller group. Then select it again in the Set Driven Key window, and click Load > Selected as Driver. Now back in the Outliner, right-click in the main section and deselect Show DAG Objects Only. This will allow us to see all of the nodes currently in our scene, as shown below :

Step 11

Locate your blendshape node in the Outliner – it will have the name we entered earlier on creation followed by a number, in my case Eyebrows1. Then in the Set Driven Key window, click Load > Selected as Driven. Now you should have something like the picture below :

Step 12

First all you want to work out the axis on which our controller is going to affect the blend shape. As I want the eyebrows to move up and down I’ll be using the Y-Axis, so I’m going to select Translate Y in the right side of the driver pane, at the top of the Set Driven Key window.
Now to create the keys themselves, we first need to setup the start states for the blend shape and our controller curve. I want the eyebrows to be lowered initially, so that moving the controller group up has the effect of raising them. So I’ll set the Translate Y value of my controller to 0 in the attribute editor, and then set the Eyebrows blend shape the value to 1 (lowered). When you’re happy with your initial setup, click the Key button at the bottom of the Set Driven Key window.

Step 13

With the first key created, we now need to set up the second. First of all I set the Eyebrows blend shape value to 0 in order to bring them back to their original position. I can then select the controller group and move them up on the Y-Axis to sit along side the newly raised eyebrows. When you’re happy with your second position, hit the Key button one last time.
With that done you can now close the Set Driven Key window, and try to move the curves around – your mesh is actually responding! I could now go on to apply this technique in exactly the same way to control the position of the mouth, eyes and any other object you can imagine.

 So that’s it for today! I hope you enjoyed this tutorial and I especially hope that you’ve learned some new useful techniques you can apply to your own models. Be sure to stand out and be creative!

Monday, November 30, 2009

MAYA Tutorial - Introduction

Maya is the 3-D animation software that provides a number of tools for creating complex characters and animations. Maya's powerful feature set gives you an almost unlimited power to create any kind of animation. The functionality of the Maya software can be extended with the use of MEL (Maya embedded language). MEL can be used to customize the user interface and write scripts and macros. In Maya, you can create objects, lights, cameras and textures. Any object, light, camera, or just any entity can be animated by changing the value of its parameters in time. We can use Maya, to create effects or animations or movies, commercials, architectural animation and forensic animation. Maya can be used to achieve far more complex effects and animation is as compared to other software is on the shelf. This tutorial is aimed at teaching a newbie, the basic concepts and functionality of the Maya software.

MAYA Tutorial - MAYA Interface

Maya user interface looks very complex at first. However, this large number of functions and the scope to add more functions to the user interface provides the real flexibility to the program. Other than the functions common for all the various aspects of a 3d graphics software application, there are set of functions dedicated to a more specific task like modeling, texturing, animation, rendering etc. The default Maya user interface can be divided into the following sections.
  • Main Menu Bar

  • Status Line

  • Shelf

  • Tool Box

  • Workspace

  • Panel Menus

  • Time Slider

  • Range Slider

  • Command Line

  • Help Line

  • Channel box

  • Layer editor
Fig 1-1 Maya User Interface

The Menu Bar

There are different menu sets in Maya that correspond to the more specific aspects of the application like Animation, Modeling, Dynamics, Rendering, cloth and Maya Live. The cloth and Maya Live are available with Maya unlimited version. These Menu sets can also be accessed using the hot keys F2, F3, F4 etc.
The menus in the menu sets behave similarly as a normal window menu. Other than the menu sets, there are common menus like File, Edit etc.
Any Menu item that has double lines over it can be dragged of the menu bar to create a min-toolbox so that the commonly used tools can float on the desktop.
You can hide or display different UI elements from the Menu item Display-> UI Elements.
Fig1-2 Menu Bar
The Status Line
The commands available on the status line are mostly use for the purpose of modeling. On the extreme left we have mode selector that helps us to change modes between modeling, animation, rendering or dynamics etc.
A collapser is a clickable switch for hiding a section of the Status Line. Collapsers can be used to hide or display sections of the status line and adjust the number of available functions at an instance.
Fig1-3 Status Line
Selection Mask lets us select the masking preset so that certain types of objects can be ignored while making selections in a 3d panel. The icons to the right of the list box show the masking selections that have been made. The selection mask list box acts as a preset for the buttons in the Select by Type area farther to the right. These buttons correspond to Hierarchy, Object and Component mode. These functions can be used to select entire objects and mask the selection to pick only particular type of objects such as surfaces, lines, cameras etc.
Component Selection mode enables you to adjust subcomponents of an object, such as letting you select a certain portion of an object such as a box or a sphere and deform it. The hierarchy selection mode is used to select only the parent or only the children objects, this comes in handy when setting up object hierarchies.
A selection can be locked by pressing the Lock Selection button. This helps in avoiding accidentally de-selection of an object. Next is Highlight Selection Mode button, a toggle to highlight the selected object in the display.
We use snap tools to ease modeling and modifying objects by making it seem as though an object or part of an object is drawn toward another.
You use the Operations List buttons to view upstream and downstream connections and enable or disable them. Next is Construction History toggle and Maya uses this to record construction. History is not related to the Undo operation. Having Construction History enabled can make files large and slow to load, however, so you might opt to turn it off sometimes.
Next we have the Quick Render, Interactive Photorealistic Renderer(IPR) and Render Globals button. Quick Render and Interactive Photorealistic Renderer is used to render a scene at full quality. IPR rendering is slower, but when finished, it can update the rendering in nearly real time. Next is the Render Globals button, which controls the size of the rendering and many other parameters.
The last we have Numeric Input tool. It can operate in different types of modes. It is used to type in a prefix or common letters and select all the objects you want quickly, rename the currently selected object, and enter an exact value for the current highlighted transform.

Shelf contains different tools and commands. The shelf can be customized for one's specific needs. It is used to organize commonly used functions and tools into groups. You can create different shelves for different functions like modeling, animation, texturing etc with the required tools for each function.
Fig1-4 Shelf
Tool Box
Maya Tool Box contains common tools as well as Layout buttons for changing views and layouts. The first one is the select tool. As the name explains itself, while this option is selected, you can use the mouse pointer to click over a particular object to select it. You can also click and drag over a number of objects to select them all together. The lasso tool is also used for selection in a way that you can draw a free hand border around the objects to be selected.
The move, rotate and scale tools are used for transforming objects in Maya. The soft modification tool is used to select the sub-object elements and modify them by moving, rotating or scaling in a way that the neighboring sub-objects also get affected by this deformation with the effect being an inverse of distance from the primary selected sub-objects.
Fig1-5 Toolbox
The last selected tool section shows the last used tool for easy access.
The single perspective view button lets you view the workspace as a single large view from a single perspective. The Four views can be used to view the workspace in four sections with each section containing the three orthographic views top, side and front and a perspective view respectively.
The other combination options below these tools are used to divide the workspace into different section in such a way that one section contains the view of the scene and other contains an animation or rendering editor so that you can edit the attributes and watch the results simultaneously.
The Workspace displays by default in a perspective window or panel. The purpose of using workspace is to view your scene. You can display various editors and arrange the workspace panels in different layouts. The workspace can be divided into sections to accommodate the orthographic and perspective views of the scenes as well as the different editors for animation, texturing and rendering etc.
Time Slider and Range Slider
The Two Sliders are for controlling the frames in your animation. The Time Slider includes the playback buttons and the current time indicator. The Range slider includes start and end times and allows animators to focus on a specific part of the animation.
Fig1-6 Time slider and Range slider
Command Line
The command Line lets you enter the MEL (Maya embedded Language) commands to perform various functions. The MEL is a powerful feature of Maya that provides us with a vast flexibility and a scope to exploit the Maya tools beyond the user interface.
The left side is where you can type MEL commands and the right half displays system responses, error messages, and warnings. For a longer series of commands, use the Script Editor. The right side can also show echoes of all commands if you turn on Script> Echo All Commands from the Script Editor.
Fig1-7 Maya Command Line

Help Line

Like several other applications, you can look at the help line for descriptions, instructions, and other useful information. While a tool is selected, the helpline gives out a brief description for "how to" and "what for".
Panel Menus
Every view panel you work in has a common set of menus at the top. The panel menu that appears in a 3d scene, shown here with lighting menu selected. If the panel menus do not appear, you can enable them in Window> Settings/Preferences> Preferences, and then click the Interface entry under the Categories list on the left side of the dialog box.
Under the View menu, you'll see options for Look at Selected, Frame Selected, and Frame All. These options are helpful for finding an item and focusing on it.
Under the Shading menu, the first two entries are Wireframe (hotkey: 4) and Smooth Shade All (hotkey: 5).An important option to note is the NURBS detail mode. When you're working with NURBS, you can display them in three detail levels: low (hotkey: 1), medium (hotkey: 2), or high (hotkey: 3). These hotkeys work only with NURBS.
Fig1-8 Panel Menu

The Lighting menu has an option for using existing lights in the scene (hotkey: 7) with this panel's Shaded mode. Normally, Shaded mode is automatically illuminated (with "default lights") in a crude way that serves to get some light in the scene for viewing or rendering a new model.
Use the Show menu to selectively hide all entities of a certain type. For example, you often use it to hide cameras and lights, just to clean up the view so that you can focus on objects. At the bottom of this menu is an option to hide the grid, which is useful when you want to simplify the view.
Under the Panels menu, use the top three options to select what the panel is seeing in a 3D view.
The next three options let you change the entire layout of the panels. The Panel item displays options for switching the selected panel to some other window, such as a rendered view or the Graph Editor. Next is Layouts, which determines how the view area is split into windows. Below it is Saved Layouts, which is similar to the Quick Layout buttons below the toolbox.
Hotkeys are also known as keyboard shortcuts. There are several default hotkeys. You can change these hotkeys and assign new ones using the Hotkey editor by
  • Selecting Window>Settings/Preferences>Hotkeys.

  • Select the category and command,

  • In the assign new Hotkey area, specify the key combination .You can see a list of which keys are unmapped by clicking List All.
Fig1-9 Hotkey Editor
Viewing hotkey lists
Click List All to view a list of mapped and unmapped keys.
Fig1-10 Hotkeys reference

The Hotbox

Maya's Hotbox is a utility to get quickly to the menus that are available in the menu bar. It pops up when you press and hold spacebar. Once you customize the Hotbox, it provides quick access to the menus you use, hiding menus that are irrelevant to your work. It has five zones with special options. Five zones are North, South, East, West and center.
To see the entire Hotbox, click in the Hotbox Controls section on the right-hand side of the window, and drag your cursor over the Show All option. You might want to come back to this same Hotbox option and disable the Cloth and Live menus if you won't be using them.
Fig1-11 Hotbox
In order to disable the Hotbox, Select window>Settings/Preferences > Hotkeys. The Hotkey Editor window opens. From the editor window select Hotbox in the list of Categories. Select Show Hotbox from the list of commands, Select space from current Hotkeys, and then click on the Remove button. This turns off the hotkey functionality. Click the Save button and then the close button.

MAYA Tutorial - Transforms in MAYA

"Transform" of an object means three functions: position, rotation, and scale. Each function has three components—for X, Y, and Z. So transform contains 9 variables in total 3 defining each function. When you create a scene entity, its transform appears in the Channel Box. Here you will learn how to scale, rotate, and move your objects. Whenever you give a command in Maya to create an object, it is created using default transform which defines the position to be in the center of the scene at 0,0,0 coordinates, or origin.
In order to customize the object transform, you need to move, rotate, and scale the object to place it in the position you want. You can Move, scale, and rotate the primitive object into its final position either by direct manipulation or by entering numeric values through an editor.
You can also Duplicate the primitive objects to create multiple copies of the original or create different variations from your original primitive object.
When you create a new primitive in Maya, it becomes the selected object. In the Channel Box, you can access the object's creation parameters, the ones used most often to modify a new shape.
The ToolBox
In order to manipulate an object's transform, the basic tools required from the toolbox are select tool, lasso serves a similar purpose, move tool for changing the position of the object, rotate tool for changing the orientation of the object and the scale tool for changing the scale of the object.
Fig2-1 The basic transform tools
Selecting Objects
There are many ways to select objects in Maya.
  • You can select object individually.
  • You can select all objects in the scene.
  • You can select objects of a specified type.
  • You can select objects of a specified name.
  • You can select all objects in a set.
  • You can select all objects in a display layer.

Inverting a Selection

Use Invert Selection to select all objects in the scene that are not selected. For example if you select two of five objects in a scene and then select Edit>Invert Selection, the other three objects are selected instead. This only works on objects not components.
To select all displayed objects
Select Edit > Select All
To deselect all objects
Click anywhere in the view.

Using Transforms

When you are in the Move (hotkey: w), Rotate (hotkey: e), or Scale (hotkey: r) mode, you have several options for transforming the object . Generally, if you click and drag on the surface of a selected object, or on the center point for the manipulator handles, you can freely move or rotate the object. In Scale mode, the object scales uniformly. You can also click and drag on any of the handles to have the action constrained to that axis.
The Move Tool
Click the Move Tool icon in the Tool Box and then select the object you want to move. Maya displays a manipulator with four handles-one to move along each axis and one to move anywhere with in the planes.
Fig2-2 The move tool
Click one of the handles, as indicated above. The selected handle changes color when active .The default color is yellow. If you double-click on the Tool Box icons for move, rotate, and scale, you get options for the tools (none appear for scale, but at least an empty dialog box appears). A useful option in this dialog box is snap spacing.
The Rotate Tool
It use the Rotate Tool to rotate objects about any or all three axes. Click the Rotate Tool icon in the Tool Box. Select the object you want to rotate. Maya displays a rotate manipulator consisting of four rings plus a virtual sphere enclosed by the rings or handles. The colors correspond to XYZ axes.
Fig2-3 The rotate tool
Click one of the handles, as indicated above. The selected handle changes color when active .The default color is yellow. Use the X, Y, Z rings to perform constrained rotations. Use the outer ring to rotate relative to the view.
When you rotate a component, Maya rotates it about a temporary pivot which is initially set to the center of the component's bounding box. In the rotate options, you can find the option to set snaps, which is helpful when you want to rotate objects in discrete increments. A good setting might be 15 degrees to make it easy to rotate objects to precise 30-, 45-, 60-, and 90-degree positions. Note that this snapping happens only when you use a manipulator's axis handle.
The Scale Tool
Use the Scale Tool to change the size of the objects by scaling proportionally in all three dimensions. You can also scale non- proportionally in one dimension at a time.
Click the Scale Tool icon in the Tool Box and select the object you want to scale. Maya displays a scale manipulator consisting of four handles. The color corresponds to XYZ axes.
Fig2-4 The scale tool

Soft Modification Tool
This lets you push and pull geometry .By default, the amount of deformation is greatest at the center of the push/pull, and gradually falls off further away from the centre. However, you can control the falloff of the deformation to create various types of effects.
You can use this tool on NURBS surfaces, polygonal surfaces, subdivision surfaces, curves, particles or any object with components.

Show Manipulator Tool

This Tool lets you edit the construction history of an operation or the attributes of an object itself. This tool lets you access the input node of an object. A manipulator is a good way to access the history of a surface created with the construction history. Several manipulators can be active at one time.

Undoing and Redoing

Undo reverse the last action you performed on a selected object. This action transform an object to its original position.
Select Edit>Undo
Select Edit>Redo to perform the last action you reversed.

Duplicating Objects

Sometimes, you need to copy an object many times to create a complex object. Maya's object duplicator is under Edit > Duplicate on the menu. The default is to duplicate an object in place; you can do this with the hotkey Ctrl +d. The new duplicate appears by default exactly over the original object, so you normally follow a duplication with a transform.
Sometime, you want to create more than one duplicate. Use the Edit > Duplicate Option box to modify how duplicates are made.
Another way to copy object is instancing. Maya redisplays the geometry being instanced. Since instances are not actual copies of the original geometry.
There are certain demerits of using instancing
  • Instances share the same shader as the original geometry and can not be assigned as independent shaders.

  • Instanced lights have no effect.

  • When you create an instance of an already instanced node, Maya does not create a new level.

  • Functions like extrude and insert can not be used on instanced items.
The Snap options let you control an object or component's position by attaching it to a grid, point, curve or view plane. As you draw, rotate, resize or drag the objects ,it snap to the grid, point, curve or view plane.
Fig2-5 Snapping options

Snap to grids

This option snaps a vertex or pivot point to a grid corner. If you select snap to grids before you create a curve, its vertices snap to the grid corners.

Snap to curves

This option snaps a vertex or pivot point to a curve or curve on surface.

Snap to points

This option snaps a vertex or pivot point to a point.

Snap to view planes

This option snaps a vertex or pivot point to a view plane.
Snapping hotkeys
x for grid snap
c for curve snap
v for point snap

How to use the grid Snap HotKey?

Select the object you want to snap and click the Move tool icon. Press and hold down the c key while click-dragging on the curve you want to snap with the middle mouse button.
Similarly you can use rest of the keys
You can use outliner to examine the structure and components of the scene. It also displays shape nodes, connections and attributes. With the outliner you can make an object the child of a parent object. It selects and renames an object. Last but not least it reorder nodes.

To open the Outliner in the window

Select Window > Outliner
Fig2-6 The outliner


Sometimes, you have groups of objects in your scene that are related to each other without being connected as a single entity. Any collection of objects can be selected and made into a group by choosing Edit>Group on the menu. Note that the objects are not tied up into this bundle; you can still select them independently. There's simply a new object that stands for the collection.
Parenting and Grouping
Parents and children in hierarchies work as follows: Where the parent goes, the child must follow, but the child is otherwise free to roam. The child objects can still be animated independently, however, without affecting the parent .With groups, the group node can be animated and all the members of the group follow the group node, but the group's members can still animate independently of the group. When you group several objects, Maya creates the group transform node, which can't be rendered.
You can directly assign hierarchical relationships to objects by selecting the child object(s), Shift-clicking to select the parent, and then choosing Edit >Parent (hotkey: p). Any transform applied to the parent is then reflected in the child. You can also break this bond by using Edit>Unparent (hotkey: Shift+P). This works only when the child object or objects are selected.
Channel Box
This is used to modify an object's attribute values. You can change multiple attribute values of multiple objects. It takes up less much less space in the window. With this you can control construction history. It appears in the Maya Window only it you choose to display it. The information displayed in the Channel Box varies, depending on what kind of object or component you have selected. If you haven't selected an object, the Channel Box region is blank.
In order to display the channel box
Turn on Display> UI Elements > Channel Box/Layer Editor.