684
Getting Started with Maya

Autodesk Maya 2009

Embed Size (px)

DESCRIPTION

Intro a 3D

Citation preview

Page 1: Autodesk Maya 2009

Getting Started with Maya

Page 2: Autodesk Maya 2009

Copyright Notice© 2008 Autodesk, Inc. All rights reserved. Except as otherwise permitted by Autodesk, Inc., this publication, or parts thereof, may not bereproduced in any form, by any method, for any purpose.Certain materials included in this publication are reprinted with the permission of thecopyright holder.Portions relating to Graph Layout Toolkit © Copyright 1992-2003 Tom Sawyer Software, Berkeley, California. All rights reserved.Portions relating to TIFF © Copyright 1988-1997 Sam Leffler. © Copyright 1991-1997 Silicon Graphics, Inc. All rights reserved. Permissions touse, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that (i) theabove copyright notices and this permission notice appear in all copies of the software and related documentation, and (ii) the names of SamLeffler and Silicon Graphics may not be used in any advertising or publicity relating to the software without the specific, prior written permissionof Sam Leffler and Silicon Graphics.THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUTLIMITATION, ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SAM LEFFLER OR SILICONGRAPHICS BE LIABLE FOR ANY SPECIAL, INCIDENTIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVERRESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORYOF LIABIBITLY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.Portions relating to OpenEXR v 1.2.2 Copyright © 2002, Industrial Light & Magic, a division of Lucas Digital Ltd. LLC All rights reserved.Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions inbinary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or othermaterials provided with the distribution. Neither the name of Industrial Light & Magic nor the names of its contributors may be used to endorseor promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHTHOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIEDWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHTOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESSINTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDINGNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCHDAMAGE.Portions relating to JPEG © Copyright 1991-1998 Thomas G. Lane. All rights reserved. This software is based in part on the work of the IndependentJPEG Group.Portions relating to GCC are Copyright © 2008 Free Software Foundation, Inc.Portions relating to Animation Repurposing Technology, Copyright 1999-2003 House of Moves Motion Capture Studios, LLC.Portions relating to Expat XML Copyright © 1998, 1999, 2000 Thai Open Source Software Center Ltd. and Clarke Cooper. Copyright © 2001,2002 Expat maintainers. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUTNOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENTSHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OFCONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGSIN THE SOFTWARE.Portions relating to XHTML Copyright © 1998, 1999, 2000 Thai Open Source Software Center Ltd. Permission is hereby granted, free of charge,to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction,including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and topermit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permissionnotice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OFANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULARPURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGESOR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITHTHE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.Portions relating to OpenVRML are Copyright © 2008 Free Software Foundation, Inc.Portions relating to pysqlite Copyright © 2005-2007 Gerhard Häring, [email protected] relating to Flex 2.5.4 are developed by the University of California, Berkeley and its contributors.Portions relating to Doc ++ are copyright © 1996 Roland Wunderling, Malte Zoeckler copyright © 1999-2001 Dragos Acostachioaie.Portions relating to the implementation of the Edge Detection and Image Segmentation (EDISON) System are provided "AS IS". More informationmay be found at http://www.caip.rutgers.edu/riul/research/code.html.Portions of the subdivision surface implementation technology are protected by U.S. patents 6,037,949, 6,222,553, 6,300,960, and 6,489,960and used under license from Pixar.Portions Copyrighted mental images GmbH 1989-2007.Portions relating to Python 2.3.3 Copyright © 2001, 2002, 2003 Python Software Foundation; All Rights Reserved.Portions relating to Imconvert Copyright 1999-2007 ImageMagick Studio LLC, a non-profit organization dedicated to making software imagingsolutions freely available.The following are registered trademarks or trademarks of Autodesk, Inc., in the USA and other countries: 3DEC (design/logo), 3December,3December.com, 3ds Max, ADI, Alias, Alias (swirl design/logo), AliasStudio, Alias|Wavefront (design/logo), ATC, AUGI, AutoCAD, AutoCADLearning Assistance, AutoCAD LT, AutoCAD Simulator, AutoCAD SQL Extension, AutoCAD SQL Interface, Autodesk, Autodesk Envision, AutodeskInsight, Autodesk Intent, Autodesk Inventor, Autodesk Map, Autodesk MapGuide, Autodesk Streamline, AutoLISP, AutoSnap, AutoSketch,AutoTrack, Backdraft, Built with ObjectARX (logo), Burn, Buzzsaw, CAiCE, Can You Imagine, Character Studio, Cinestream, Civil 3D, Cleaner,Cleaner Central, ClearScale, Colour Warper, Combustion, Communication Specification, Constructware, Content Explorer, Create>what's>Next>(design/logo), Dancing Baby (image), DesignCenter, Design Doctor, Designer's Toolkit, DesignKids, DesignProf, DesignServer, DesignStudio,

Page 3: Autodesk Maya 2009

Design|Studio (design/logo), Design Web Format, DWF, DWG, DWG (logo), DWG TrueConvert, DWG TrueView, DXF, Ecotect, Exposure,Extending the Design Team, FBX, Filmbox, FMDesktop, Freewheel, GDX Driver, Gmax, Green Building Studio, Heads-up Design, Heidi, HumanIK,IDEA Server, i-drop, ImageModeler, iMOUT, Incinerator, Inventor, Inventor LT, Kaydara, Kaydara (design/logo), Kynapse, Kynogon, LocationLogic,Lustre, Matchmover, Maya, Mechanical Desktop, MotionBuilder, Movimento, Mudbox, NavisWorks, ObjectARX, ObjectDBX, Open Reality,Opticore, Opticore Opus, PolarSnap, PortfolioWall, Powered with Autodesk Technology, Productstream, ProjectPoint, ProMaterials, Reactor,RealDWG, Real-time Roto, REALVIZ, Recognize, Render Queue, Retimer,Reveal, Revit, Showcase, ShowMotion, SketchBook, SteeringWheels,Stitcher, StudioTools, Topobase, Toxik, ViewCube, Visual, Visual Construction, Visual Drainage, Visual Landscape, Visual Survey, Visual Toolbox,Visual LISP, Voice Reality, Volo, Vtour, Wiretap, and WiretapCentral.The following are registered trademarks or trademarks of Autodesk Canada Co. in the USA and/or Canada and other countries: Backburner,Discreet, Fire, Flame, Flint, Frost, Inferno, Multi-Master Editing, River, Smoke, Sparks, Stone, and Wire.mental ray is a registered trademark of mental images GmbH licensed for use by Autodesk, Inc. Adobe, Illustrator and Photoshop are eitherregistered trademarks or trademarks of Adobe Systems Incorporated in the United States and/or other countries. The Ravix logo is a trademarkof Electric Rain, Inc. "Python" and the Python logo are trademarks or registered trademarks of the Python Software Foundation. All other brandnames, product names or trademarks belong to their respective holders.

DisclaimerTHIS PUBLICATION AND THE INFORMATION CONTAINED HEREIN IS MADE AVAILABLE BY AUTODESK, INC. "AS IS." AUTODESK, INC. DISCLAIMSALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY ORFITNESS FOR A PARTICULAR PURPOSE REGARDING THESE MATERIALS.

Page 4: Autodesk Maya 2009
Page 5: Autodesk Maya 2009

Contents

Chapter 1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1About the Getting Started lessons . . . . . . . . . . . . . . . . . . . . . 2Before you begin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3Installing Maya . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4Conventions used in the lessons . . . . . . . . . . . . . . . . . . . . . . 4Using the lesson files . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5Using the Maya Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5Additional learning resources . . . . . . . . . . . . . . . . . . . . . . . 10Restoring default user settings . . . . . . . . . . . . . . . . . . . . . . 11

Chapter 2 Maya Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13Preparing for the lessons . . . . . . . . . . . . . . . . . . . . . . . . . 14Lesson 1: The Maya user interface . . . . . . . . . . . . . . . . . . . . 15

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15Starting Maya . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15The Maya interface . . . . . . . . . . . . . . . . . . . . . . . . . 16Copying and setting the Maya project . . . . . . . . . . . . . . . 25Saving your work . . . . . . . . . . . . . . . . . . . . . . . . . . 26Exiting Maya . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27Beyond the lesson . . . . . . . . . . . . . . . . . . . . . . . . . . 28

Lesson 2: Creating, manipulating, and viewing objects . . . . . . . . . 29

v

Page 6: Autodesk Maya 2009

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29Creating a new scene . . . . . . . . . . . . . . . . . . . . . . . . 30Primitive objects . . . . . . . . . . . . . . . . . . . . . . . . . . . 30The Toolbox: Layout shortcuts . . . . . . . . . . . . . . . . . . . 32The Toolbox: Transformation tools . . . . . . . . . . . . . . . . . 34The Channel Box . . . . . . . . . . . . . . . . . . . . . . . . . . 37Duplicating objects . . . . . . . . . . . . . . . . . . . . . . . . . 39Save your work . . . . . . . . . . . . . . . . . . . . . . . . . . . 40Beyond the lesson . . . . . . . . . . . . . . . . . . . . . . . . . . 41

Lesson 3: Viewing the Maya 3D scene . . . . . . . . . . . . . . . . . . 42Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42Camera tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43Workflow overview . . . . . . . . . . . . . . . . . . . . . . . . . 46Viewing objects in shaded mode . . . . . . . . . . . . . . . . . . 51Grouping objects . . . . . . . . . . . . . . . . . . . . . . . . . . 52The Hypergraph . . . . . . . . . . . . . . . . . . . . . . . . . . . 53Selection modes and masks . . . . . . . . . . . . . . . . . . . . . 57Pivot points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58Save your work . . . . . . . . . . . . . . . . . . . . . . . . . . . 60Beyond the lesson . . . . . . . . . . . . . . . . . . . . . . . . . . 60

Lesson 4: Components and attributes . . . . . . . . . . . . . . . . . . 61Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61Template display . . . . . . . . . . . . . . . . . . . . . . . . . . 61Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63The Attribute Editor . . . . . . . . . . . . . . . . . . . . . . . . . 66Surface materials . . . . . . . . . . . . . . . . . . . . . . . . . . 68Save your work . . . . . . . . . . . . . . . . . . . . . . . . . . . 71Beyond the lesson . . . . . . . . . . . . . . . . . . . . . . . . . . 71

Chapter 3 Polygonal Modeling . . . . . . . . . . . . . . . . . . . . . . . . 73Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73Preparing for the lesson . . . . . . . . . . . . . . . . . . . . . . . . . . 74Lesson 1: Modeling a polygonal mesh . . . . . . . . . . . . . . . . . . 75

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75Setting modeling preferences . . . . . . . . . . . . . . . . . . . . 76Using 2D reference images . . . . . . . . . . . . . . . . . . . . . 77Creating a polygon primitive . . . . . . . . . . . . . . . . . . . . 80Modeling in shaded mode . . . . . . . . . . . . . . . . . . . . . 83Model symmetry . . . . . . . . . . . . . . . . . . . . . . . . . . 84Selecting components by painting . . . . . . . . . . . . . . . . . 85Selecting edge loops . . . . . . . . . . . . . . . . . . . . . . . . . 87Editing components in the orthographic views . . . . . . . . . . 89Editing components in the perspective view . . . . . . . . . . . . 96Drawing a polygon . . . . . . . . . . . . . . . . . . . . . . . . . 98Extruding polygon components . . . . . . . . . . . . . . . . . . 100Bridging between edges . . . . . . . . . . . . . . . . . . . . . . 105

vi | Contents

Page 7: Autodesk Maya 2009

Adding polygons to a mesh . . . . . . . . . . . . . . . . . . . . 108Splitting polygon faces . . . . . . . . . . . . . . . . . . . . . . . 110Terminating edge loops . . . . . . . . . . . . . . . . . . . . . . 118Deleting construction history . . . . . . . . . . . . . . . . . . . 120Mirror copying a mesh . . . . . . . . . . . . . . . . . . . . . . . 122Working with a smoothed mesh . . . . . . . . . . . . . . . . . . 124Creasing and hardening edges on a mesh . . . . . . . . . . . . . 126Beyond the lesson . . . . . . . . . . . . . . . . . . . . . . . . . 132

Chapter 4 NURBS Modeling . . . . . . . . . . . . . . . . . . . . . . . . . 135Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135Preparing for the lessons . . . . . . . . . . . . . . . . . . . . . . . . . 136Lesson 1: Revolving a curve to create a surface . . . . . . . . . . . . . 137

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137Creating a profile curve . . . . . . . . . . . . . . . . . . . . . . 137Creating a revolve surface . . . . . . . . . . . . . . . . . . . . . 139Editing a revolve surface . . . . . . . . . . . . . . . . . . . . . . 140Beyond the lesson . . . . . . . . . . . . . . . . . . . . . . . . . 141

Lesson 2: Sculpting a NURBS surface . . . . . . . . . . . . . . . . . . 142Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142Preparing a surface for sculpting . . . . . . . . . . . . . . . . . . 143Basic sculpting techniques . . . . . . . . . . . . . . . . . . . . . 145Additional sculpting techniques . . . . . . . . . . . . . . . . . . 148Sculpting a nose . . . . . . . . . . . . . . . . . . . . . . . . . . 150Sculpting eye sockets . . . . . . . . . . . . . . . . . . . . . . . 151Sculpting eyebrows . . . . . . . . . . . . . . . . . . . . . . . . 152Sculpting a mouth . . . . . . . . . . . . . . . . . . . . . . . . . 153Sculpting other facial features . . . . . . . . . . . . . . . . . . . 155Beyond the lesson . . . . . . . . . . . . . . . . . . . . . . . . . 156

Lesson 3: Lofting curves to create a surface . . . . . . . . . . . . . . . 157Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157Creating profile curves for a surface . . . . . . . . . . . . . . . . 158Duplicating curves . . . . . . . . . . . . . . . . . . . . . . . . . 160Lofting a surface . . . . . . . . . . . . . . . . . . . . . . . . . . 161Modifying a primitive object . . . . . . . . . . . . . . . . . . . 162Using the Outliner to parent objects . . . . . . . . . . . . . . . 164Beyond the lesson . . . . . . . . . . . . . . . . . . . . . . . . . 165

Chapter 5 Subdivision Surfaces . . . . . . . . . . . . . . . . . . . . . . . 167Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167Preparing for the lesson . . . . . . . . . . . . . . . . . . . . . . . . . 167Lesson 1: Modeling a subdivision surface . . . . . . . . . . . . . . . . 168

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168Creating a subdivision surface . . . . . . . . . . . . . . . . . . . 169Splitting a surface in polygon proxy mode . . . . . . . . . . . . 171

Contents | vii

Page 8: Autodesk Maya 2009

Extruding polygon faces . . . . . . . . . . . . . . . . . . . . . . 173Deleting polygon faces . . . . . . . . . . . . . . . . . . . . . . . 176Subdivision surface levels . . . . . . . . . . . . . . . . . . . . . 177Refining surface components . . . . . . . . . . . . . . . . . . . 179Creating a crease in a subdivision surface . . . . . . . . . . . . . 181Beyond the lesson . . . . . . . . . . . . . . . . . . . . . . . . . 183

Chapter 6 Animation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185Preparing for the lessons . . . . . . . . . . . . . . . . . . . . . . . . . 185Lesson 1: Keyframes and the Graph Editor . . . . . . . . . . . . . . . 186

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186Setting the playback range . . . . . . . . . . . . . . . . . . . . . 187Setting keyframes . . . . . . . . . . . . . . . . . . . . . . . . . 188Using the Graph Editor . . . . . . . . . . . . . . . . . . . . . . 191Changing the timing of an attribute . . . . . . . . . . . . . . . 195Fine tuning an animation . . . . . . . . . . . . . . . . . . . . . 196Deleting extra keyframes and static channels . . . . . . . . . . . 198Using Playblast to playback an animation . . . . . . . . . . . . 199Beyond the lesson . . . . . . . . . . . . . . . . . . . . . . . . . 200

Lesson 2: Set Driven Key . . . . . . . . . . . . . . . . . . . . . . . . . 201Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201Lesson setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202Using Set Driven Key to link attributes . . . . . . . . . . . . . . 202Viewing the results in the Graph Editor . . . . . . . . . . . . . . 205Beyond the lesson . . . . . . . . . . . . . . . . . . . . . . . . . 205

Lesson 3: Path animation . . . . . . . . . . . . . . . . . . . . . . . . 206Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206Open the scene for the lesson . . . . . . . . . . . . . . . . . . . 207Animating an object along a motion path . . . . . . . . . . . . 208Changing the timing of an object along a motion path . . . . . 210Rotating an object along a motion path . . . . . . . . . . . . . 216Blending keyframe and motion path animation . . . . . . . . . 217Using Playblast to playback an animation . . . . . . . . . . . . 223Beyond the lesson . . . . . . . . . . . . . . . . . . . . . . . . . 224

Lesson 4: Nonlinear animation with Trax . . . . . . . . . . . . . . . . 225Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225Open the first scene for the lesson . . . . . . . . . . . . . . . . 226Creating clips with Trax . . . . . . . . . . . . . . . . . . . . . . 228Changing the position of clips with Trax . . . . . . . . . . . . . 235Editing the animation of clips . . . . . . . . . . . . . . . . . . . 237Reusing clips within Trax . . . . . . . . . . . . . . . . . . . . . 239Soloing and muting tracks . . . . . . . . . . . . . . . . . . . . . 242Scaling clips within Trax . . . . . . . . . . . . . . . . . . . . . . 243Open the second scene for the lesson . . . . . . . . . . . . . . . 245Creating clips from motion capture data . . . . . . . . . . . . . 246

viii | Contents

Page 9: Autodesk Maya 2009

Extending the length of motion capture data . . . . . . . . . . . 248Redirecting the motion within a clip . . . . . . . . . . . . . . . 252Beyond the lesson . . . . . . . . . . . . . . . . . . . . . . . . . 259

Lesson 5: Inverse kinematics . . . . . . . . . . . . . . . . . . . . . . . 262Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262Open the scene for the lesson . . . . . . . . . . . . . . . . . . . 263Understanding hierarchies . . . . . . . . . . . . . . . . . . . . . 264Viewing hierarchies using the Hypergraph . . . . . . . . . . . . 265Creating a skeleton hierarchy . . . . . . . . . . . . . . . . . . . 267Parenting a model into a skeleton hierarchy . . . . . . . . . . . 271Applying IK to a skeleton hierarchy . . . . . . . . . . . . . . . . 274Creating a control object for an IK system . . . . . . . . . . . . 276Constraining an IK system . . . . . . . . . . . . . . . . . . . . . 280Limiting the range of motion of an IK system . . . . . . . . . . 284Simplifying the display of a hierarchy . . . . . . . . . . . . . . . 290Applying parent constraints on an IK system . . . . . . . . . . . 291Planning an animation for an IK system . . . . . . . . . . . . . 294Animating an IK system . . . . . . . . . . . . . . . . . . . . . . 297Beyond the lesson . . . . . . . . . . . . . . . . . . . . . . . . . 301

Chapter 7 Character Setup . . . . . . . . . . . . . . . . . . . . . . . . . 303Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303Preparing for the lessons . . . . . . . . . . . . . . . . . . . . . . . . . 304Lesson 1: Skeletons and kinematics . . . . . . . . . . . . . . . . . . . 304

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304Open the scene for the lesson . . . . . . . . . . . . . . . . . . . 305Creating joints . . . . . . . . . . . . . . . . . . . . . . . . . . . 305Adding joints to a skeleton . . . . . . . . . . . . . . . . . . . . 311Creating a skeleton hierarchy . . . . . . . . . . . . . . . . . . . 313Forward and inverse kinematics . . . . . . . . . . . . . . . . . . 314Posing and animating using inverse kinematics . . . . . . . . . 314Posing and animating using forward kinematics . . . . . . . . . 318Beyond the lesson . . . . . . . . . . . . . . . . . . . . . . . . . 318

Lesson 2: Smooth skinning . . . . . . . . . . . . . . . . . . . . . . . 319Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319Open the scene for the lesson . . . . . . . . . . . . . . . . . . . 320Smooth binding a skeleton . . . . . . . . . . . . . . . . . . . . 321Skin weighting and deformations . . . . . . . . . . . . . . . . . 323Modifying skin weights . . . . . . . . . . . . . . . . . . . . . . 324Influence objects . . . . . . . . . . . . . . . . . . . . . . . . . . 326Beyond the lesson . . . . . . . . . . . . . . . . . . . . . . . . . 329

Lesson 3: Cluster and blend shape deformers . . . . . . . . . . . . . . 330Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330Open the scene for the lesson . . . . . . . . . . . . . . . . . . . 330Creating a target object for a blend shape . . . . . . . . . . . . . 331Creating a cluster deformer on a target object . . . . . . . . . . 332

Contents | ix

Page 10: Autodesk Maya 2009

Editing cluster weights . . . . . . . . . . . . . . . . . . . . . . . 334Creating a blend shape . . . . . . . . . . . . . . . . . . . . . . 338Refining deformation effects . . . . . . . . . . . . . . . . . . . 340Adding target objects to an existing blend shape . . . . . . . . . 341Beyond the lesson . . . . . . . . . . . . . . . . . . . . . . . . . 345

Chapter 8 Polygon Texturing . . . . . . . . . . . . . . . . . . . . . . . . 347Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347Preparing for the lesson . . . . . . . . . . . . . . . . . . . . . . . . . 348Lesson 1: UV texture mapping . . . . . . . . . . . . . . . . . . . . . . 349

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349Creating a cracker box model . . . . . . . . . . . . . . . . . . . 350Applying a texture map to a polygon mesh . . . . . . . . . . . . 351Viewing UVs in the UV Texture Editor . . . . . . . . . . . . . . 357Mapping UV texture coordinates . . . . . . . . . . . . . . . . . 361Working with UVs in the UV Texture Editor . . . . . . . . . . . 365Beyond the lesson . . . . . . . . . . . . . . . . . . . . . . . . . 373

Chapter 9 Rendering . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375Preparing for the lessons . . . . . . . . . . . . . . . . . . . . . . . . . 377Lesson 1: Rendering a scene . . . . . . . . . . . . . . . . . . . . . . . 377

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377Open the scene for the lesson . . . . . . . . . . . . . . . . . . . 378Creating shading materials for objects . . . . . . . . . . . . . . 379Refining shading materials for objects . . . . . . . . . . . . . . 383Maya renderers . . . . . . . . . . . . . . . . . . . . . . . . . . . 388Rendering a single frame using IPR . . . . . . . . . . . . . . . . 390Rendering using the Maya software renderer . . . . . . . . . . . 396Batch rendering a sequence of animation frames . . . . . . . . . 398Viewing a sequence of rendered frames . . . . . . . . . . . . . . 401Beyond the lesson . . . . . . . . . . . . . . . . . . . . . . . . . 402

Lesson 2: Shading surfaces . . . . . . . . . . . . . . . . . . . . . . . . 404Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404Open the scene for the lesson . . . . . . . . . . . . . . . . . . . 405Assigning a shading material . . . . . . . . . . . . . . . . . . . 406Modifying surface specularity . . . . . . . . . . . . . . . . . . . 408Material types . . . . . . . . . . . . . . . . . . . . . . . . . . . 409Assigning textures . . . . . . . . . . . . . . . . . . . . . . . . . 410Using the Hypershade editor . . . . . . . . . . . . . . . . . . . 413Creating a texture within the Hypershade editor . . . . . . . . . 416Modifying a bump texture . . . . . . . . . . . . . . . . . . . . . 419Beyond the lesson . . . . . . . . . . . . . . . . . . . . . . . . . 421

Lesson 3: Lights, shadows, and cameras . . . . . . . . . . . . . . . . . 423Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423

x | Contents

Page 11: Autodesk Maya 2009

Open the scene for the lesson . . . . . . . . . . . . . . . . . . . 424Directional lights . . . . . . . . . . . . . . . . . . . . . . . . . . 425Spotlights . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427Editing light attributes . . . . . . . . . . . . . . . . . . . . . . . 430Shadows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433Creating additional cameras in a scene . . . . . . . . . . . . . . 435Animating camera moves . . . . . . . . . . . . . . . . . . . . . 437Beyond the lesson . . . . . . . . . . . . . . . . . . . . . . . . . 438

Lesson 4: Global Illumination . . . . . . . . . . . . . . . . . . . . . . 440Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440Open the scene for the lesson . . . . . . . . . . . . . . . . . . . 441Render the scene using raytracing . . . . . . . . . . . . . . . . . 442Render the scene using Global Illumination . . . . . . . . . . . 447Beyond the Lesson . . . . . . . . . . . . . . . . . . . . . . . . . 456

Lesson 5: Caustics . . . . . . . . . . . . . . . . . . . . . . . . . . . . 458Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 458Open the scene for the lesson . . . . . . . . . . . . . . . . . . . 459Render the scene using raytracing . . . . . . . . . . . . . . . . . 460Render the scene using caustics . . . . . . . . . . . . . . . . . . 465Beyond the Lesson . . . . . . . . . . . . . . . . . . . . . . . . . 472

Chapter 10 Dynamics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475Preparing for the lessons . . . . . . . . . . . . . . . . . . . . . . . . . 476Lesson 1: Particles, emitters, and fields . . . . . . . . . . . . . . . . . 476

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476Creating an emitter . . . . . . . . . . . . . . . . . . . . . . . . 477Creating volume axis fields . . . . . . . . . . . . . . . . . . . . 479Adjusting the velocity of moving particles . . . . . . . . . . . . 485Setting the particle render type . . . . . . . . . . . . . . . . . . 485Adding dynamic attributes . . . . . . . . . . . . . . . . . . . . 486Adding per particle attributes . . . . . . . . . . . . . . . . . . . 488Adding color to particles with a color ramp . . . . . . . . . . . 489Hardware rendering particles . . . . . . . . . . . . . . . . . . . 491Beyond the lesson . . . . . . . . . . . . . . . . . . . . . . . . . 493

Lesson 2: Rigid bodies and constraints . . . . . . . . . . . . . . . . . 494Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 494Lesson setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . 495Creating hinge constraints . . . . . . . . . . . . . . . . . . . . . 497Running a dynamics simulation . . . . . . . . . . . . . . . . . . 498Changing an active rigid body to passive . . . . . . . . . . . . . 498Beyond the lesson . . . . . . . . . . . . . . . . . . . . . . . . . 499

Chapter 11 Painting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 501Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 501

Contents | xi

Page 12: Autodesk Maya 2009

Preparing for the lessons . . . . . . . . . . . . . . . . . . . . . . . . . 503Lesson 1: Painting in 2D using Paint Effects . . . . . . . . . . . . . . 503

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 503Painting strokes . . . . . . . . . . . . . . . . . . . . . . . . . . 504Modifying the default brush settings . . . . . . . . . . . . . . . 506Modifying the canvas . . . . . . . . . . . . . . . . . . . . . . . 508Modifying the colors of a preset brush . . . . . . . . . . . . . . 509Editing strokes with tubes attributes . . . . . . . . . . . . . . . 510Saving brush settings for future use . . . . . . . . . . . . . . . . 511Blending brushes . . . . . . . . . . . . . . . . . . . . . . . . . . 512Smearing, blurring, and erasing paint . . . . . . . . . . . . . . . 513Beyond the lesson . . . . . . . . . . . . . . . . . . . . . . . . . 515

Lesson 2: Painting in 3D using Paint Effects . . . . . . . . . . . . . . 516Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 516Preparing for the lessons . . . . . . . . . . . . . . . . . . . . . . 517Brushes and strokes . . . . . . . . . . . . . . . . . . . . . . . . 518Rendering Paint Effects strokes . . . . . . . . . . . . . . . . . . 525Paint Effects on 3D objects . . . . . . . . . . . . . . . . . . . . 529Creating a surface to paint on . . . . . . . . . . . . . . . . . . . 530Painting on objects . . . . . . . . . . . . . . . . . . . . . . . . 533Using turbulence with brush stroke tubes . . . . . . . . . . . . . 535Using additional preset brushes . . . . . . . . . . . . . . . . . . 536Mesh brushes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 538Converting mesh strokes to polygons . . . . . . . . . . . . . . . 540Modifying a converted polygonal mesh . . . . . . . . . . . . . . 542Beyond the lesson . . . . . . . . . . . . . . . . . . . . . . . . . 546

Lesson 3: Painting textures on surfaces . . . . . . . . . . . . . . . . . 548Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 548Open the scene for the lesson . . . . . . . . . . . . . . . . . . . 548Preparing for painting . . . . . . . . . . . . . . . . . . . . . . . 549Painting with an Artisan brush . . . . . . . . . . . . . . . . . . 551Painting symmetrical strokes . . . . . . . . . . . . . . . . . . . 552Using Flood All to apply a single color . . . . . . . . . . . . . . 553Brush shapes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 553Painting with a Paint Effects brush . . . . . . . . . . . . . . . . 555Smearing and blurring . . . . . . . . . . . . . . . . . . . . . . . 557Painting a bump map texture . . . . . . . . . . . . . . . . . . . 558Beyond the lesson . . . . . . . . . . . . . . . . . . . . . . . . . 561

Chapter 12 Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 565Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 565Preparing for the lessons . . . . . . . . . . . . . . . . . . . . . . . . . 566Lesson 1: Creating a simple expression . . . . . . . . . . . . . . . . . 567

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 567Creating expressions to control a single attribute . . . . . . . . . 567Editing expressions . . . . . . . . . . . . . . . . . . . . . . . . 570

xii | Contents

Page 13: Autodesk Maya 2009

Using expressions to control multiple attributes . . . . . . . . . 571Linking multiple attributes on the same object . . . . . . . . . . 571Controlling attributes in two objects . . . . . . . . . . . . . . . 572Beyond the lesson . . . . . . . . . . . . . . . . . . . . . . . . . 573

Lesson 2: Conditional expressions . . . . . . . . . . . . . . . . . . . . 574Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 574Creating a conditional expression . . . . . . . . . . . . . . . . . 574Other conditional statement options . . . . . . . . . . . . . . . 577Fixing a problem in an expression . . . . . . . . . . . . . . . . . 579Using else statements . . . . . . . . . . . . . . . . . . . . . . . 580Simplifying expressions . . . . . . . . . . . . . . . . . . . . . . 581Editing expressions to refine an animation . . . . . . . . . . . . 582Beyond the lesson . . . . . . . . . . . . . . . . . . . . . . . . . 584

Lesson 3: Controlling particle attributes . . . . . . . . . . . . . . . . 584Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 584Creating particle objects . . . . . . . . . . . . . . . . . . . . . . 584Using creation expressions to set a constant color . . . . . . . . 586Using runtime expressions . . . . . . . . . . . . . . . . . . . . . 587Modifying runtime expressions . . . . . . . . . . . . . . . . . . 588Beyond the lesson . . . . . . . . . . . . . . . . . . . . . . . . . 589

Chapter 13 Scripting in Maya . . . . . . . . . . . . . . . . . . . . . . . . 591Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 591Some basic concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . 592Preparing for the lessons . . . . . . . . . . . . . . . . . . . . . . . . . 595Lesson 1: Commands in MEL . . . . . . . . . . . . . . . . . . . . . . 596

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 596Entering MEL commands . . . . . . . . . . . . . . . . . . . . . 597Observing script history . . . . . . . . . . . . . . . . . . . . . . 598Modifying object attributes . . . . . . . . . . . . . . . . . . . . 601Editing Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . 604Beyond the lesson . . . . . . . . . . . . . . . . . . . . . . . . . 605

Lesson 2: Saving scripts to the Shelf . . . . . . . . . . . . . . . . . . . 606Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 606Setting up the scene . . . . . . . . . . . . . . . . . . . . . . . . 607Recording the script history . . . . . . . . . . . . . . . . . . . . 608Compare the rendered images . . . . . . . . . . . . . . . . . . 610Saving the history as a button . . . . . . . . . . . . . . . . . . . 611Beyond the Lesson . . . . . . . . . . . . . . . . . . . . . . . . . 613

Lesson 3: Using Variables in MEL . . . . . . . . . . . . . . . . . . . . 614Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 614Setting up the scene . . . . . . . . . . . . . . . . . . . . . . . . 615Storing scene information . . . . . . . . . . . . . . . . . . . . . 615Create a row of barrels . . . . . . . . . . . . . . . . . . . . . . . 617Stacking the row of barrels . . . . . . . . . . . . . . . . . . . . . 618Using MEL built-in functions to calculate the Y offset . . . . . . 619

Contents | xiii

Page 14: Autodesk Maya 2009

Creating dynamics with MEL commands . . . . . . . . . . . . . 621Beyond the lesson . . . . . . . . . . . . . . . . . . . . . . . . . 623

Lesson 4: User interface creation and procedures . . . . . . . . . . . . 624Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 624Creating a window . . . . . . . . . . . . . . . . . . . . . . . . . 624Window naming . . . . . . . . . . . . . . . . . . . . . . . . . . 627Introduction to procedures . . . . . . . . . . . . . . . . . . . . 630Loading a script file . . . . . . . . . . . . . . . . . . . . . . . . 631Linking the user interface . . . . . . . . . . . . . . . . . . . . . 636Saving the script . . . . . . . . . . . . . . . . . . . . . . . . . . 641Using the saved script file . . . . . . . . . . . . . . . . . . . . . 642Beyond the lesson . . . . . . . . . . . . . . . . . . . . . . . . . 643

Lesson 5: Using Python in Maya . . . . . . . . . . . . . . . . . . . . 644Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 644Entering Python commands . . . . . . . . . . . . . . . . . . . . 645Using flags in Python . . . . . . . . . . . . . . . . . . . . . . . 648Using the edit flag in Python . . . . . . . . . . . . . . . . . . . 652Communicating between Python and MEL . . . . . . . . . . . . 654Beyond the lesson . . . . . . . . . . . . . . . . . . . . . . . . . 656

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 657

xiv | Contents

Page 15: Autodesk Maya 2009

Overview

IntroductionWelcome to Autodesk® Maya®, one of the world’s leading software applicationsfor 3D digital animation and visual effects. Maya provides a comprehensivesuite of tools for your 3D content creation work ranging from modeling,animation, and dynamics through to painting and rendering to name but afew.

With Maya, you can create and edit 3D models in a variety of modeling formatsand animate your models using Maya’s suite of animation tools. You can createconvincing visual simulations of rigid and soft body objects interacting in thephysical world using the computational dynamics and particles tools. Mayaalso provides a range of tools to allow you to render your animated 3D scenesto achieve photo realistic imagery and animated visual effects.

The Maya software interface is fully customizable for those users who requirethe ability to maximize their productivity. Maya allows users to extend theirfunctionality within Maya by providing access to MELTM (Maya EmbeddedLanguage). With MEL, you can customize the user interface and write scriptsand macros. In addition, a full Application Programmers Interface (API) isavailable to enhance the power and functionality of Maya. Maya also providesa Python-based Maya API for those users wishing to use it.

The content creation power of Maya is provided to users in an integrated softwareapplication that is designed to enhance user productivity and ease of use.

This section provides the following information:

n About the Getting Started lessons–Information about the lessons, where tobegin, and the order in which you should complete the lessons.

1

1

Page 16: Autodesk Maya 2009

n Before you begin–Prerequisite knowledge and skills you should possessbefore beginning the Getting Started with Maya lessons.

n Installing Maya–Information on installing Maya.

n Using the lesson files–How to access and use the lesson files for the GettingStarted with Maya lessons.

n Conventions used in the lessons–Describes the various conventions usedthroughout the Getting Started with Maya lessons.

n Using the Maya Help–Outlines the various help resources provided withyour Maya software.

n Additional learning resources–Outlines learning resources beyond what isincluded with your Maya software.

n Restoring default user settings–Describes how to reset Maya to its defaultsettings before you begin the lessons.

About the Getting Started lessonsGetting Started with Maya introduces the different areas of Maya in a set of brieflessons. The lessons are designed to let you learn these modules at your ownpace.

If you are new to Maya, this guide gets you started on your learning path. Ifyou are an existing user or are transitioning from another 3D softwareapplication, Getting Started with Maya provides a starting point forunderstanding features you haven’t yet had time to learn.

If you are a user of Maya® UnlimitedTM you can learn about the features ofyour software by going through the lessons in Getting Started with Maya Unlimitedwhich is included in the Learning Resources section of the Maya Help. If youare new to Maya, we recommend that you begin with the lessons containedwithin Getting Started with Maya.

Getting Started with Maya is not meant to replace the documentation that comeswith the Maya software. Only the commands and options used in the lessonsare explained in this manual. You will find the Maya Help provides an excellentcompanion reference to the lessons and much more.

Many of the lessons in Getting Started with Maya contain one or more separatelessons that provide step-by-step instructions for creating or accomplishingspecific tasks within Maya. You can follow the lessons in this guide from start

2 | Chapter 1 Overview

Page 17: Autodesk Maya 2009

to finish or complete only the lessons that correspond to your interests andneeds.

We recommend that any new Maya user begin by completing the following:

n Viewing the Essential Skills Movies that are available when you first startMaya.

n Completing the Maya Basics lessons (Chapter 2) which introduce manyfundamental concepts and skills related to the Maya user interface.

The version of Getting Started with Maya within the Maya Help also containsApple® QuickTime® movies for some of the lessons.

To use the lessons from the Maya Help

1 In Maya, select Help > Tutorials.

The Maya Help window displays the Getting Started with Maya lessons.

2 Click the tutorial you want to work through.

The Maya Help displays the associated lessons for that tutorial.

Before you beginBefore beginning Getting Started with Maya, you should have a workingknowledge of your computer’s operating system. You should know how touse a mouse, select menus, and enter text and commands from your keyboard.You should also know how to open and save files, copy files from a DVD toyour hard drive, and be able to navigate your computer operating system’sfile browser.

If you require an overview or review of these techniques, we recommend thatyou refer to the documentation that came with your particular computer andoperating system.

If you are new to 3D computer graphics and animation, you might want toobtain The Art of Maya (ISBN: 978-1-8971-7747-1). It explains many conceptsand techniques that are unique to the world of 3D computer graphics as theyrelate to Maya.

Before you begin | 3

Page 18: Autodesk Maya 2009

Installing MayaYou must have Maya installed and licensed on your computer system tosuccessfully complete the lessons in this guide. To operate Maya on yourcomputer you must be running a qualified Microsoft® Windows®, Linux®, orApple® Mac OS® X operating system with the recommended minimummemory and storage requirements. Maya requires a three button mouse toaccess its full functionality for menus, commands, and 3D viewing.

For complete instructions on qualified hardware and operating systems, aswell as installation and licensing of the Maya software, please refer to theInstallation and Licensing manual that came with your Maya software or checkthe Maya Features and Specification link at http://www.autodesk.com/maya.

Conventions used in the lessonsSome important conventions used throughout Getting Started with Maya areexplained here.

Maya is available for use on a wide range of operating systems. Any differencesbetween operating systems when operating Maya are identified throughoutthis book in the following ways:

(Windows), (Mac OS X), (Linux)

The screen illustrations and examples within Getting Started with Maya varyamong the Windows, Mac OS X, and Linux operating systems. Maya’s interfaceis generally consistent across these systems.

When instructed to select a menu within Maya we use the followingconvention:

n Menu > Command (For example, File > New Scene)

When you are instructed to select the option box for a particular menu itemwithin Maya, we use the following convention:

n Menu > Command > Option (for example, Create > NURBS Primitives>

Sphere > ).

4 | Chapter 1 Overview

Page 19: Autodesk Maya 2009

Using the lesson filesMany of the Getting Started with Maya lessons have accompanying lessonfiles that were created for use with the lessons. These files are included in theGettingStarted directory that was installed with your Maya software and canbe found in the following locations:

(Windows XP and Vista, 32 and 64-bit)

<drive>:\Program Files\Autodesk\Maya2009\GettingStarted

(Mac OS X)

/Applications/Autodesk/maya2009/GettingStarted

(Linux 64-bit)

/usr/autodesk/maya2009-­x64/GettingStarted

Before you use the lesson files, you need to copy the GettingStarted directoryto your Maya projects folder. Then, you need to set the GettingStarted folderas your project directory in Maya. For more information and steps, see Copyingand setting the Maya project on page 25.

Using the Maya HelpYour Maya software application comes with a comprehensive set ofdocumentation resources.

Essential Skills Movies

The first time you start Maya, the Essential Skills Movies window displays inMaya. Watch these movies to learn about the skills you need to master whenyou first use Maya. The audio for the movies is available in English, French,German, Italian, Japanese, Korean, and Mandarin.

Using the lesson files | 5

Page 20: Autodesk Maya 2009

To play the Essential Skills Movies

1 In the Essential Skills Movies window, click the buttons to play a movie.

Your computer launches the necessary multimedia player and your chosenmovie begins to play.

2 Click your multimedia player’s controls to start, stop, and pause themovie.

To close the Essential Skills Movies window or the multimedia player

1 To close the Essential Skills Movies window, click the close box in theupper right corner of the window.

If you do not want to have this dialog box automatically display whenyou start Maya, turn on the Don’t show this at startup check box.

2 To close the multimedia player, select File > Exit or click the close box inthe upper right corner of the window. (This instruction might varydepending upon which multimedia player is used)

If you want to watch the movies in the future

1 In Maya, select Help > Learning Movies.

The Learning Movies window appears.

6 | Chapter 1 Overview

Page 21: Autodesk Maya 2009

Maya Help

Your Maya software application comes installed with Maya technicaldocumentation that assists you in learning the Maya software. The Maya Helpis HTML-based, structured by module, fully searchable, and is displayed usingyour computer’s web browser.

The Maya Help is topic based and displays the major functionality categoriesfor Maya. The Maya Help can assist you in finding reference information aboutparticular topics, how to perform specific tasks, and MELTM commandreferences.

To launch the Maya Help

1 Select Help > Maya Help.

The Maya Help appears in a separate web browser window (dependingon your user preference settings). The left hand pane of the Maya Helplets you navigate to various Maya topics.

To obtain help on a particular Maya topic

1 In the Maya Help navigation pane, click the name of the Maya topic youwant information about (for example, Modeling, Animation, Dynamics,MEL commands, and so on).

The Maya Help displays the associated sub-topics and categories associatedwith the name you selected.

Maya Index and search

You can search the Maya Help directly using the index and search capabilities.With these tools you find the Maya topic you’re looking for by searching thetopic word in an alphabetic list or by directly typing the topic word(s) intothe search field and having the search tool find the documentation entriesassociated with it.

To use the Maya Index

1 In Maya, select Help > Maya Help.

The Maya Help appears in a separate window (depending on your userpreferences). The Maya Index button appears at the top of the leftnavigation pane.

2 Click the Index button.

Using the Maya Help | 7

Page 22: Autodesk Maya 2009

The navigation pane updates to display an alphabetic list at the top ofthe pane with the first index items listed.

3 Click an item/letter in the alphabetic list.

The information related to that topic appears in the right pane.

To use the Maya Help search

1 Select Help > Maya Help.

The Maya Help appears in a separate window (depending on your userpreferences). The Maya Search button appears at the top of the leftnavigation pane.

2 Click the Search button.

The navigation pane updates to display the available search methods andoptions. You search a topic by typing in a word(s) that best represent theinformation you require.

3 In the text box, type a word that best represents your search topic.

By default, all of the content in the Maya Help is searched. You cannarrow the search results by selecting a specific user guide from the dropdown list below the text box.

4 Click the Search button to begin.

The search results appear in the left navigation pane, in order of relevancy.

5 Click the desired topic from the search results list.

The information related to that entry appears in the right pane of theMaya Help.

Popup Help

Popup Help provides you with a quick method of identifying a particular toolor icon in the Maya user interface.

8 | Chapter 1 Overview

Page 23: Autodesk Maya 2009

To use Popup Help

1 Move your mouse cursor over an icon or button.

The name or description of it appears in a popup window directly overit.

To turn on the Popup Help if it does not appear

1 If you’re operating Maya on a Windows or Linux operating system:n Select Window > Settings/Preferences > Preferences.

n In the Preferences window, click the Help category and set the Tooltipsbox to Enable in the Popup Help section so a check mark appears.

n Click the Save button to close the Preferences window.

2 If you’re operating Maya on a Mac OS X operating system:n Select Maya > Preferences.

n In the Preferences window, click the Help category and click theTooltips Enable box in the Popup Help section so a check markappears.

n Click the Save button to close the Preferences window.

Help Line

The Help Line at the bottom of Maya's window shows information abouttools, menus, and objects. Like the Popup help, it displays descriptions whenyou move the mouse over icons and menu items. It also displays instructionswhen you select a tool. This is useful if you don’t know or forget how to usea particular tool.

Using the Maya Help | 9

Page 24: Autodesk Maya 2009

To use the Help Line

1 Move your mouse cursor over an icon or button.

The icon or button name and instructions about how to use that toolappear in the Help Line.

Find Menu

The Find Menu feature lets you find the location of a particular menu item.Find Menu works only on the main menu items.

To find the location of a main menu item

1 Select Help > Find Menu.

The Find a Menu Item window appears.

2 Type the menu item you want to locate in the text field, and press Enter(Windows and Linux) or Return (Mac OS X).

The possible locations for the main menu item display in the results fieldof the Find Menu window.

Additional learning resourcesBeyond the Maya Help resources within your Maya software, you can accessthe following resources to learn more about Maya or obtain technicalassistance.

The Maya Learning Path

Discover the many learning resources available from Autodesk using the MayaLearning Path. For more information, seehttp://www.autodesk.com/maya-learningpathwww.autodesk.com/maya-learningpath.

10 | Chapter 1 Overview

Page 25: Autodesk Maya 2009

The Maya Web site

The Maya Web site contains a wealth of resources related to your Maya softwareand many other related products and services. You can view the Maya Website athttp://www.autodesk.com/maya www.autodesk.com/maya using your webbrowser.

Autodesk Training

Autodesk provides a range of products and services to help you get the mostfrom your Maya software. You can purchase additional self-paced learningmaterials or attend certified instructor led training courses at Autodesksanctioned training facilities. For more information, seehttp://www.autodesk.com/maya-trainingwww.autodesk.com/maya-training.

Technical Support

Autodesk delivers technical support services for Maya globally throughtelephone and email services, as well as online eSupport services. For moreinformation, click the Support Center link from the Maya Help menu or clickthe Services and Support link on the Maya Web site.

Events and Seminars

Autodesk also runs Maya seminars and short format training courses at majorcomputing events and trade shows. For more information, seehttp://www.autodesk.com/maya-events-seminarswww.autodesk.com/maya-events-seminars.

Restoring default user settingsIf you have already used Maya or have a prior version of Maya installed, youshould restore the default settings for Maya before you begin the lessons. Thisensures that Maya appears and operates exactly as the lessons describe.

If you are an existing user of Maya we recommend that you save your existingpreferences for later use prior to restoring the default user settings.

To save your existing custom user preferences

1 Ensure Maya is not running.

Each time you exit Maya it saves the configuration of most componentsof your user interface so it appears the same when you start it the nexttime. It writes the preferences to a directory called prefs. If you rename

Restoring default user settings | 11

Page 26: Autodesk Maya 2009

the prefs directory, your original preferences will be maintained and Mayawill create a new prefs directory the next time it is run.

2 Rename your existing user preferences file to a different name; forexample, myprefs. The prefs directory path is:

Windows

(Windows XP)

\Documents and Settings\<username>\My Documents\maya\2009\en_US\prefs

(Windows XP 64bit)

\Documents and Settings\<username>\My Documents\maya\ 2009-­x64\en_US\prefs

(Windows Vista)

\Users\<username>\Documents\maya\2009\en_US\prefs

(Windows Vista 64-bit)

\Users\<username>\Documents\maya\2009-­x64\en_US\prefs

Mac OS X

/Users/<username>/Library/Preferences/Autodesk/maya/en_US/2009/prefs

Linux (64-bit)

~<username>/maya/2009-­x64/en_US/prefs

NOTE If you are running the Japanese version of Maya, change en_US in theabove directory paths to ja_JP.

If you have a previous version of Maya installed, also rename that prefsdirectory to a new name such as myprefs. Maya will load older preferencesif they exist from a previous version.

3 Start Maya and begin the Getting Started with Maya lessons.

To restore your custom user preferences after doing the lessons

1 Ensure Maya is not running.

2 Rename the previously changed preferences back to prefs.

12 | Chapter 1 Overview

Page 27: Autodesk Maya 2009

Maya Basics

Introduction

Critical to learning any software application is some initial understanding ofthe basic concepts: how that software’s world works and the fundamental skillsyou need to work in that world. If you have never used a three dimensional(3D) software application before, you may initially find Maya different comparedto 2D applications.

2

13

Page 28: Autodesk Maya 2009

If you are wondering “where do I begin?”, this chapter is the best place tostart. We recommend that you complete the lessons in this chapter so theessential concepts and skills presented become familiar to you.

This chapter covers some of the fundamental concepts and skills for Maya infour lessons:

n Lesson 1 The Maya user interface: Introduction on page 15

n Lesson 2 Creating, manipulating, and viewing objects: Introduction onpage 29

n Lesson 3 Viewing the Maya 3D scene: Introduction on page 42

n Lesson 4 Components and attributes: Introduction on page 61

Preparing for the lessonsTo ensure the lessons work as described:

n Ensure Maya is installed and licensed on your computer.If you have not installed Maya yet, refer to the Installation and Licensingmanual that accompanies your Maya software package. It outlines therequirements for installing Maya and procedures for installation andlicensing Maya on supported hardware platforms.

n If you have never started Maya on your computer before, it will start forthe first time using the default preference settings.

n If you have run Maya before, you should ensure that your Maya userpreferences are reset to their default setting. This ensures that the lessonsappear and work as described.Refer to Restoring default user settings on page 11 for instructions onresetting user preferences to the default setting.

n Unless otherwise indicated, the directions in this chapter for making menuselections assume you’re working from the Polygons menu set.

NOTE Before you perform the lessons in this book, ensure that the InteractiveCreation option for primitives is turned off by selecting Create > PolygonPrimitives > Interactive Creation and Create > NURBS Primitives > InteractiveCreation. That is, ensure a check mark does not appear beside these menuitems.

14 | Chapter 2 Maya Basics

Page 29: Autodesk Maya 2009

Lesson 1:The Maya user interface

Introduction

Just as the driver of an automobile is familiar with the dashboard of theirvehicle, it is important for you to become familiar with the Maya “dashboard.”

The Maya user interface refers to everything that the Maya user sees and operateswithin Maya. The menus, icons, scene views, windows, and panels comprisethe user interface.

Through the Maya user interface you access the features and operate the toolsand editors that allow you to create, animate, and render your threedimensional objects, scenes, and effects within Maya.

As you spend time learning and working with Maya, your knowledge of andfamiliarity with the user interface will increase until it becomes second nature.

In this lesson you learn how to:

n Start Maya on your computer.

n Use the Maya interface so that you can begin to understand where andhow to access the critical tools to get started with Maya.

n Select the menu and icon sets within Maya.

n Learn the names of tools related to the icons in Maya.

n Create a new scene view.

This first lesson contains additional explanations of the tools and conceptscompared to many of the lessons later in this manual. We suggest you takesome time to review these explanations as they lay the foundation forunderstanding where things are in Maya.

Starting Maya

To start Maya on Windows

1 Do one of the following:n Double-click the Maya icon on your desktop.

Lesson 1:The Maya user interface | 15

Page 30: Autodesk Maya 2009

n From the Windows Start menu, select All Programs > Autodesk >Autodesk Maya 2009 > Maya 2009 (Maya Complete or MayaUnlimited).

To start Maya on Mac OS X

1 Do one of the following:n Double-click the Maya icon on your desktop.

n Click the Maya icon in the Dock.

n From the Apple Finder menu, select Go > Applications and then browsefor the Maya icon and double-click it to start Maya.

To start Maya on Linux

1 Do one of the following:n Double-click the Maya icon on your desktop.

n In a shell window, type: maya.

The Maya interface

Now that Maya is running, you first need to understand what you are seeing.There are a lot of items displayed in the Maya user interface.

The best way to begin is to learn the fundamental tools and then learnadditional tools as you need them. Begin by learning some of the main tools.

16 | Chapter 2 Maya Basics

Page 31: Autodesk Maya 2009

The Maya workspace

The Maya workspace is where you conduct most of your work within Maya.The workspace is the central window where your objects and most editorpanels appear.

The Maya interface | 17

Page 32: Autodesk Maya 2009

When you start Maya for the first time, the workspace displays by default ina perspective window, or panel. There are the other components of the defaultperspective view panel:

n The panel is labeled persp at the bottom to indicate that you are viewingthe Maya scene from a perspective camera view.

n The panel has its own menu bar at the top left corner of the panel. Thesemenus allow you to access tools and functions related to that specific panel.

n The grid is displayed with two heavy lines intersecting at the center of theMaya scene. This central location is called the origin. The origin is the centerof Maya’s 3D world, and with all object’s directional values measured fromthis location.

18 | Chapter 2 Maya Basics

Page 33: Autodesk Maya 2009

In Maya, like many other 3D applications, the three dimensions are labeledas the X, Y, and Z axes. The origin is located at X, Y, Z position of 0, 0, 0. Thegrid also lies along the X, Z plane. We refer to this as a plane because you mightvisualize an imaginary, flat, two-dimensional square laying along this 3Dposition.

Maya labels the X, Y, and Z axes with a color scheme: red for X, green for Y,and blue for Z. Many tools that you use in Maya use this color scheme toindicate that you are accessing a particular item that relates to X, Y, and Z insome way.

The axis indicator shows in which direction, X, Y, or Z, you are viewing theMaya scene. The axis indicator is color coded in the red, green, and blue colorscheme and appears in the lower left corner of a view panel.

This is extremely useful if you are new to 3D, as many of the instructions inthis manual and the Maya Help assume you know where you are viewing thescene in relation to the X, Y, Z axes.

The Maya interface | 19

Page 34: Autodesk Maya 2009

Main Menu bar

Tools and items are accessible from pull down menus located at the top ofthe user interface. In Maya, menus are grouped into menu sets. These menusets are accessible from the Main Menu bar.

The Main Menu bar appears at the top of the Maya interface directly belowthe Maya title bar and displays the chosen menu set. Each menu setcorresponds to a module within Maya: Animation, Polygons, Surfaces,Rendering, and Dynamics. Modules are a method for grouping related featuresand tools. Maya® UnlimitedTM has additional menu sets (For example, Maya®

nClothTM).

You switch between menu sets by choosing the appropriate module from themenu selector on the Status Line (located directly below the File and Editmenus). As you switch between menu sets, the right-hand portion of themenus change, but the left-hand portion remains the same; the left-handmenus are common menus to all menu sets. The left-hand menus containFile, Edit, Modify, Create, Display, and Window.

To select a specific menu set

1 On the Status line, select Animation from the drop-down menu.

The Main Menu changes to display the menu set that relates to theAnimation module. In particular, menu titles such as Animate, Deform,Skeleton, Skin, and so on, appear.

20 | Chapter 2 Maya Basics

Page 35: Autodesk Maya 2009

2 Using the menu selector, choose Polygons from the drop-down menu.

The main menu changes to display the menu set for Polygons. Menutitles such as Select, Mesh, Edit Mesh, and so on, appear.

For now, leave the menu set at Polygons. You will use this set in the nextstep.

To create a primitive 3D object from the Polygons menu set

1 Select Create > Polygon Primitives > Interactive Creation and ensure thata check mark does not appear beside this item.

For this lesson, you won’t use this option.

2 From the Main Menu Bar, select Create > Polygon Primitives > Cube >.

Maya creates a 3D cube primitive object and places it at the center (origin)of the Maya workspace.

Status Line

The Status Line, located directly below the Main Menu bar, contains a varietyof items, most of which are used while modeling or working with objectswithin Maya. Many of the Status Line items are represented by a graphicalicon. The icons save space in the Maya interface and allow for quick access totools used most often.

In this lesson, you learn about some of the Status Line areas.

The Maya interface | 21

Page 36: Autodesk Maya 2009

You’ve already learned the first item on the Status line: the Menu Selectorused to select between menu sets.

The second group of circled icons relate to the scene and are used to create,open, and save your Maya scenes.

The third and fourth group of buttons are used to control how you can selectobjects and components of objects. You will learn more about selection ofobjects in later lessons.

The fifth group of icons are used to control the Snap Mode for objects andcomponents. You will begin to use these tools in a later lesson in this chapter.

The last section comprise three buttons that are used to show or hide editors,including the Attribute Editor, Channel Box, Layer Editor, and Tool Settings.The default display shows the Channel Box and the Layer Editor. When youcreate an object, like the cube for example, information about that objectdisplays in these editors. You will learn how to use these editors later in thischapter.

For better organization on the Status Line, all of the icon buttons are brokeninto groups that you can expand and collapse, as shown.

Shelf

The Shelf is located directly below the Status line. The Maya Shelf is useful forstoring tools and items that you use frequently or have customized for yourown use. You can keep the tools and items you use most frequently in alocation that provides handy access. Maya has some of the Shelf itemspre-configured for your use.

22 | Chapter 2 Maya Basics

Page 37: Autodesk Maya 2009

To create an object using a tool from the Shelf

1 From the Shelf, select the Surfaces tab in order to view the tools locatedon that shelf.

2 Select Create > NURBS Primitives > Interactive Creation to ensure that acheck mark does not appear beside the item.

For this lesson, you won’t use this option

3 From the Shelf, select the NURBS sphere icon located at the left end byclicking on it.

Maya creates a sphere primitive object and places it at the center of theMaya workspace in the same position as the cube.

TIP You can determine if this is the correct tool prior to choosing it by firstplacing your mouse cursor over the icon, the name or description of it appearsin a popup window directly over it.

The Maya interface | 23

Page 38: Autodesk Maya 2009

In your scene view the wireframe outline of the cube you created earlier inthe lesson has changed color to navy blue, and the sphere is displayed in abright green color. The sphere is now the selected object and the cube is nolonger selected. In Maya, when the object displays like this, we refer to it asbeing selected or active.

Selection of objects and components is a way of indicating to Maya that thisparticular item is to be affected by the tool or action you will subsequentlychoose. As you work with Maya, you will be selecting and deselecting itemsa lot. You will learn how to select and deselect objects later in this chapter.

Some numerical information appears in the Channel Box editor on the righthand side of the user interface. This information relates to X, Y, and Z,translation, rotation, and scaling for the active object. The X, Y, and Z Translatenumerical values are currently set to 0. This indicates that the sphere’s locationis at the origin. The Channel Box is useful for viewing and editing this typeof basic information. You will use the Channel Box later in this chapter.

24 | Chapter 2 Maya Basics

Page 39: Autodesk Maya 2009

To hide or show the Channel Box

1 To hide the Channel Box, click the Show/Hide Channel Box icon fromthe right end of the Status line.

The Channel Box disappears, and the perspective scene view expandsslightly. With the Channel Box hidden, you have more working area inyour scene view.

2 To show the Channel Box, click the Show/Hide Channel Box icon onthe Status line. The Channel Box appears in the scene view.

Copying and setting the Maya project

Before you can save your work, you need to set a project in Maya.

A project is a file directory that stores and organizes all of the files (scenes,images, materials, textures, etc.) related to a particular scene. In Maya, youcreate and work with a variety of file types and formats. The project directoryallows you to keep these different file types in their unique subdirectorylocations within the project directory.

You can create a new project directory by choosing File > Project > New.Alternatively, you can choose an existing folder to act as the project directoryif you have prepared a folder in advance.

For these lessons, the project directory will be the GettingStarted folder thatwe have created for you. Here, you will find all the template files that youneed for the lessons, and you will save your work as you learn. You need tocopy the GettingStarted folder to your Maya projects folder, and then youneed to set the GettingStarted folder as the project directory in Maya.

Copying and setting the Maya project | 25

Page 40: Autodesk Maya 2009

To copy and set the GettingStarted folder as your Maya project

1 Navigate to the GettingStarted folder that was installed with your Mayasoftware. The location of this folder depends on the operating systemthat you are using.

(Windows XP and Vista, 32 or 64-bit)

<drive>:\Program Files\Autodesk\Maya2009\GettingStarted

(Mac OS X)

/Applications/Autodesk/maya2009/GettingStarted

(Linux 64-bit)

/usr/autodesk/maya2009-­x64/GettingStarted

2 Copy the GettingStarted folder.

3 Paste the GettingStarted folder in one of the following locations,depending on the operating system that you are using:

(Windows XP, 32 or 64-bit)

<drive>:\Documents and Settings\<username>\My Documents\maya\projects

(Windows Vista, 32 or 64-bit)

<drive>:\Users\<username>\My Documents\maya\projects

(Mac OS X)

/Users/<username>/Documents/maya/projects

(Linux 64-bit)

<home directory>/maya/projects

4 In Maya, choose File > Project > Set.

5 Browse for the GettingStarted folder that you pasted in your Mayaprojects directory in step 3.

6 Select the folder and click OK.

Saving your work

Make it a habit to save your work often when working on your Maya projects.In that way, you can always open an earlier version of your work should youmake a mistake.

26 | Chapter 2 Maya Basics

Page 41: Autodesk Maya 2009

Maya refers to everything you’ve created in your workspace as the scene. Thisincludes any objects, lights, cameras and materials associated with yourworking session.

To save your Maya scene

1 Select File > Save Scene.

A file browser appears, listing the GettingStarted project directory whereyou can save your scene.

If the GettingStarted directory does not appear, you need to copy theGettingStarted folder and set it as your Maya project. See Copying andsetting the Maya project on page 25.

2 Within the GettingStarted directory, double-click the scenes folder toopen it.

3 Type: Lesson1 in the file name text box.

4 Click Save.

Maya saves your file to the scenes directory within your GettingStartedproject directory. Maya automatically saves the file with a .mb fileextension. The .mb file extension indicates that the scene was saved as aMaya binary file: the default file type for a Maya scene.

Exiting Maya

Before you exit Maya, ensure you save any work that you want to retrieve andcontinue with at a later time.

To exit Maya

1 Select File > Exit from the main menu.

Maya does one of the two following actions:

n If you have saved your scene immediately preceding the Exit command,Maya exits.

n If you have not recently saved your scene, a message prompt appears onthe screen asking if you want to save your changes. Click either Save, Don’tSave, or Cancel.

Exiting Maya | 27

Page 42: Autodesk Maya 2009

Beyond the lesson

In this lesson you began your orientation to Maya by learning:

n How to start Maya on your computer.

n The Maya workspace, and how it shows three dimensional space (X, Y, Z).

n How Maya color-codes items and tools related to X, Y, Z.

n The location of the main menus for the various modules within Maya.

n How to create a three-dimensional object from the Polygons menu.

n The location of the Status Line and how items are displayed as icons.

n About the Shelf how to create a three dimensional object from the Shelf.

n How to hide and show the Channel Box and that basic transformation,scaling, and rotational information for an object can viewed in the ChannelBox.

n How to save your work.

n How to exit Maya.

As you proceed through Getting Started with Maya you should be familiarwith the fundamental concepts and skills covered in this first chapter.

If you want to learn more about a particular tool or feature that has beenpresented in this lesson, refer to the Maya Help.

28 | Chapter 2 Maya Basics

Page 43: Autodesk Maya 2009

Lesson 2: Creating, manipulating, and viewingobjects

Introduction

Using primitive objects to model 3D forms is a great place to continue learningabout Maya. You can create many types of 3D objects using Maya and thenmove, scale, and rotate them to create more complex forms in your scene.

In this lesson, you begin to construct a classic temple using the primitiveobject creation tools in Maya. The project is not very complex and providesyou with experience in using some of the important object manipulation andviewing tools.

As you continue to work with Maya, you’ll learn how to visualize morecomplex forms using these basic objects. Maya has many advanced tools andoptions for modeling complex forms, as you will learn in later chapters.

In this lesson, you learn how to:

n Create 3D primitive objects.

n Select objects for manipulation and editing purposes.

n Move and rotate objects using your mouse.

n Move, rotate, and scale objects using numeric input.

n Duplicate objects.

n Change the viewing panels in Maya using a variety of methods so you canview your objects from different points of view.

Lesson 2: Creating, manipulating, and viewing objects | 29

Page 44: Autodesk Maya 2009

n Undo actions when you need to undo a particular task or step.

Creating a new scene

You begin your temple project by creating a new empty scene.

To create a new scene

1 Start Maya (if it is not already running).

When Maya starts, it automatically creates a new scene.

If Maya was previously running, follow steps 2 and 3.

2 From the main menu, select File > New Scene.

Maya displays the following prompt.

3 Click No.

Maya creates a new scene and delete everything that was in the previousscene.

Primitive objects

Maya provides many types of primitive types and shapes such cubes, spheres,cylinders, and planes.

Primitive objects can be used as a starting point for a wide variety of shapesand forms. The most common workflow when using primitive objects is:

n Set the construction options for the primitive when you initially create itso that it appears in the Maya scene roughly in the size and shape thatyou require.

30 | Chapter 2 Maya Basics

Page 45: Autodesk Maya 2009

n Move, scale, and rotate the primitive object into its final position eitherby direct manipulation (the move, scale, and rotate tools), or by enteringnumeric values through an editor.

n Duplicate the primitive objects to create multiple copies of the original orcreate different variations from your original primitive object.

In this section, you construct the base for the temple using a polygonal cylinderprimitive. The octagonal shape is created by modifying the creation optionsfor the cylinder tool before you create the object. If you did not modify thecylinder options you would create a round cylinder.

To create a polygonal cylinder for the base

1 Select the Polygons menu set.

NOTE Unless otherwise indicated, the directions in this lesson for makingmenu selections assume you’ve already selected the Polygons menu set.

You should also ensure that the Interactive Creation option for primitivesis first turned off by selecting Create > Polygon Primitives > InteractiveCreation to ensure the check mark does not appear beside the item.

2 From the main menu, select Create > Polygon Primitives > Cylinder >.

An option window appears.

3 In the Polygon Cylinder Options window, select Edit > Reset Settings andthen set the following options:n Radius: 10

n Height: 1

n Axis divisions: 8

n Height divisions: 1

n Cap divisions: 1

n Axis: Y

4 In the Polygon Cylinder Options window, click Create.

Primitive objects | 31

Page 46: Autodesk Maya 2009

Maya creates a cylinder primitive object that is octagonal in shape andpositioned at the center of the Maya workspace. This cylinder is 20 unitswide by one unit high, and has eight faceted sides.

NOTE You were instructed to reset the option settings as a precaution incase they had been set differently. This is a good habit to practice whenworking with tool options to avoid getting a result that was different fromwhat you expected.

The Toolbox: Layout shortcuts

The Toolbox is located on the left hand side of the Maya user interface. Itcontains icons that open tools for transforming your objects within Maya(selection, move, rotate, scale) as well as layout shortcuts for changing theviews and panel layouts.

The Quick Layout buttons shortcuts allow you to select a different panel orswitch to another layout.

You need to finish positioning the cylinder. To do this you need to see theobject from a side view to make sure it is sitting exactly on the ground plane.

To change the panel layout to view the base from a side view

1 From the Toolbox, click the Four View layout shortcut.

32 | Chapter 2 Maya Basics

Page 47: Autodesk Maya 2009

The workspace changes to a four-view layout. The perspective view islocated in the top right corner and the other views show the object fromthe top, front and side. The layout shortcuts have other options that youwill learn later in this tutorial.

It’s now possible to see the base from the side view, but it would be easierto determine the position of the base if the side view were enlarged to afull view.

2 To enlarge the side view, position the mouse cursor in the side view, andtap the spacebar of your keyboard.

The workspace changes to a single view layout with the side view in anenlarged view. It is easier to view the position of the base from this sideview. Notice that the base lies slightly above and below the ground plane(X, Z).

The Toolbox: Layout shortcuts | 33

Page 48: Autodesk Maya 2009

TIP You can position your mouse cursor in any scene view and tap thespacebar once to toggle the view. If the view is a full panel view, it will changeto a four panel view and vice versa.

The Toolbox:Transformation tools

You need to move the base slightly upwards in the Y direction so it ispositioned on the X, Z plane. To do this you use the Move transformationtool located in the Toolbox.

The upper half of the Toolbox contains the tools for transforming objects(selection, move, rotate, scale) within Maya. When you move your mousecursor over any transformation tool icon you see the name of the tool appearnext to the mouse cursor.

The tool’s name also appears in the Help Line at the bottom of the Mayawindow. The Help Line has an additional purpose: it displays summaryinstructions as you use tools that require several steps.

Selection and de-selection of objects

Before you can transform an object, you must ensure it is selected. You canselect objects by clicking them directly, or by dragging a rectangular bounding

34 | Chapter 2 Maya Basics

Page 49: Autodesk Maya 2009

box around some portion of the object to indicate what you want selected.To deselect an object, you simply click somewhere off of the selected object.

To select the base primitive object in the scene view

1 Do one of the following:

n With your left mouse button, click the object’s wireframe outline in thescene view.

n With your left mouse button, drag a bounding box around one corner oredge of the object’s wireframe.The object is selected when its wireframe outline color displays in a brightgreen color. If it is not selected, its display color is navy blue.

To use the Move Tool to adjust the position of the base

1 Select the Move Tool from the Toolbox.

A move manipulator icon appears over the primitive cylinder in the sceneview.

The Move Tool Manipulator has handles that point in the direction ofthe three fundamental axis directions of 3D space: X, Y, Z. The handlesare colored red, green, and blue based on their function related to the X,Y, Z axes and control the direction of the movement along an axis.

When you click a specific handle, it indicates that the move is constrainedto that particular axis direction.

2 In the side view, drag the green Y manipulator handle to move theprimitive cylinder upwards in the Y direction. Move it upwards enoughso that the bottom of the base cylinder is aligned with the X axis (thethick dark line of the grid)

The Toolbox:Transformation tools | 35

Page 50: Autodesk Maya 2009

The base cylinder now needs to be rotated slightly so the front of the base isparallel to a grid line. Since each facet of the octagon represents 45 degrees ofa circle, you need to rotate the object approximately half of that amount or22.5 degrees.

To use the Rotate Tool to adjust the position of the base

1 Display all four views by positioning the mouse cursor in the view andtapping the spacebar of your keyboard.

The four view panel appears.

2 Position the mouse cursor in the top view and tap the spacebar once.

The top view appears in the workspace.

3 With the base cylinder selected, choose the Rotate tool from the Toolbox.

A rotate manipulator icon appears over the primitive cylinder in the sceneview.

The Rotate Tool manipulator consists of three rings (handles), plus avirtual sphere enclosed by the rings. The colors of the handles correspondto the X, Y, and Z axes. The handles are colored red, green, and blue basedon their function related to the X, Y, Z axes and control the direction ofthe rotation around an axis.

4 In the top view, drag the green Y manipulator ring to rotate the primitivecylinder so that one of the facets of the base cylinder is aligned with thegrid as shown in the image below.

36 | Chapter 2 Maya Basics

Page 51: Autodesk Maya 2009

You are rotating the cylinder around its Y axis.

You may be asking yourself the question “How do I know if I’ve rotatedthe base exactly 22.5 degrees?” You can check the accuracy of the rotationby viewing the Channel Box. Rotate Y should be close to 22.5 degrees.

TIP You can undo and redo the last action you performed. Undo reversesthe last action you performed on a selected object. It also reverses any actionyou performed from the Edit Menu.

To undo an action select, Edit > Undo, Redo, Repeat. Maya allows youto perform multiple undos.

The Channel Box

The Channel Box is an editing panel that provides you access to an object’stransformation information and much more. It provides information on threedistinct areas for any type of object: The transform node, shape node, andinput node.

Nodes are where information about object types are kept track of within Maya.Nodes are comprised of attributes. Attributes refer to information related towhat the node is designed to accomplish. In this case, information about theprimitive cylinder’s Y axis rotation is referred to as the Rotate Y attribute. Youwill learn more about nodes later in this tutorial.

When you moved and rotated the cylinder primitive using the Move Tool,you were doing this by your own visual judgement. This will usually besufficient for many of your creative applications.

If you need to control the attribute of an object with more accuracy you cando this by entering the precise values into the appropriate attribute field ofthe Channel Box.

The Channel Box | 37

Page 52: Autodesk Maya 2009

To move and rotate the base using the Channel Box

1 With the base cylinder selected, view the Transformation attributes inthe Channel Box. Specifically, view the values for Translate Y, and RotateY.

2 In the Channel Box, adjust the attribute values so they match the aboveimage by clicking in the field and entering the correct numerical values.

This accurately positions the base in your Maya scene.

Maya named the cylinder primitive when it was first created. Renamethe cylinder to something more meaningful to your project.

To rename the cylinder primitive using the Channel Box

1 In the Channel Box, click in the field with the name pCylinder1.

2 Rename the primitive object by typing the new name: templeBase andthen pressing Enter.

38 | Chapter 2 Maya Basics

Page 53: Autodesk Maya 2009

Duplicating objects

Duplicating an existing object is a useful way to make an exact copy of itwithout having to start over. When you duplicate an item the copy takes onthe characteristics of the original. Using the Duplicate Tool you canadditionally apply transformations to the copy (move, rotate, scale).

Return to a four view layout to view what you’ve accomplished to this point.

To change the panel layout to a four view layout

1 From the Toolbox, click the Four View layout shortcut.

The workspace changes to a four view layout. It is easier to view the workfrom this four view layout.

The base for the temple is constructed of two levels and appears stepped.You duplicate and scale the templeBase object using the duplicate tool.

To duplicate the temple base

1 Display all four views by positioning the mouse cursor in the view andtapping the spacebar. Then click in the perspective view to display thebase in this view.

2 With templeBase selected, choose Edit > Duplicate Special > from themain menu.

The Duplicate Special Options window appears.

Duplicating objects | 39

Page 54: Autodesk Maya 2009

3 In the Duplicate Special Options window, select Edit > Reset Settings andthen set the following options:n Translate: 0 1.0 0

n Rotate: 0 0 0

n Scale: 0.9 1.0 0.9

n Geometry Type: Copy

n Group under: Parent

4 In the Duplicate Options window, click Duplicate Special.

Maya creates a duplicate of the templeBase object that is scaled to 0.9 ofthe original in the X, Z axes, and is one unit above templeBase. As a resultof the scale operation, the base for the temple now appears stepped.

Maya keeps track of the name of the duplicated object based on the nameof original and renames the duplicated object templeBase1.

Save your work

In the last lesson we recommended that you save your work at regular intervals.An example of this is when you have just completed a major task such asconstructing the base for the temple. With this strategy, if you ever make amistake, you can always open the previously saved version of your work andbegin from there.

To save your Maya scene

1 Select File > Save Scene.

A file browser appears showing the GettingStarted project directorywhere you can save your scene.

40 | Chapter 2 Maya Basics

Page 55: Autodesk Maya 2009

If you do not see the GettingStarted project directory, you have not yetcopied the GettingStarted folder and set it as your Maya project. Formore information, see Copying and setting the Maya project on page 25.

2 Within the GettingStarted project directory, ensure that you are savingin the scenes sub-directory.

3 Type Lesson2Base in the file name text box.

4 Click Save.

Beyond the lesson

In this lesson you continued with the fundamental tools and skills tosuccessfully learn:

n An overall workflow for constructing forms using primitive objects.

n Where the primitive object tools are located in the main menu.

n How to create a primitive object as well as reset and edit its creationoptions.

n How to change between a single view and four view panel layout usinglayout shortcuts and by tapping the spacebar of your keyboard.

n How to select objects by clicking them with your mouse.

n How to move and rotate objects using the transformation tools in theToolbox.

n That tool manipulators can constrain a transformation to the X, Y, or Zaxes.

n How to edit an object’s transformation node attributes (move, rotate, scale)accurately using the Channel Box.

n How to rename objects using the Channel Box.

n How to duplicate objects and apply transformations while doing so.

We suggest you additionally practice the following tasks on your own:

n Creating other primitive object types, with various options so that youcan understand the variations that are possible.

Beyond the lesson | 41

Page 56: Autodesk Maya 2009

n Try using the ViewCube™ located in the upper-right corner of the activescene view to change the camera’s viewing angle in relation to the objectsin the scene.

n Practice moving, rotating, and scaling objects, and changing between thevarious scene views (single perspective, four view, single side, single topetc.)

Lesson 3:Viewing the Maya 3D scene

Introduction

In the previous lesson you learned how to view your 3D scene by changingbetween single and four view layouts. It is important for you to learn how tochange your views in a more interactive manner so that you can: view yourobjects close up or far away, select objects more accurately, or view objectsfrom different angles in your perspective view.

In this lesson you learn how to:

n Understand the difference between moving objects in the scene and movingthe point of view on the scene.

n Use the dolly, track, and tumble camera tools to change the view of yourscene in both the orthographic and perspective views.

n Rotate objects using the transformation tools in the Toolbox.

n Select objects using a variety of techniques.

n Group objects together so they can be transformed as a unit.

42 | Chapter 2 Maya Basics

Page 57: Autodesk Maya 2009

n Display objects in both wireframe and shaded modes.

n Use additional primitive objects and options.

Camera tools

In the lessons so far, when you looked at an object from the top, front, or sideviews you have been viewing the scene through an orthographic view.Orthographic views appear two-dimensional because the object is displayedusing parallel projections of only two axes at a time. (Scooter images courtesyof The Art of Maya)

When you view the scene through the perspective view, you are viewing thescene in a three-dimensional manner. The perspective view simulates whatyour scene would look like from a camera’s point of view.

In Maya, you view the scene through a set of virtual cameras. These camerasare either orthographic or perspective in nature. You can adjust how thesecameras view the scene using the Camera Tools.

Camera tools | 43

Page 58: Autodesk Maya 2009

The three primary methods for manipulating the camera view are dolly, tumble,and track.

Dolly Tool

The Dolly Tool gets its name from filmmaking where a camera, mounted ona wheeled tripod, is moved towards or away from the scene. In Maya, dollyingallows you to view the items in your scene either close up or from furtherback.

To dolly the perspective view

1 Enlarge the scene view to a single perspective view.

2 Do one of the following:n (Windows & Linux) Press the Alt key and drag the mouse to the right

while holding down the right button on your mouse.

n (Mac OS X) Press the Option key and drag the mouse to the rightwhile holding down the right button on your mouse.

3 To dolly the camera outwards from the subject in the scene you canperform the same key and mouse combinations as described above butdrag the mouse to the left.

Dolly works in both the perspective and orthographic views.

44 | Chapter 2 Maya Basics

Page 59: Autodesk Maya 2009

TIP If you make an error when adjusting your camera view of the scene, youcan reset the camera to its default home setting.

To reset the camera view for a particular orthographic or perspective view:

From the panel menu, select View > Default Home.

Tumble Tool

The Tumble Tool allows you to tumble or rotate the camera’s view around aparticular center of interest to achieve either a higher or lower vantage point,or a different side angle.

To tumble the perspective view

1 Press the Alt key (Windows & Linux) or the Option key (Mac OS X) anddrag the mouse either left or right, or up or down, while holding downthe left button on your mouse.

Tumbling the view revolves the camera around the center of the sceneview, in whichever direction you drag (left, right, up or down). TheTumble Tool does not work in the orthographic views.

Camera tools | 45

Page 60: Autodesk Maya 2009

Track Tool

The Track Tool allows you to move the camera up, down, or sideways inrelation to the scene.

To track the perspective view

1 Press the Alt key (Windows & Linux) or the Option key (Mac OS X) anddrag the mouse in any direction, while holding down the middle buttonon your mouse.

The Track Tool works for both orthographic and perspective views.

NOTE Even though the objects appear to move across the screen whenoperating any of these camera tools, it is the viewing camera that is actuallymoved in relation to the scene, not the objects.

Workflow overview

The columns are made up of multiple primitives that are moved, scaled, androtated into position. Once the first column is created, with each componentnamed and accurately positioned, you will group and duplicate it to createothers.

46 | Chapter 2 Maya Basics

Page 61: Autodesk Maya 2009

To create a polygonal cube for the pedestal

1 From the Main Menu, select Create > Polygon Primitives > Cube > .

2 In the Polygon Cube Options window, select Edit > Reset Settings andthen set the following options:n Width: 1.75

n Height: 0.6

n Depth: 1.75

Leave the other options at their default settings.

NOTE If the Polygon Cube Options window does not appear, ensure thatthe Interactive Creation option for primitives is turned off by first selectingCreate > Polygon Primitives > Interactive Creation so that a check mark doesnot appear beside this menu item.

3 In the Polygon Cube Options window, click Create.

Maya creates a cube primitive and positions it at the origin.

4 In the side view, move the cube upwards (Y axis) so it rests on the topsurface of the temple base.

You can do this using the Move Tool or with the Channel Box. If youuse the Channel Box, enter a Translate Y value of 2.3.

You may find it useful to dolly or tumble the scene view to obtain a betterviewpoint.

Workflow overview | 47

Page 62: Autodesk Maya 2009

5 In the Channel Box, rename the cube columnPedestal.

To create a polygonal cylinder for the shaft

1 From the main menu, select Create > Polygon Primitives > Cylinder >.

2 In the Polygon Cylinder Options window, select Edit > Reset Settings andthen set the following options:n Radius: 0.5

n Height: 6

n Axis divisions: 12

Leave the other options at their default settings

3 In the Polygon Cylinder Options window, click Create.

Maya creates the cylinder primitive at the origin.

4 In side view, move the cylinder upwards (Y axis) so it rests on the topsurface of columnPedestal.

You can do this using the Move Tool or with the Channel Box. If youuse the Channel Box, enter a Translate Y value of 5.6.

48 | Chapter 2 Maya Basics

Page 63: Autodesk Maya 2009

5 In the Channel Box, rename the cylinder columnShaft.

The capital for the column rests on top of the column and is very similar tothe pedestal. You duplicate the pedestal and position the duplicate at the topof the column.

To duplicate the pedestal to create the capital

1 With only columnPedestal selected, select Edit > Duplicate Special >from the main menu.

The Duplicate Special Options window appears.

2 In the Duplicate Special Options window, select Edit > Reset Settings andthen set the following options:n Translate: 0 6.6 0

n Scale: 0.8 1.0 0.8

Leave the other options at their default settings.

3 In the Duplicate Special Options window, click Duplicate Special.

Maya creates a duplicate of the columnPedestal object and moves andscales it based on the options you set.

NOTE If you positioned the geometry for the column using the TransformTools and your mouse, the Y translate values may be incorrect for yourparticular model. You may want to continue positioning the objects by visualreference using your mouse.

Using the duplicate options is an alternate method for positioning andscaling duplicated objects when you can anticipate its final location.

Workflow overview | 49

Page 64: Autodesk Maya 2009

4 In the Channel Box, rename the duplicated cube columnCapital.

The base for the column rests on top of the pedestal. You will create the baseusing one half of a NURBS sphere primitive and then move and rotate it intoposition. You will do this by modifying the creation options for the sphereprimitive.

To create a NURBS sphere for the column base

1 Select Create > NURBS Primitives > Sphere > .

2 In the NURBS Sphere Options window, select Edit > Reset Settings andthen set the following options:n Start Sweep Angle: 0

n End Sweep Angle: 180

n Radius: 0.75

n Number of Sections: 8

n Number of Spans: 4

Leave the other options at their default settings.

3 In the NURBS Sphere Options window, click Create.

Maya creates a half-sphere primitive at the origin.

The sphere needs to be rotated 90 degrees and then positioned on top of thepedestal.

To rotate and position the sphere on the pedestal

1 In side view, rotate the sphere so that the dome part is pointing up.

50 | Chapter 2 Maya Basics

Page 65: Autodesk Maya 2009

This is accomplished by either of the following methods:

n Rotating the sphere about the X axis using the Rotate Tool’smanipulator handle.

n Using the Channel Box to change the Rotate X value to -90.

2 Move the sphere so it rests on the top surface of columnPedestal (TranslateY = 2.6, if you have been inputting values into the Channel Box).

3 Using the Scale Tool, scale the sphere along its Z axis (blue manipulatorhandle) so that the sphere becomes slightly squashed in appearance.

When you scale an object non-uniformly along one of its axes, you arescaling it non-proportionally.

4 In the Channel Box, rename the sphere columnBase.

Viewing objects in shaded mode

Up to this point, you have been viewing your objects in the default wireframemode. In wireframe mode, objects appear transparent except for the simple

Viewing objects in shaded mode | 51

Page 66: Autodesk Maya 2009

wire outline that indicates their position and general shape. Maya providesseveral options for displaying objects in a shaded manner.

Change the display of your scene so that the objects display as shaded objects.

To display the objects in smooth shaded mode

1 Enlarge your perspective view, and dolly and tumble the scene so youcan easily view what you’ve completed so far.

2 From the panel menu, select Shading > Smooth Shade All.

The objects in your scene display in an opaque dark gray color. You canwork with objects in either shaded or unshaded mode for the balance ofthis lesson.

Grouping objects

When you need to move, scale or rotate multiple objects as one unit it is easierif they have been grouped together so that they transform as one unit.

Many primitive objects in Maya are grouped objects. For example, the NURBScube primitive is comprised of 6 flat squares or planes that have been groupedtogether as one unit. When the plane objects are grouped together they createa hierarchy.

A hierarchy is a collection of nodes or objects that are connected together toform a unit for some purpose. Hierarchies are useful for describing how theobjects within them share similar characteristics or attributes; move, scale,rotate for example.

52 | Chapter 2 Maya Basics

Page 67: Autodesk Maya 2009

To group the objects for the column

1 Select the four objects that comprise the column simultaneously by doingone of the following:n With your left mouse button, shift-click each object in turn until the

four objects are selected in the scene view.

n With your left mouse button, drag one large bounding box aroundthe column objects in an orthographic view.

It is important that you do not select any of the templeBase objects aspart of your selection. If you accidentally select any of the base objects,deselect them.

2 From the main menu, select Edit > Group > .

3 In the Group Options window, select Edit > Reset Settings and then setthe following options:n Group Under: Parent

Leave the other options at their default settings

4 In the Group Options window, click Group.

Maya groups the objects together in a hierarchy. You will learn more abouthierarchies in the steps that follow.

The Hypergraph

The Hypergraph is a window that shows how the nodes and their connectionsare organized in your scene. You view object hierarchies and dependencies inthe Hypergraph. Use the Hypergraph to view what happens when you groupan object.

To view the Hypergraph

1 From the view menu, select Panels > Layouts > Two Panes Stacked.

The scene view splits into two viewing panels - each has their own separateview menu. You will set these to view the scene in the upper view andthe Hypergraph in the other.

2 From the lower pane menu, select Panels > Hypergraph Panel >Hypergraph Hierarchy.

The Hypergraph panel will display below the scene view panel.

The Hypergraph | 53

Page 68: Autodesk Maya 2009

3 At the top of the Hypergraph panel, select the Scene Hierarchy icon toensure the Hypergraph is displaying the scene hierarchy.

4 In the Hypergraph panel, select View > Frame All.

The Hypergraph displays the hierarchy for all of the objects in the scene.This approach to viewing the entities in the scene provides a verygraphical approach to viewing all of the various nodes in your scene.

In the Hypergraph, each node is represented as a rectangle labelled withan icon that denotes the type of information it represents (for example,surface, shading, and so on). Each node has a unique name assigned toit when it is first created. When you rename your objects, you are actuallyrenaming the node associated with that object.

Some nodes display with a line connecting them. This denotes that theyare in a hierarchy and have a dependency structure based on how theywere originally grouped.

For the temple’s column objects, the hierarchy displays each of the namedobjects under a node labelled group1. Group1 is the parent node for thishierarchy of objects.

In Maya, when the parent node (sometimes referred to as the root node)is moved, rotated, or scaled in any way, the child nodes (sometimesreferred to as the leaf nodes) underneath are also affected.

When you select objects at the top level of a hierarchy and move them,the objects within the hierarchy or group follow.

NOTE This system of nodes, attributes, and hierarchies may initially appearsomewhat complex, but it is one of the most powerful features of Maya. Thenode based architecture provides flexibility and power to create complexmodels, shaders, and animations.

54 | Chapter 2 Maya Basics

Page 69: Autodesk Maya 2009

To rename the parent node in the Hypergraph

1 In the Hypergraph, click on the group1 node so it becomes active.

In the scene view, all of the objects in the column group become selectedas a result of selecting the group at the top (parent) level of the hierarchy.

2 In the Hypergraph, right-click the top node representing group1 and selectRename from the pop-up menu.

A small text box appears in the node.

3 Enter Column as the new name.

Now that the column is grouped, you need to position it at one corner of thetemple base.

To position the column on the temple base

1 Change the display of objects to wireframe mode by tapping the 4 keyon your keyboard.

This is a keyboard shortcut. Instead of selecting the item from the menuyou can use a single key to implement the command.

TIP Many of the tools and features in Maya can be accessed using keyboardshortcuts. In Maya, these shortcuts are called Hotkeys. Some Hotkeys aredisplayed directly beside the menu item, others are listed in the Hotkey Editor.For a complete listing of available hotkeys, go to Hotkey editor.

2 In the Hypergraph, select the Column at the top node so that Columnbecomes active in the scene view.

3 In the scene view, use the Move Tool to position Column at the frontcorner of the temple base as shown below.

The Hypergraph | 55

Page 70: Autodesk Maya 2009

With your first column in position, you can now create a copy of the columnand position it on the adjacent corner of the base.

To create a duplicate copy of the column

1 With Column still selected in the Hypergraph, select Edit > Duplicate

Special > from the main menu.

The Duplicate Special Options window appears.

2 In the Duplicate Special Options window, select Edit > Reset Settings andthen set the following options:n Number of Copies: 1

Leave the other options at their default settings.

3 In the Duplicate Special Options window, click Duplicate Special.

The Hypergraph view updates to show an additional column object inthe scene. The copy also takes on the prefix name of the original groupand is now labelled Column1.

In the scene view it appears that nothing was actually duplicated. Whenan object is duplicated without any transformations the copy is positionedin the same position as the original. The two objects are on top of eachother.

You need to move the column into position on the adjacent corner of thetemple base.

To move the duplicate column into position on the base

1 In the Hypergraph, ensure Column1 is selected by clicking on its top nodeso it becomes selected in the scene view.

2 In the scene view, use the Move Tool to position Column1 on the adjacentcorner of the temple base as shown below.

56 | Chapter 2 Maya Basics

Page 71: Autodesk Maya 2009

3 From the Toolbox, click the Four View layout shortcut.

The workspace changes to a four view layout and the Hypergraph is nolonger displayed.

Selection modes and masks

It isn’t always efficient to have the Hypergraph window open when you wantto select an object at a particular level within its hierarchy. Maya allows youto select items in different selection modes depending upon your specificneeds.

There are three main types of selection modes: Hierarchy, Object andComponent. You use these modes in order to mask or limit the selection ofother objects in order to select only the types of items you want. When youuse a selection mask you are filtering out or masking items you don’t want tobe chosen as part of the selection.

The icons for the three modes appear on the Status Line.

When you first start Maya, the default selection mode is set to Objects. Thisis useful for much of your selection work with Maya, with a few exceptions.When you want to select items that have been grouped, set the selection modeto Hierarchy.

Selection modes and masks | 57

Page 72: Autodesk Maya 2009

TIP If you set the selection mask, it will remain that way until you change it again.If an item won’t select for you in Maya, you should check the selection mask settingto see if it is set correctly.

To use the Hierarchy and Combinations selection mask

1 On the Status Line, choose the Select by Hierarchy and Combinationsicon

The Selection Mask icons update to display the three selection choices.

2 On the Status Line, choose the Select by hierarchy icon.

Select by hierarchy ensures that when you select items they are selectedat their parent or root node.

3 In the scene view, shift-click Column and Column1 so they are selectedsimultaneously. (Do not be concerned that they highlight in differentcolors.)

Pivot points

A pivot point is a specific position in 3D space that is used as a reference forthe transformations of objects. All objects (curves, surfaces, groups) have pivotpoints.

When you group objects in Maya, a new node called a parent node is createdfor the group of objects. The pivot point for the group’s parent node is placedat the origin (0, 0, 0). This is useful if you later want to duplicate and rotatethe objects radially (that is, in a circular fashion around the pivot).

To group the two columns

1 Ensure Column and Column1 are selected.

2 From the main menu, select Edit > Group > .

58 | Chapter 2 Maya Basics

Page 73: Autodesk Maya 2009

3 In the Group Options window, select Edit > Reset Settings. Set thefollowing options:n Group Under: Parent

4 In the Group Options window, click Group.

Maya groups the objects together in a hierarchy and the pivot point ispositioned at the origin. (When the pivot point is relocated to the originthe Move Tool manipulator for the selected group appears at the origin.)

With the two columns grouped, you then duplicate the columns with arotation option, the groups will duplicate and rotate around the pivot pointat the origin (0, 0, 0).

To duplicate and rotate the group

1 With column group selected, select Edit > Duplicate Special > fromthe main menu.

2 In the Duplicate Special Options window, select Edit > Reset Settings andthen set the following options:n Rotate: 0 90 0

n Number of Copies: 3

3 In the Duplicate Special Options window, click Duplicate Special.

The columns are duplicated and rotated by 90 degrees with each copy.

Pivot points | 59

Page 74: Autodesk Maya 2009

Save your work

Your temple is taking shape! Save your work before proceeding to the nextlesson.

To save your Maya scene

1 To save your Maya scene, select File > Save Scene As.

2 Type Lesson3Columns in the file browser area reserved for file names.

3 Click Save.

Beyond the lesson

In this lesson, you explored additional tools and skills within Maya as youcontinued with the construction of the classic temple. In this lesson youlearned how to:

n Use your mouse to change the view of your scene using the dolly, track,and tumble camera tools in both the orthographic and perspective views.

n Rotate objects using the transformation tools in the Toolbox and theChannel Box.

n Group objects so they can be transformed as a unit.

n Display objects in both wire frame and shaded modes.

n Access the Hypergraph to view nodes and hierarchies. You are also learningthat many tasks in Maya can be completed or approached using multipletechniques.

n Rename nodes within the Hypergraph.

n Select objects in your scene using the Hypergraph.

n Use the group pivot point to your advantage when duplicating objects.

Before proceeding with the next lesson you may want to review the materialpresented in this lesson so you are familiar with the concepts and skillsassociated with them. Some suggested tasks you can try on your own include:

n Practice using the view camera tools (dolly, track, and tumble) so you cannavigate within the scene views efficiently.

60 | Chapter 2 Maya Basics

Page 75: Autodesk Maya 2009

n Practice moving and rotating objects, and changing between the variousscene views (single perspective, four view, single side, single top, and soon).

n View objects in the Hypergraph so you can understand their relationshipsand hierarchy.

Lesson 4: Components and attributes

Introduction

Working with components is an important part of the workflow when workingin Maya. Components describe objects at a more detailed level. As you editthe components of your classic temple, you will learn more about what ispossible in Maya.

In this lesson you learn how to:

n Template objects in the scene.

n Understand the difference between objects and components.

n Edit objects at their component level.

n Assign surface material attributes

n Access the Attribute editor

Template display

When your scene becomes complex, templating the display of some of theobjects in your scene allows you to more easily select only the objects youwant. When you template the display of an object, its wireframe changes toa gray color. The object(s) can still be seen, but not easily selected. This helpsto prevent you from selecting or modifying it accidentally. You can changethe display of objects to a template and use them as a modeling reference (theway a grid is used).

You need to change the display of the base and columns to template modeso that you can more easily work on the temple roof.

Lesson 4: Components and attributes | 61

Page 76: Autodesk Maya 2009

To template the base and columns

1 In the side view, with the Selection Mask set to Hierarchy, select all theobjects in your scene.

2 From the main menu, select Display > Object Display > Template.

The selected objects become templated.

For your classic temple, you need to create the entablature using a torusprimitive. An entablature is a structure that lies horizontally upon the columnsof a temple and supports the roof.

To create and position a torus primitive for the entablature

1 From the main menu, select Create > NURBS Primitives > Torus > .

2 In the NURBS Torus Options window, select Edit > Reset Settings andthen set the following options:n Radius: 8.5

n Minor Radius: 0.5

n Number of Sections: 24

3 In the NURBS Torus option window, click Create.

NOTE If the NURBS Primitives Options window does not appear, ensure thata check mark does not appear beside the Interactive Creation menu item

before selecting Create > NURBS Primitives > Torus > by first selectingCreate > NURBS Primitives > Interactive Creation.

4 In the Channel Box, rename the torus primitive Entablature.

5 Move the entablature vertically in the scene so it rests on top of thecolumns (Translate Y = 9.7).

62 | Chapter 2 Maya Basics

Page 77: Autodesk Maya 2009

Components

All objects in Maya have a transform and a shape node. Geometric shapes,like the primitives in this tutorial, have smaller parts called components. A fewexamples of components in Maya are control vertices, faces, and hulls.Components allow you to work with objects at a finer level and allow you toedit them in creative ways.

In order to change the shape of the entablature beyond the basic scaletransformations, you need to modify its component information.

To select components of the entablature

1 In the side view, dolly in for a closer view of Entablature.

2 Set the Selection Mode to Component mode.

3 Right-click the wireframe of Entablature and select Control Vertex fromthe pop-up menu.

Components | 63

Page 78: Autodesk Maya 2009

The menu that pops up is a marking menu for quickly selecting operationsrelevant to the object where you right-click the mouse. In this case, thechoices pertain to the display of the entablature’s components.

A set of small blue squares appear on Entablature called control vertices.Control Vertices (CVs) describe the shape of an object based on theirposition in space. If you move any combination of these vertices, youchange the shape of the object.

4 Drag a selection box around the top row of vertices so they becomeselected.

5 Using the Move Tool, move the vertices up vertically as shown below tochange the shape of Entablature.

6 To cancel the display of the CVs, right-click the wireframe of Entablatureonce again and select Object Mode from the pop-up menu.

The roof for the temple rests on top of the entablature. The roof for the templeis created using one half of a sphere primitive.

To create a roof for the temple

1 Select Create > NURBS Primitives > Sphere > .

2 In the NURBS Sphere Options window, select Edit > Reset Settings andthen set the following options:n Start Sweep Angle: 0

n End Sweep Angle: 180

n Radius: 8.75

n Number of Sections: 8

64 | Chapter 2 Maya Basics

Page 79: Autodesk Maya 2009

n Number of Spans: 4

In the NURBS Sphere Options window, click Create.

3 Rename the half-sphere templeRoof.

The roof needs to be rotated -90 degrees about the X axis and positioned ontop of the entablature.

To rotate and position the roof on the entablature

1 In side view, rotate the roof so that the dome part is pointing up.

2 Move the roof so it is positioned close to the top edge of Entablature.

3 Scale the roof along its Z axis (blue manipulator handle) so that the spherebecomes slightly squashed in appearance.

Now that the roof is complete, you can untemplate the templated objects.

To untemplate objects

1 On the Status Line, choose the Select by Hierarchy and Combinationsbutton.

2 On the Status Line, choose the Select by hierarchy: template button.

Select by hierarchy: template ensures that only templated objects will beaffected by a selection.

Components | 65

Page 80: Autodesk Maya 2009

3 In the scene view, drag a selection box around all the objects in the sceneso that the templated objects are selected simultaneously.

4 From the main menu, select Display > Object Display > Untemplate.

5 On the Status Line, choose the Select by hierarchy: root button.

The Attribute Editor

The Attribute Editor provides information about the various nodes andattributes for the objects and materials in your scene. Like the Channel Box,you can view and edit the basic transform information and many other keyableattributes. However, the Attribute Editor provides a more detailed display ofall attributes for a selected object.

To view object attributes using the Attribute Editor

1 In the scene view, select templeRoof so it becomes the selected object.

2 To view the Attribute Editor, click the Show/Hide icon on the Status Line.

The Attribute Editor displays the attributes for templeRoof. The variousattributes for the templeRoof object appear under various tabs. Each tabrepresents a node.

66 | Chapter 2 Maya Basics

Page 81: Autodesk Maya 2009

3 Click the templeRoof tab to see its attributes.

This tab is known as the transform node, because the most importantattributes on this tab control templeRoof’s transformation. Every visibleobject in Maya has a transform node, including cameras and lights.

4 Click the templeRoofShape tab to see its attributes.

This tab is called the shape node because the attributes establish theobject’s geometric shape or physical properties when the object is firstcreated. Most objects have shape nodes, some do not, such as the groupfor the column objects. The shape node also includes other types ofattributes, such as object display attributes.

5 Click the makeNurbSphere tab to see its attributes.

This is an input node that includes attributes related to the object’sconstruction history. The attributes of an input node are passed to anothernode subsequent in the construction history for the object—in this case,to the templeRoofShape node.

6 The last two nodes are initialShadingGroup and lambert1. If you can’tsee them, click the display arrow.

The initialShadingGroup and lambert1 nodes are default nodes that relateto the default shading material for an object. Maya uses them to establishthe initial color of objects and other settings related to shading. If youcreate your own shading materials for the temple, as you will in thefollowing steps, these nodes are replaced by the new shading nodes youcreate.

The Attribute Editor | 67

Page 82: Autodesk Maya 2009

Surface materials

The color, shininess, and reflectivity attributes of an object are controlled byits surface material (sometimes referred to as a shader, or shading material).Material attributes relate to how the object simulates a natural reaction tolight in Maya’s 3D computer world.

Maya assigns a default shading material to all objects when they are firstcreated. In this section, you learn how to assign a new material to your objects.

To assign a new material to the temple objects

1 Right-click the wireframe of Entablature and select Object Mode fromthe pop-up menu.

This changes the selection mask back to objects so you can select objectsin the scene. It is a shortcut to access this feature.

2 Drag a selection box around all the objects in your scene to select them.

TIP If objects won’t select in the Maya scene, check that your selection maskis set correctly on the Status Line.

3 From the Status Line, select the Rendering menu set using the menuselector.

The main menu changes to display the menu set for Rendering.

4 From the main menu, select Lighting/Shading > Assign New Material >Blinn.

A Blinn shading material is assigned to all the objects in the scene andthe Attribute Editor updates. Blinn shading materials (named after the

68 | Chapter 2 Maya Basics

Page 83: Autodesk Maya 2009

inventor of this shading algorithm) provide for high-quality specularhighlights on surfaces.

5 In the Attribute Editor, rename the blinn1 shading material totempleShader.

With a shading material assigned to all the objects, you need to edit the colorattributes of the templeShader material.

To edit the shading material’s attributes

1 In the Attribute Editor, click in the gray box to the right of the wordColor.

The Color Chooser appears.

Surface materials | 69

Page 84: Autodesk Maya 2009

2 Click inside the color wheel (hexagon) and drag the pointer to achievea sand color.

The exact color is unimportant for this lesson. As you adjust the colorwheel indicator, the temple objects become the same color you select inthe Chooser.

3 Click Accept to close the chooser.

You will learn more about Maya’s shading and texturing capabilities infuture lessons.

4 In the Attribute Editor menu, choose the Selected menu item, and selecttempleBase from the list.

The attributes for templeBase display in the Attribute Editor.

5 Click the templeShader node tab to see its attributes.

If you can’t see this tab, click the display arrow to the right of the tabs.

These are the same attributes you edited when you assigned thetempleShader shader to all the objects in the scene. When you first createan object, you see two default nodes for shading, initialShadingGroupand lambert1. When you assign a shading material, the two default nodesare replaced by the attribute node for the assigned shading material.

You will encounter transform, shape, input, and shading nodesthroughout your work with Maya. There are other types of nodes thatyou’ll learn about as you continue learning about Maya.

6 Close the Attribute Editor using the Show/Hide icon.

70 | Chapter 2 Maya Basics

Page 85: Autodesk Maya 2009

Save your work

You have completed this lesson. Save your work before proceeding.

To save your Maya scene

1 Select File > Save Scene As.

2 Type Lesson4Final in the file browser area reserved for file names, andthen click Save.

Beyond the lesson

In this lesson, you completed the construction of the classic temple and learnedhow to:

n Display objects in template mode.

n Select objects at their component level using selection masks and the rightmouse button.

n Assign and edit shading materials for your objects in the scene.

n Access the Attribute editor and view the various node types for objects.

As you proceed through Getting Started with Maya, we assume you are familiarwith the fundamental concepts and skills covered in this first chapter.

Before proceeding to the next chapter you may want to review the materialpresented in this lesson so you are familiar with the concepts and skillsassociated with them. Some suggested tasks you may want to do on your own:

n Practice construction of additional forms using primitive shapes by creating.additional details for your temple scene (stairs, roof details, etc.).

n Learn more about the tools and options that have been presented in thislesson, by referring to the Maya Help. To view the Maya Help, select Help> Maya Help.

Save your work | 71

Page 86: Autodesk Maya 2009

72

Page 87: Autodesk Maya 2009

Polygonal Modeling

Introduction

In Maya, modeling refers to the process of creating virtual 3D surfaces for thecharacters and objects in the Maya scene. Surfaces are vital for creating aconvincing 3D image.

Modeling is a process requiring keen visual skills and mastery of the modelingtools. The more accurate you are when modeling your forms in terms of size,shape, detail, and proportion, the more convincing your final scene will be.

There are three modeling surface types in Maya:

n Polygons

n NURBS

n Subdivision surfaces.

Each surface type has particular characteristics and benefits.

3

73

Page 88: Autodesk Maya 2009

Polygon surfaces are a network of three-or-more sided flat surfaces called facesthat get connected together to create a poly mesh. Polygon meshes arecomprised of vertices, faces, and edges.

The wireframe lines on the mesh represent the edges of each face. The regionsbounded by the edges are faces. Where the edges intersect each other is thelocation of a point called a vertex.

When a polygon mesh is rendered, its edges can be set to appear hard orsmooth. As a result, polygons can easily represent both flat as well as curved3D forms. You’ll work with these component types continuously whenmodeling with polygons.

Polygonal surfaces have a wide range of applications and are the preferredsurface type for many 3D applications including interactive games and webdevelopment applications.

Polygonal surfaces can be described with the smallest amount of data of allthe 3D surface types, and therefore, can be rendered quickly, deliveringincreased speed and interactive performance to the end user in games andother applications.

Preparing for the lessonTo ensure the lesson works as described, do these steps before beginning:

1 Select File > New Scene.

2 Make sure Construction History (below the menu bar) is on: . (Ifit is turned off, the icon has a large X across it).

3 Select the Polygons menu set.

Unless otherwise noted, the directions in this chapter for making menuselections assume you’ve already selected the Polygons menu set.

4 Make sure Display > UI Elements > Help Line is turned on.

You will use the Help Line while modeling.

5 If you have not already done so, copy the GettingStarted folder fromits installation location to your projects directory. Then, set theGettingStarted directory as your Maya project. For more information,see Copying and setting the Maya project on page 25.

74 | Chapter 3 Polygonal Modeling

Page 89: Autodesk Maya 2009

6 As you work through this lesson, remember to save your work frequentlyand increment the name of the file every so often (filename1, filename2,and so on).

In this way you’ll have earlier versions of your work to return to shouldthe need arise.

7 Make sure that Soft Selection is turned off by opening the Attribute Editorwith the Select Tool active and unchecking the box marked Soft Select.

Lesson 1: Modeling a polygonal mesh

Introduction

In this lesson, you model a helmet for an interactive game character, usingpolygonal surface modeling techniques.

In this lesson you’ll be introduced to some of the polygon modeling toolsMaya provides by learning how to:

n Use 2D image planes as a reference for constructing 3D models

n Use 3D primitives as the basis for creating more complex models

n Work with the components of a polygon mesh (faces, edges, and vertices)

n Smooth a polygon mesh

n Select the faces, edges, and vertices of polygonal meshes

Lesson 1: Modeling a polygonal mesh | 75

Page 90: Autodesk Maya 2009

n Create polygon faces by placing vertices

n Scale and extrude faces on a polygon mesh

n Move and rotate extruded polygonal meshes

n Split vertices and subdivide polygonal faces

n Combine separate meshes into one mesh

n Bridge between meshes

n Add faces to an existing mesh

n Use Snap to Grid

n Preview a smoothed high resolution version of a polygon mesh

n Harden and soften polygon edges

Setting modeling preferences

Before you create your polygon model change some of the default settings tobetter work through this lesson.

1 Select Window > Settings/Preferences > Preferences.

The Maya user preferences window appears.

In the Categories section of the Preferences window select Polygons.

2 In the Polygon Display settings, set the following:n Border Edges: On

n Edge Width: 4

This displays border edges prominently on polygon meshes. Displayingborder edges distinctively lets you differentiate them from other edgeson your models and troubleshoot issues.

3 In the Categories section of the Preferences window, choose Selection.

4 In the Polygon Selection settings, set the following:n Select faces with: Whole face

The Whole face setting lets you select polygon faces by clicking anywhereon the face (the Center setting requires you to click on the face’s center

76 | Chapter 3 Polygonal Modeling

Page 91: Autodesk Maya 2009

dot). In addition, when a face is selected in the scene, the entire faceappears highlighted.

5 Click the Save button to close the settings window.

6 Turn off the Interactive Creation option for primitives: Select Create >Polygon Primitives > Interactive Creation (no check mark).

Using 2D reference images

You can use front, side, and top views from drawings, sketches, or photographsto help visualize your 3D model in Maya, much like an architect or engineercreates their designs from the plan and elevation views of a blueprint.

You can import 2D images into your orthographic camera views as imageplanes. An image plane is a 2D object (plane) that places an image file in thescene view. By default, an image plane only appears in the camera to whichthe image plane is connected. Image planes are also used to create backgroundsand environments when rendering.

When you load an image into an image plane, it appears in your selectedorthographic view at the origin along an axis that is perpendicular to theselected orthographic view. You can refer to the image in the orthographicview to define the silhouette and character lines of your model. You can movethe image plane, change its transparency, or turn it off.

For this lesson you load two images we’ve provided for the lesson into imageplanes in the front and side orthographic views of your scene. You’ll refer tothem frequently while you model the helmet.

Using 2D reference images | 77

Page 92: Autodesk Maya 2009

To load reference images into the front and side orthographic views

1 In the Toolbox, click the Four View shortcut from the Layout Shortcutsbar.

The perspective view is located in the top right corner and the other viewsshow your scene from the top, front, and side.

2 In the front view panel menu, select View > Image Plane > Import Image.

3 Select the image file named HelmetFront.jpg.

This image can be found in the GettingStarted directory that you set asyour Maya project:

GettingStarted/PolygonModeling/sourceimages

4 In the browser, click the Open button.

HelmetFront.jpg appears in the front view and depicts a drawing of thehelmet.

5 In the side view panel menu, select View > Image Plane > Import Image.

6 Select the image file named HelmetSide.jpg.

This image can be found in the GettingStarted project directory:

GettingStarted/PolygonModeling/sourceimages

7 In the browser, click the Open button.

HelmetSide.jpg appears in the side view.

78 | Chapter 3 Polygonal Modeling

Page 93: Autodesk Maya 2009

NOTE The front and side images for this lesson were created so that the twoviews are aligned and the height of each image is identical. When you importthem as image planes, they appear at the same scale. These are importantconsiderations when you construct your own reference images in the future.Otherwise, your reference images may not align or may be at different scalesbetween the two orthographic views.

By referring to the image planes in the orthographic views as you work,you can correlate how a feature in one view, appears in another. Whilea top view reference image is useful in many cases, it isn’t critical for thislesson.

The image planes can be set so they appear partially transparent to allowyou to work with the polygonal components more easily. To do this you’llselect the front and side orthographic cameras and modify thetransparency of the images.

To modify the transparency of the reference images

1 In the front view panel menu, select View > Select Camera.

The camera for the front orthographic view is selected.

2 Display the Channel Box by clicking the Show/Hide Channel Box iconon the Status Line.

The Channel Box displays the keyable attributes for the Frontorthographic camera.

3 In the Inputs section, click the ImagePlane1 name to display the attributesfor the image plane.

4 Set the Alpha Gain attribute to a value of 0.25.

The image appears partially transparent.

5 In the side view panel menu, select the camera and change the AlphaGain setting for the side view image plane exactly as you changed thefront view image plane.

Using 2D reference images | 79

Page 94: Autodesk Maya 2009

TIP You can change the Alpha Gain at any time if you want the image planesto appear more or less transparent.

6 In the perspective view’s panel menu, select Show > Cameras totemporarily turn off the display of the image planes in the perspectiveview.

Creating a polygon primitive

You’ll create the top portion of the helmet mesh from a cube primitive usingthe image planes as a reference. Primitive objects are one method for starting3D meshes because they can be modified to create other forms.

To create a cube primitive for the helmet mesh

1 Ensure you are working in the perspective view.

2 Select Create > Polygon Primitives > Cube > .

3 In the options window, select Edit > Reset Settings, and then set thefollowing:n Width: 14

n Height: 14

n Depth: 14

n Width divisions: 1

80 | Chapter 3 Polygonal Modeling

Page 95: Autodesk Maya 2009

n Height divisions: 2

n Depth divisions: 1

4 Click the Create button.

A cube primitive is created at the origin with the dimensions you specifiedand one subdivision around the middle. This cube primitive is comprisedof four-sided polygon faces called quads. Quad polygons are usedfrequently with 3D character models as they are easily smoothed anddeform well when bound into a skeleton.

You can smooth the cube so it appears more rounded on the corners andsubdivide it into smaller faces using the Smooth feature.

To smooth and subdivide the cube primitive

1 With the cube still selected in the scene view, select Mesh > Smooth >

, and set the following options in the window that appears:n Add divisions: Exponentially

n Division levels: 2

2 Click the Smooth button

The cube primitive is smoothed and is rounded at its corners. The cubehas also been subdivided into smaller faces.

Creating a polygon primitive | 81

Page 96: Autodesk Maya 2009

The polygon faces are still four-sided even though their shape and positionhave been modified by the smooth operation.

NOTE If the top, domed portion of the smoothed cube doesn’t roughlymatch the helmet sketches as indicated in the image below, scale the cubewith the Scale Tool to make it match.

To rename the polygon mesh

1 With the cube still selected, rename the cube primitive using the ChannelBox from pCube1 to helmetmesh.

82 | Chapter 3 Polygonal Modeling

Page 97: Autodesk Maya 2009

Modeling in shaded mode

Modeling a polygon mesh in shaded mode gives you a better sense of the 3Dvolume that the model occupies as well as how any surface details appear.

You can control the shading of an object separately in each view. For example,you can display the object as shaded in the perspective view only, and set theorthographic views to display objects in wireframe mode. You can also set thedisplay settings to show both a shaded and wireframe display simultaneously.

To display the helmet mesh in Wireframe on Shaded mode

1 In the perspective view, right-click on the helmet mesh and select ObjectMode from the marking menu that appears.

This changes the selection mode to Objects.

2 Select the helmet mesh.

3 In the perspective view, select Shading > Smooth Shade All from the panelmenu.

The helmet mesh displays in smooth shaded mode.

4 From the panel menu, select Shading > Wireframe on Shaded.

The wireframe appears on the mesh as well as the shading (whether ornot the mesh is selected).

The opacity of the smooth shading in the side and front views prevents youfrom seeing the image planes behind the object. X-Ray display mode solvesthis problem by making the smooth shaded surface appear semitransparent.

Modeling in shaded mode | 83

Page 98: Autodesk Maya 2009

To display the helmet mesh in shaded X-Ray mode

1 With the helmet still selected, choose the following from the side view’spanel menu:n Shading > Smooth Shade All

n Shading > Wireframe on Shaded

n Shading > X-Ray.

The helmet mesh updates to a semitransparent shaded display with thewireframe. You can see the 2D image behind the mesh.

2 Repeat the previous step for the front view as well.

After setting the shading for the objects in the various views, you maywish to adjust the Alpha Gain setting on your image planes to changetheir transparency. As you gain experience with Maya, you’ll developyour own personal preferences for modeling in wireframe or shaded modeand switching between the various shading modes.

Model symmetry

Whenever you model an object, you should take advantage of any symmetrythat the form provides. It can save you time and effort if you work on onlyone half of the model and then later copy it across the model’s axis ofsymmetry. The sketch of the helmet is symmetrical along its center line (YZplane).

84 | Chapter 3 Polygonal Modeling

Page 99: Autodesk Maya 2009

To delete the faces on the left half of the mesh

1 In the top view, right-click on the mesh and select Face from the markingmenu that appears.

2 Drag a bounding box around the faces on the left half of the helmet meshto select them.

3 Press the delete key.

The selected faces are deleted.

You now have half as many components in your model. When you near thecompletion point of the model, you will copy the finished half across the axisof symmetry to get the complete model.

Selecting components by painting

You can delete some of the faces that are not needed on the front and lowersection of the helmet mesh using the Paint Selection Tool. This is useful whenyou need to select components that are in an irregular region and are noteasily selected using the bounding box.

To select faces for deletion using the Paint Selection Tool

1 In the Toolbox, click the Paint Selection Tool icon.

Selecting components by painting | 85

Page 100: Autodesk Maya 2009

2 In the side view, right-click the helmet mesh and select Face from themarking menu that appears.

3 In the side view, paint select the faces that appear along the front andlower areas of the mesh (see image) by dragging the mouse over the faces.

NOTE The Paint Selection Tool only selects components on the mesh thatface towards the camera.

4 Press the delete key to delete the selected faces.

5 Tumble the perspective view to review your work so far.

The edges that reside along the outside perimeter of a polygon mesh,called border edges, are displayed with a thicker line than the interioredges on the mesh. You set this display setting early in the lesson so youcould differentiate this edge type from other edges.

86 | Chapter 3 Polygonal Modeling

Page 101: Autodesk Maya 2009

Selecting edge loops

In the top view, the rows of edges immediately above and below the X axis,and the row to the right of the Z axis are not straight. You’ll want to align theedges in these rows (referred to as edge loops) by snapping them to the gridusing the Move Tool. An edge loop is a path of polygon edges that are connectedin sequence by their shared vertices. Edge loop selections are very useful whenyou model using polygons.

To align edges on the helmet mesh

1 Right-click the mesh and select Edge from the marking menu that appears.

Maya’s component selection mode is set to edges.

2 Double-click one edge in the edge-loop directly below the X axis.

The edge loop is selected.

3 On the Status Line, turn on the Snap to Grids feature by clicking the icon.

Snap to Grids lets you move selected components to the closest grid lineor grid intersection point. When many components are selected, you canalign them to each other via the grid simultaneously.

4 In the Toolbox, double-click the Move Tool to display its tool settings.

5 In the Move Snap Settings, turn off the Retain component spacing setting.

Selecting edge loops | 87

Page 102: Autodesk Maya 2009

6 In the top view, click-drag the blue arrow on the Move Tool manipulatordownwards a small distance.

The edge loop immediately snaps to a lower grid line. It is not positionedat the location you want, but all of the edges in the loop you selected arenow aligned to each other.

7 On the Status Line, turn off the Snap to Grids feature by clicking its icon.

8 With the Move Tool still active in the top view, drag the manipulatorarrow upwards a short distance so the edge loop is positioned roughly atits original location (which should be at the second grid line below theX axis).

9 Using the steps described above, align the other edge loop that appearsabove the X axis and then align the edge loop directly to the right of theZ axis. (Remember to turn on and off Snap to Grids as required.)

When you have finished, the edge loops nearest the X and Z axes arealigned. (see image below)

88 | Chapter 3 Polygonal Modeling

Page 103: Autodesk Maya 2009

Editing components in the orthographic views

Component selection and transformation is one fundamental method forediting the shape of a polygon mesh. As you model, you’ll find yourselffrequently examining and then refining the position of the polygoncomponents (vertices, edges, and faces) while working in the various sceneviews so they match the reference images on the image planes.

To manually reposition the vertices on the rear of the helmet

1 Right-click the helmet and select Vertex from the marking menu thatappears.

2 In the side view, select the pair of vertices at the rear lower edge (seeimage) by dragging a bounding box around them.

3 In the Toolbox, click the Move Tool.

4 In the side view, click-drag the blue arrow on the Move Tool manipulatortowards the right until the vertices are repositioned so that your helmetmatches the reference sketch on the image plane.

By moving the vertex as well as the vertex adjacent to it along the axisof symmetry, you ensure that the symmetrical shape of the helmet ismaintained. If you move one vertex independently of the other it mayresult in an unwanted bump or valley in the mesh. These types ofanomalies will become more apparent when you copy the completedhalf of the mesh across the axis of symmetry.

Editing components in the orthographic views | 89

Page 104: Autodesk Maya 2009

5 Repeat steps 2 through 4 for the other pairs of vertices on the rear of thehelmet. Ensure that the edge loops appear smooth in relation to eachother.

When you have finished, the back region of the helmet should closelymatch the reference image on your image plane.

6 In the side view, select other pairs of vertices along the top and front ofthe helmet and move them in a similar fashion so they match thereference image. Do not reposition the vertices for the top of the faceshield yet.

TIP You can click in the center of the Move Tool manipulator to drag a vertexselection freely.

90 | Chapter 3 Polygonal Modeling

Page 105: Autodesk Maya 2009

Next, you’ll reposition the border edges that lie along the bottom edge of themesh. You can select these edge types using the Select Border Edge Tool.

To reposition the lower border edges on the helmet

1 In the side view, select the lowest horizontal edge loop on the helmet bychoosing Select > Select Border Edge Toolfrom the main menu, and thenclicking the first and then the last edge on the loop as indicated in theimage below.

2 Using the Move Tool, drag the selected edge loop downwards until theleft hand vertex roughly matches the lower edge indicated in the referencesketch.

3 In the side view, select and reposition the remaining vertices individuallyon the edge loop using the Move Tool so they match the reference sketch.

Editing components in the orthographic views | 91

Page 106: Autodesk Maya 2009

NOTE Up to this point in the lesson, you’ve been instructed to repositionthe vertices on the helmet mesh only within the side view (Y, Z plane). Onceyou achieve the shape you want in the side view you will then concentrateon how the model appears when viewed from the front and perspectiveviews.

To edit the border edges on the upper edge of the face shield

1 From the Select menu, choose Select Border Edge Tool.

2 In the side view, click the first border edge that will be used as the upperedge of the face shield, then click the last border edge (see image).

The border edges in between are selected.

3 In the Toolbox, select the Rotate Tool by clicking its icon.

4 In the side view, click-drag the rotate manipulator in a clockwise directionuntil the border edges are rotated at roughly the same angle as thecorresponding edge in the reference sketch.

92 | Chapter 3 Polygonal Modeling

Page 107: Autodesk Maya 2009

5 With the border edges still selected, click the Move Tool again and dragthe green manipulator upwards to match the location of the border edgesin the reference sketch.

6 Reposition the pairs of vertices on the upper front of the helmet to matchthe reference sketch.

Editing components in the orthographic views | 93

Page 108: Autodesk Maya 2009

At this point in the lesson, the outline of your helmet should roughly matchthe helmet in the side view reference image. If it doesn’t, review the earliersteps in this lesson and make any adjustments to your polygonal mesh asrequired.

If you view your helmet in the front orthographic view, you’ll notice that thehelmet shows a wider profile from this view than the reference sketch. In thenext steps you’ll correct this using the front and top orthographic views ofthe helmet for reference.

To reposition vertices on the side of the helmet to match the sketch

1 Display the front view.

2 In the front view, select the vertices that extend beyond the outline ofthe helmet as shown in the reference sketch (see image).

94 | Chapter 3 Polygonal Modeling

Page 109: Autodesk Maya 2009

3 In the front view, move these vertices to the left until they match thewidest area of the helmet in the reference sketch (see image).

When you view your helmet from the top orthographic view the regionbetween the side and rear of the helmet appears a bit flat in relation to theother areas. To correct this you can move the other vertices in this regionoutwards in a similar fashion so the curvature in this area appears fuller andmore rounded. However, viewing only from the orthographic views can belimiting, and you should also use the perspective view to examine the mesh.

To examine the mesh using the perspective view

1 Enlarge the perspective view.

2 Dolly and tumble the perspective view while you closely examine thehelmet mesh.

As you examine the vertices along any particular edge loop, the vertices onthe mesh should appear to cascade in a smooth gradual fashion to create thecurvature of the mesh with no undesirable spikes or dips.

Ensuring that the mesh appears relatively smooth at various stages throughoutthe modeling process will reduce the possibility for issues when you create ahigh resolution version of the mesh later on.

If you find areas where one vertex (or more) appears to protrude outwards (orrecedes) on the mesh in relation to neighboring vertices, you can correct theseprotruding regions by repositioning the affected vertices in the perspectiveview.

Editing components in the orthographic views | 95

Page 110: Autodesk Maya 2009

Editing components in the perspective view

Repositioning polygon components in the perspective view can be morechallenging when compared to the orthographic views because your frame ofreference changes as you track, dolly, or tumble the 3D view.

By default, the Move Tool lets you reposition components in relation to worldspace coordinates. That is, the movement of a component is referenced to adirection based on the center of the 3D scene and the X, Y, or Z axes.

It is also possible to set the Move Tool to move objects and components basedon other coordinate systems, such as object space and local space.

In addition, you can also move a polygon component in relation to itssurrounding mesh. For example, you can select and move a vertex in adirection that is perpendicular or normal to its surrounding surface mesh. Thisis a useful technique for correcting any protruding vertices on the mesh.

To move a vertex on the mesh in a direction normal to the mesh

1 Dolly and tumble the perspective view while examining the mesh untilyou find vertices that protrude outwards from the mesh in an unwantedfashion.

2 In the Toolbox, double-click the Move Tool to display the Move Settingseditor.

3 In the Move Settings editor, in the Move section, turn on the Normaloption.

96 | Chapter 3 Polygonal Modeling

Page 111: Autodesk Maya 2009

4 In the perspective view, click the vertex you wish to reposition.

The vertex highlights and the Move manipulator appears to indicate thethree directions of movement that are possible in this mode.

The U and V handles slide the vertex in relation to its associated edges,while the N handle moves the vertex either away or towards the meshdepending on the direction you move your mouse.

5 Drag the N handle outwards or inwards depending on what’s requiredfor that particular vertex. Dolly or tumble the view as required to examinethe mesh after you’ve done this and make any modifications as necessary.

6 Repeat the above steps for any other protruding or receding vertices onthe mesh until you are satisfied that the mesh appears smooth.

7 Before you proceed to the next section, double-click on the Move Tooland return the Move setting to the default World setting.

If you examine your model in the perspective view your helmet mesh shouldnow match the reference sketches as they appear in both the front and sideimage planes (see image below). The mesh should also have a relatively uniformdistribution of polygon faces on the mesh and the edge loops should flowsmoothly.

Editing components in the perspective view | 97

Page 112: Autodesk Maya 2009

Drawing a polygon

To create the lower front region of the helmet (that is, the region that wouldprotect the mouth and jaw of the wearer) you’ll create a polygon for the crosssection of the lower front region by manually placing vertices using the CreatePolygon Tool (Mesh > Create Polygon Tool).

To place vertices for a polygon

1 In the side view, select Mesh > Create Polygon Tool > .

The Create Polygon Tool settings editor appears.

2 In the tool settings editor, set the following options:n Limit the number of points: On

n Limit points to: 6

These settings specify that a closed polygon face will be created once youhave placed six vertices in the scene.

3 In the side view, place six points for the profile as it appears in crosssection of the lower front region of the helmet (see image below). Ensurethat you place the vertices in a counter-clockwise direction for this step.

The new polygon face is created along the YZ plane (the axis of symmetryfor the model).

98 | Chapter 3 Polygonal Modeling

Page 113: Autodesk Maya 2009

4 Press the q key to quit the Create Polygon Tool when the polygon faceis complete.

The new polygon component remains selected in Object Mode.

NOTE If the polygon face doesn’t appear shaded in the side view but doesappear shaded in the perspective view, it means that the polygon face andthe image plane lie on exactly the same plane. You can correct this by movingthe image plane backwards in the side view so it doesn’t lie directly on theYZ plane, but this step is not critical to the success of the steps that follow.

You’ll extrude this polygon face to create the remainder of the lower frontregion of the helmet. Before you can extrude the new face it needs to beselected in Face mode. You can do this quickly by converting the existingselection to Faces.

To convert the object selection to face selection

1 With the face still active in Object Mode, choose Select > ConvertSelection > To Faces.

The selection is converted to a face selection.

TIP You can also press Ctrl + F11 or Ctrl + right-click on the selected objectand choose To Faces > To Faces from the marking menu that appears.

Drawing a polygon | 99

Page 114: Autodesk Maya 2009

Extruding polygon components

You can create new polygon components from existing ones using the Extrudefeature (Edit Mesh > Extrude). When you extrude a polygon component (forexample, a face, edge, or vertex), you create additional polygon componentsfrom the ones you selected. Using the Extrude feature you will:

n Create the lower front region of the helmet by extruding the polygon faceyou created in the last section of the lesson.

n Extrude edges around the face shield and along the lower bottom edge.

To extrude the polygon face for the lower front region

1 Enlarge the scene view to a single perspective view.

2 With the polygon face still selected, choose Edit Mesh > Extrude.

The extrude manipulator appears on the selected face.

3 In the perspective view, drag the blue arrow on the manipulator to extrudea section of mesh out from the face (positive X) a distance ofapproximately one half a grid unit (see image).

4 Press the g key to extrude again.

5 Click the large circle that surrounds the manipulator to display the rotatemanipulators and then drag the green circular manipulator to rotate theangle of the extrusion to match the angle in the reference sketch (seeimage) and then drag the arrow manipulator a second time to extrude asecond section of mesh.

100 | Chapter 3 Polygonal Modeling

Page 115: Autodesk Maya 2009

TIP As you change the angle of rotation and extrude the mesh you can alsomomentarily switch between the move or scale manipulators to fine tunethe position and scale of each section as you extrude it.

6 Press the g key once again and create a third extruded region using themanipulator to move, rotate, or scale the extruded segment of the meshso you position it correctly when compared to the reference sketch (seeimage). You may also want to view the extrusion from either the top orfront view to ensure your extrusion doesn’t extend outwards more thanthe side region.

7 Save your work.

To delete unwanted faces on the extruded mesh

1 Tumble the perspective view until you can view the inside of the lowerfront region (see image below).

Extruding polygon components | 101

Page 116: Autodesk Maya 2009

2 Select the faces that appear on the inside of the mesh you just extruded,including the faces on either end of the extrusion.

These faces were required for creating the extruded portions of the lowerregion but are not needed beyond this point.

3 Press the Delete key to delete the selected faces.

When you are finished, a gap will exist between the last extruded segmentof the lower region and the helmet mesh.

You’ll combine these separate meshes together and then create a mesh thatbridges between them in the next section of the lesson. To prepare for thebridge, you need to extrude more edges on the helmet mesh so that the numberof edges match when you create the bridge.

102 | Chapter 3 Polygonal Modeling

Page 117: Autodesk Maya 2009

To extrude the bottom edges of the helmet mesh

1 In the perspective view, select the lower edges of the helmet mesh usingSelect > Select Border Edge Tool.

2 Select Edit Mesh > Extrude, then drag the blue arrow manipulator in adirection towards the inside of the helmet to create a row of edges thatare perpendicular to the selected bottom edges. Extrude these edges adistance that is approximately one grid unit in depth (see image below).

To extrude top and side edges for the face shield

1 In the perspective view, select the upper and side edges on the helmetmesh using Select > Select Border Edge Tool (see image below).

2 Select Edit Mesh > Extrude and then drag the blue arrow on the extrudemanipulator in a direction towards the inside of the helmet to createedges that are perpendicular to the top and side edges of the face shield.Extrude these edges a distance that is approximately one grid unit indepth (see image below).

Extruding polygon components | 103

Page 118: Autodesk Maya 2009

To move vertices on the lower front region to match the reference sketch

1 In the perspective view, right-click on the helmet and select vertex modeto change the selection type to vertices.

2 Select the four vertices on the lower front region of the helmet that arenear the axis of symmetry (see image below) and using the Move Tool,move the selected vertices upwards by dragging the green arrow on theMove Tool manipulator so that the lower front region of the helmetmatches the reference sketches as they appear in the various orthographicviews.

3 Adjust any vertices on the lower region that may require minorrepositioning by selecting and moving them as necessary.

104 | Chapter 3 Polygonal Modeling

Page 119: Autodesk Maya 2009

Bridging between edges

Next you’ll connect the lower front region to the helmet mesh. You can createmeshes that bridge between one or more border edges of a mesh using theBridge feature (Edit Mesh > Bridge).

When using the bridge feature you must ensure that:

n the edges to be bridged are in the same polygon mesh. That is, you mustcombine the two meshes into one using the Combine feature, before youperform the bridge.

n you select an equal number of border edges on either side of the region tobe bridged.

To combine the two meshes into one

1 In the perspective view, right-click the mesh and select Object Mode fromthe marking menu that appears.

2 Select the helmet mesh, and then shift-select the lower front mesh, soboth meshes are selected.

3 Select Mesh > Combine.

The two meshes are combined into one. When you select either objectnow, the other is also selected because they are in the same mesh.

The edge of the mesh on the lower front region of the helmet is comprisedof five edges. The corresponding region on the side region of the helmet only

Bridging between edges | 105

Page 120: Autodesk Maya 2009

has three. You can increase the number of edges on the lower side region byinserting two edge loops across the mesh. Inserting two edge loops in thisregion of the mesh also divides the large faces so they better match the sizeof the other faces on the rest of the mesh.

To insert edge loops on the side region of the helmet

1 Select Edit Mesh > Insert Edge Loop Tool > .

The Insert Edge Loop Tool settings editor appears.

2 In the tool settings editor, set the following options:n Maintain Position: Relative distance from edge

3 In the perspective view, click-drag the edge on the side region of thehelmet near the bottom of the edge as indicated in the image below.Without releasing the mouse button, drag the mouse upwards about onethird of the distance along the edge and then release the mouse buttonto insert the edge loop.

NOTE Click-dragging an edge when using the Relative option inserts an edgeloop that closely matches the existing edge layout on the mesh. That is, thelower region of the mesh is much wider near the front than at the rear. TheRelative setting adjusts the position of the edge loop locator based on thistopology so is ideal in these situations. When you click-drag using the Relativeoption, remember to click near the edge whose layout you want the edgeloop to match.

4 With the Insert Edge Loop Tool still active, click-drag the side region ofthe helmet near the top of the same edge and insert a second edge loopabout two thirds of the distance along the edge.

106 | Chapter 3 Polygonal Modeling

Page 121: Autodesk Maya 2009

5 Press the q key to return to selection mode, and click anywhere off themesh to unselect the edges.

Now that you’ve inserted the necessary edges, you can proceed withcreating the bridge.

To bridge between the lower front and side region of the helmet

1 Choose Select > Select Border Edge Tool and then click the border edgeson both the lower front as well as the side region of the mesh where youwant the bridging mesh to be constructed. (You should have five edgesselected on either side).

TIP When you select border edges using the Select Border Edge Tool youcan click on the first and last edge in a series on one side of the bridge andthe tool will select the edges in between.

Bridging between edges | 107

Page 122: Autodesk Maya 2009

2 Select Edit Mesh > Bridge > .

3 In the Bridge Options window, set the Divisions to 0, then click the Bridgebutton to create the bridge.

4 Press the q key to return to select mode, and click anywhere off the meshto unselect the edges.

NOTE If your bridge appears to twist or cross over itself it indicates that thetwo meshes have their surface normals mismatched. In this particular case itlikely indicates that you did not create the original profile shape for the lowerfront by placing the six vertices in a counter-clockwise direction.

If this occurs you must undo your steps to the point immediately beforeyou combined the two meshes and then reverse the surface normals ononly the lower front section by selecting it and then selecting Normals> Reverse. You can then redo the instructions in this section as required.

Adding polygons to a mesh

For the protective face shield on the helmet, you'll create one large multi-sidedpolygon using the Append to Polygon Tool and then split it into multiplefour-sided polygons (quads) so that the new polygons match the existingfour-sided topology of the helmet mesh.

To create the face shield using the Append to Polygon Tool

1 Tumble the perspective view so you can see all of the edges surroundingthe area for the face shield.

108 | Chapter 3 Polygonal Modeling

Page 123: Autodesk Maya 2009

2 Select Edit Mesh > Append to Polygon Tool > .

3 In the Append to Polygon Tool settings window, set the following:n Keep new faces planar: Off

If the planar option is on, the Append to Polygon Tool will not create amulti-sided polygon as the edges you’ll select do not form a planar region.

4 In the perspective view, click once on the top inner border edge of thehelmet mesh to indicate which mesh you are appending to, and thenclick the same edge a second time to begin the append operation (seeimage below).

5 Click the bottom edge of the face shield that is opposite the first edgeyou just clicked.

A polygon appears that spans the two edges.

6 Continue to click the remaining border edges in a counter-clockwisedirection around the opening for the face shield (see image above) untilyou reach the last edge.

7 When you are finished clicking the perimeter border edges for the faceshield, press the q key to quit the tool.

The multi-sided polygon is completed and added to the existing mesh.Multi-sided polygons are also referred to as n-gons.

Adding polygons to a mesh | 109

Page 124: Autodesk Maya 2009

Ideally, all faces should be four-sided to match the other faces on the helmetmesh. In the next section, you'll split the n-gon vertically and horizontallyinto several smaller four-sided polygons using the Split Polygon Tool.

Splitting polygon faces

Earlier in the lesson you split the helmet mesh by inserting edge loops acrossthe mesh. You can split localized areas of a mesh using the Split Polygon Tool.When using the tool you draw a line across the faces to indicate the locationfor the split. You'll begin by vertically splitting the face shield.

To split the face shield vertically

1 Select Edit Mesh > Split Polygon Tool > .

The Split Polygon Tool settings editor appears.

2 Set the following options:n Split only from edges: On

n Use snapping points along the edge: On

n Snapping tolerance: 100

These settings let you begin and end your split at a location thatcorresponds exactly with an edge and lets you snap to the midpoint andends of the edge you select. (The number of points setting of 1 ensuresthis). These settings will help to ensure that the faces you split alignexactly and that the four-sided topology of the mesh is maintained.

110 | Chapter 3 Polygonal Modeling

Page 125: Autodesk Maya 2009

3 Tumble the camera in the perspective view so you can view both theupper inner edges of the face shield as well as the lower inner edges.

4 Click-drag the top inner edge of the face shield to indicate the start ofthe split (see image below). Drag the mouse to position the vertex untilit stops at the right side of the edge.

5 Click-drag on the lower inner edge of the helmet mesh to indicate theend of the split (see image). Drag the mouse to the right until the vertexstops at the right side of the edge.

6 Press the y key to split the face.

7 Press the g key to select the Split Polygon Tool again, and then continueto split the face shield vertically at the other locations specified in theimage below. Remember to press the y key after each split and then theg key to select the tool again.

When you are finished the n-gon for the face shield will be split into fouror five new polygons (depending on how you've constructed your mesh).

One polygon on the side of the face shield will still be five-sided. To correctthis, you'll also split the face shield horizontally. Splitting the face shieldhorizontally will also let you modify its shape afterwards.

Splitting polygon faces | 111

Page 126: Autodesk Maya 2009

To split the face shield horizontally

1 In the perspective view, with the Split Polygon Tool still active, click-dragthe inner side edge (see image) to indicate the start location for thehorizontal split.

2 In the side view, click-drag the front vertical border edge of the face shield(this border edge lies on the axis of symmetry) and release the mousebutton at the mid-point along the edge where the vertex naturally snaps(as if a magnet were attracting it towards that location).

3 Press the y key to split the faces.

112 | Chapter 3 Polygonal Modeling

Page 127: Autodesk Maya 2009

NOTE When you split across multiple faces at the same time you only needto click an edge to indicate the start point for the split and on a second edgeto indicate the end point. The Split Polygon Tool automatically splits theedges in between.

4 Press the q key to quit the Split Polygon Tool.

In the next steps you'll reposition some of the vertices along the horizontalsplit to make the face shield protrude outwards a small amount.

To adjust the shape of the face shield

1 In the side view, select the middle two vertices at the front of the faceshield and use the Move Tool to move the vertices outwards (+Z) a smallamount (see image).

2 In the perspective view, select the remaining middle vertices on the faceshield one at a time and reposition them outwards a small distance usingthe Move Tool with the Move Setting option set to Normal.

Splitting polygon faces | 113

Page 128: Autodesk Maya 2009

TIP Tumble the perspective view so you can see the relationship betweenthe vertices as you move them outwards.

3 Reset the Move Tool's Move Settings to World before continuing to thenext steps.

To create the diagonal grill vents on the lower front of the helmet you’ll insertedges on the face, reposition some of the vertices, and then extrude some ofthe faces.

To insert multiple edges for the diagonal grill vents

1 Select Edit Mesh > Insert Edge Loop Tool > .

2 In the Insert Edge Loop Tool Options window, set the following:n Multiple Edge Loops: On

n Number of edge loops: 4

n Auto Complete: Off

These settings let you insert four evenly spaced edges on the face whereyou want the grill vents to appear.

3 In the perspective view, click the border edge of the face where the grillvents will appear and then click the edge directly opposite that borderedge (see image).

114 | Chapter 3 Polygonal Modeling

Page 129: Autodesk Maya 2009

4 Press the y key to complete the edge loop insertion

5 Click off the mesh to deselect the edges.

6 Press the q key to exit the tool and return to selection mode.

To make the grill vents appear diagonally you’ll select the vertices on the rightside and then slide them downwards using the Move Tool.

To move vertices along an edge using the Move Tool

1 Right-click the helmet mesh and change the selection mode to Vertex.

2 Select the vertices on the right side of the grill feature (see image below).

3 Double-click the Move Tool icon to display the Move Tool’s settingseditor.

4 In the Move Tools’ settings editor, click the Set to Edge button.

The vertices appear unselected temporarily. The Move Tool expects youto select an edge it will reference for the axis of movement.

5 Click an edge that is on the same line of the edges as the vertices youselected.

The Move Tool manipulator appears and is aligned to the edge youselected. The vertices appear selected again indicating that the Move Toolis now set to move those vertices along the axis defined by the edge youselected.

Splitting polygon faces | 115

Page 130: Autodesk Maya 2009

6 Drag the red arrow on the Move manipulator downwards to move thevertices so that the shape of the faces for the grill are more diagonal (seeimage).

NOTE Make sure you do not move the vertices so that the lowest vertextouches the corner vertices or you’ll create an edge that has zero length.

7 Click off the mesh to deselect the vertices.

8 Before proceeding to the next section, double-click the Move Tool andreset the tool settings by clicking the Reset Tool button.

To make the grill vents three-dimensional, you’ll extrude some of the thindiagonal faces inwards.

To extrude the faces for the grill feature

1 Right-click the helmet mesh and change the selection mode to Face.

2 Beginning at the bottom of the grill feature, shift-select the two diagonalfaces as indicated in the image below.

116 | Chapter 3 Polygonal Modeling

Page 131: Autodesk Maya 2009

3 Select Edit Mesh > Extrude.

The Extrude manipulator appears.

4 Drag the blue arrow on the Extrude manipulator towards the helmet ashort distance to create the two recessed vents for the grill.

5 Press the q key to quit the Extrude feature.

Splitting polygon faces | 117

Page 132: Autodesk Maya 2009

6 Shift-select the two side faces on the grill vents that lie on the axis ofsymmetry and delete them (see image below). These faces will not berequired when you create the opposite half of the helmet.

7 Save your work before proceeding to the next section.

Terminating edge loops

When you inserted the edges for the grill vents the adjacent face was changedfrom four-sided to eight-sided as a result of the splitting that occurred alongthe shared edge.

This situation can easily occur when you are splitting polygons in a localizedregion of a mesh, and should be anticipated if maintaining four-sided polygonsis a constraint for your polygon models.

When this occurs you’ll need to find a way to gradually divide the n-gonsinto four-sided regions by terminating the edge loops. Terminating edge loopsis when you split a multi-sided n-gon gradually into multiple four-sidedpolygons.

When you do this, a single vertex may have five or more shared edges comingout of it as a result. This process lets you create regions on a mesh that havemore detail while maintaining a particular mesh type—four-sided polygonsin this case.

118 | Chapter 3 Polygonal Modeling

Page 133: Autodesk Maya 2009

To manually split the multi-sided polygon into three four-sided polygons

1 Select Edit Mesh > Split Polygon Tool.

2 In the perspective view, click-drag on the top side edge of the top grillvent. Drag your mouse so the vertex is positioned at the bottom of theedge (see image).

3 Click-drag on the top edge of the multi-sided polygon and slide the vertexto the right end of the edge (see image).

4 Press the y key to split the face.

The region above the split edge appears like a polygon but is actuallyfour-sided because of the edges on the grill vent.

5 Split the side edge on the bottom grill vent in a similar fashion byclick-dragging your mouse so the vertex is positioned at the top of theedge (see image below).

Terminating edge loops | 119

Page 134: Autodesk Maya 2009

6 Click-drag the bottom edge of the multi-sided polygon and slide thevertex to the right end of the edge (see image).

7 Press the y key to split the face.

Your multi-sided face is now split into three four-sided faces, maintainingthe overall quad topology on the helmet mesh.

8 Press the q key to exit the Split Polygon Tool.

Deleting construction history

Maya keeps track of the options, attribute settings, and transformations madeto an object via its construction history. Construction history is useful whenyou’re working on a surface and want to edit an attribute from an earlier stageof the model’s development.

The simplest way to access the construction history for an object is via itsvarious input nodes in the Channel Box or via the Attribute Editor. Selectingan input node displays the attributes associated with that particularmodification to the object. You then edit the attributes on that node asrequired and the surface updates.

For example, the input nodes for the helmet mesh include: polyCreateFace,polyCube, polyExtrudeFace, polySmoothFace, polyMoveVertex, polyUnite,and so on. You can associate the steps in creating the helmet mesh with nodesthat are related to a particular stage of its construction history.

120 | Chapter 3 Polygonal Modeling

Page 135: Autodesk Maya 2009

As you near the completion of a model, these construction history nodes arenot required. If your production work entails having another person textureor animate the model, you’ll want to delete these history nodes from theobjects in your scene altogether so another user doesn’t accidentally changeyour work.

Deleting the construction history is usually done only when a model iscompleted to a particular milestone stage and the next major phase ofproduction with it needs to occur. For example, skinning, animating, texturing,and so on.

To delete the construction history on the helmet mesh

1 Right-click the mesh and change the selection mode to Object, and selectthe helmet mesh.

2 Display the Channel Box if it isn’t already, and notice the list of historynodes that appear in the Inputs section.

3 Select Edit > Delete by Type > History.

The construction history is deleted on the helmet mesh. Notice the listof items under Inputs has only one item remaining—the polySurfaceShapenode.

4 Save your work before proceeding to the next section.

Deleting construction history | 121

Page 136: Autodesk Maya 2009

Mirror copying a mesh

Once you’ve finalized one half of your polygon model (and deleted itsconstruction history) you’ll want to create the opposite half by copying itacross the axis of symmetry so you have the complete model. You can producea mirrored copy of a polygon mesh using Mirror Geometry (Mesh > MirrorGeometry).

Before copying one half across the axis of symmetry, you should check thatall of the border edges lie along the axis of symmetry. If any edges do not liealong this axis, the original half will be copied based on the vertices that createthe widest point and a gap between the two halves may result.

To ensure that the border vertices lie along the axis of symmetry

1 Enlarge the front view so you can view the vertices that lie along the axisof symmetry.

If any vertices on the mesh protrude across the Y axis, you’ll need to snapthese to the Y axis using the Move Tool in combination with the Snapto grids feature.

NOTE Any vertices that protrude across the Y axis likely occurred as a resultof an earlier extrude operation. Because the extrude feature extrudescomponents based on the face normal, a few vertices may have moved acrossthe axis of symmetry.

2 In the front view, select all of the vertices that should lie along the axisof symmetry (Y axis) using a bounding box selection.

3 On the Status Line, turn on Snap to Grids.

4 In the Toolbox, double-click the Move Tool to display its tool settingsand ensure that the Retain component spacing setting is turned off.

5 In the front view, click-drag the red arrow on the Move Tool manipulatorto the right a small distance.

The vertices immediately snap to the grid line to the right. They initiallywill not be positioned at the location you want, but you’ll notice that allof the vertices you selected are now aligned to each other.

6 Drag the manipulator towards the left until the vertices snap to the Yaxis.

122 | Chapter 3 Polygonal Modeling

Page 137: Autodesk Maya 2009

7 On the Status Line, turn off Snap to Grids.

8 Click off the mesh to unselect the vertices.

To mirror copy the polygon mesh

1 Right-click the mesh, change the selection mode to Object, and thenselect the helmet mesh.

2 Select Mesh > Mirror Geometry > , set the following options, and thenclick the Mirror button.n Mirror Direction: -X

n Merge with original: On

n Merge vertices: On

The mesh is copied along -X to create the opposite half of the model.The two meshes are combined into one and vertices are merged so theybecome shared.

Mirror copying a mesh | 123

Page 138: Autodesk Maya 2009

3 Save your work before proceeding to the next section.

At this point, the low resolution version of the helmet model is complete. Inthe next section you’ll preview how the model appears at a higher resolutionusing the subdiv proxy feature.

Working with a smoothed mesh

Depending on the intended use of your polygonal model, you may want alow resolution version, a high resolution version, or both. In Maya, its easyto increase the resolution of a model using the Smooth feature (Mesh >Smooth).

In addition, you can preview a higher resolution version of the mesh usingeither Smooth Mesh Preview or the Proxy > Subdiv Proxy feature. You canthen view and edit the low resolution and high resolution smoothed versionof the mesh separately or simultaneously.

Smooth Mesh Preview lets you quickly preview how your mesh will appearwhen smoothed.

The Subdiv Proxy feature links the original and the high resolution smoothedversions via construction history, you can make changes to the low resolutionversion and immediately see the effect on the high resolution smoothedversion.

In this lesson, you’ll use Subdiv Proxy to work with your smoothed mesh.

124 | Chapter 3 Polygonal Modeling

Page 139: Autodesk Maya 2009

To create a high resolution smoothed model using Subdiv Proxy

1 Right-click the mesh, change the selection mode to Object, and thenselect the helmet mesh.

2 Select Proxy > Subdiv Proxy > , and set the following:n Division Levels: 2

n Mirror Behavior: None

n Subdiv Proxy Shader: Keep

3 Click the Smooth button.

A higher resolution, smoothed copy of the helmet mesh is created in thesame position as the original mesh. It is possible to see the two versionsin this position (and you can toggle the display to show either or both)but in this lesson you’ll select the high resolution version and move itslightly to the left.

NOTE The two versions of the model are also grouped into the same nodehierarchy when the Subdiv Proxy operation is performed.

4 Select both the low and high resolution versions of the mesh in ObjectMode.

Working with a smoothed mesh | 125

Page 140: Autodesk Maya 2009

5 Press the ‘ key (located to the left of the 1 key) to toggle the displaybetween the low and high resolution versions.

Toggling the display between the two versions is useful when you wantto view one or the other.

6 Press the ~ key to toggle the display so that both are visible again.

NOTE The Toggle Proxy Display (‘) and the Both Proxy and Subdiv Display(~) display items are also available from within the Proxy menu.

7 Select only the smoothed version of the mesh in Object Mode and moveit to the left about 25 units (X = -25).

As you edit the low resolution version of the helmet mesh you’ll see theresulting updates on the smoothed version beside it.

Creasing and hardening edges on a mesh

You can crease or harden the edges on your polygon meshes. Hardening orcreasing the edges sets how the mesh transitions between faces enhancingthe realism of your model.

When you harden an edge on a polygon mesh, you change the direction ofthe normals associated with the shared edge, which in turn affects the shadingalong those edges. When you crease an edge of a mesh that has an associatedsubdiv proxy, the edges on the smoothed high resolution version are creasedby physically modifying the polygon smoothing surrounding those edges.

126 | Chapter 3 Polygonal Modeling

Page 141: Autodesk Maya 2009

In this lesson, you’ll try both methods on your helmet mesh.

To display hard and soft edges on a mesh

1 Right-click the low resolution mesh, set the selection type to Object Mode,and then select the helmet mesh.

2 Select Soft/Hard Edges.

The wireframe mesh on the helmet updates to display both dashed andsolid lines. The dashed lines indicate edges that are set to display as softshaded. The solid lines indicate edges that are set to display as hardshaded. The reason some of the edges are hard and some are soft relatesto the particular settings for some polygon tools.

To soften the edges on the mesh

1 With the low resolution version of the helmet still selected, select Normals> Soften Edge.

All of the edges on the helmet mesh are set to be shaded in a softened fashion.The wireframe mesh updates to display as dashed lines indicating that all ofthe edges are set to be soft shaded. You may not notice any immediate effecton the smoothed high resolution version, but its important that you performthis step before you proceed to harden specific edges on this model.

Creasing and hardening edges on a mesh | 127

Page 142: Autodesk Maya 2009

To harden the edges surrounding the face shield

1 Right-click the low resolution mesh and set the selection mode to Edge.

2 Select the inner edges that surround the perimeter of the face shield (seeimage below).

TIP You can quickly select the inner edges surrounding the perimeter of theface shield using the Select Edge Loop Tool. You may need to double-clickin a couple of areas to complete the selection.

3 Select Normals > Harden Edge.

The selected edges are hardened on the low resolution mesh.

128 | Chapter 3 Polygonal Modeling

Page 143: Autodesk Maya 2009

Notice that the same edges on the smoothed high resolution version ofthe helmet are unchanged. For edges to display sharp on the smoothedversion, you must turn on the Keep Hard Edge attribute.

To turn on the Keep Hard Edge attribute

1 In the perspective view, select only the smoothed high resolution versionof the helmet mesh.

2 In the Channel Box, in the Inputs section, click the listed proxy to displayits attributes.

3 Set the Keep Hard Edge attribute to On.

The sharper transition between the face shield and the rest of the helmetnow appears on the smoothed high resolution version.

4 Select all of the edges for the grill vents and harden them as well.

Creasing and hardening edges on a mesh | 129

Page 144: Autodesk Maya 2009

To crease edges on the mesh

1 Select the lower outer edges on the face shield (see image).

2 Select Edit Mesh > Crease Tool.

3 In the scene view, press the middle mouse button then drag the mouseto the right to add a crease to the selected edges.

A thick line appears on both the low resolution model and the highresolution version to indicate that a crease has been applied. Notice onthe high resolution version that the related edges have become sharperin appearance, but not as sharp as if they were hardened using the HardenEdge feature.

130 | Chapter 3 Polygonal Modeling

Page 145: Autodesk Maya 2009

4 Save your work.

NOTE You can toggle the creased edge display (thick lines) by selectingCrease Edges.

Your model is now complete. Depending on your requirements you can deletethe construction history on both the low resolution and high resolutionversions.

Refine any regions on the helmet as required to gain more experience withthe tools presented in this lesson.

If you need to work with either version of the model separately you canungroup the two meshes by selecting the top node of their hierarchy in the

Creasing and hardening edges on a mesh | 131

Page 146: Autodesk Maya 2009

Hypergraph window (Window > Hypergraph: Hierarchy) and selecting Edit >Ungroup.

Beyond the lesson

In this lesson you learned some basic techniques of polygonal modeling:

n You can create complex polygonal models with surprisingly few techniques.

n Starting from a primitive surface such as a cube, you can smooth, scale,move, extrude, split, and rotate components of the primitive to create alow resolution version of the model you want to create.

n You must frequently adjust vertices to fine-tune the shape, and finallysmooth the edges between faces where desired in order to produce thefinal version of your model.

n Another method for previewing a smoothed version of the mesh before itis smoothed is via Smooth Mesh Preview. Press the 2 or 3 key while themesh is selected to preview it in a smoothed state. Press the 1 key to returnit to the unsmoothed state.

Polygonal modeling has many timesaving features not covered in this lesson:

n For example, Boolean operations (union, difference, and intersection) area common way to create a new object from the interaction of two existingobjects.

n If you’re planning to use your polygonal surfaces where the poly count isconstrained, such as with interactive games, Maya has a number of toolsfor minimizing the number of polygonal faces of an object such as theReduce Tool. Fewer faces means simpler geometry. This is critical whenfewer polygons means increased interactive performance with gamesapplications. You can view the polygon count on your mesh by selectingthe mesh and then choosing Poly Count.

n Maya also has a category of tools called Deformers. Deformers let you bend,twist, and scale your objects by enveloping the object in a cage-likemanipulator called a lattice deformer that you can manipulate.

n The NURBS chapter in this guide describes how to use the Sculpt GeometryTool to modify a surface by pushing, pulling, and smoothing a surfacewithout first selecting vertices. Though the lesson shows how to shape a

132 | Chapter 3 Polygonal Modeling

Page 147: Autodesk Maya 2009

NURBS surface, you can apply many of the same techniques when sculptingpolygonal surfaces.

n You can also modify a polygon mesh using the Soft Modification Toolwhich lets you smoothly modify a group of vertices on a mesh.

If you want to learn more about a particular tool or feature that has beenpresented in this lesson, refer to the Maya Help.

Beyond the lesson | 133

Page 148: Autodesk Maya 2009

134

Page 149: Autodesk Maya 2009

NURBS Modeling

IntroductionNURBS (Non-Uniform Rational B-splines) use a method of mathematicallydescribing curves and surfaces that are well suited to 3D applications. NURBSare characterized by the smooth organic forms they produce.

NURBS surfaces can be quickly modeled and edited using a variety of techniques.NURBS surfaces are created using one or more NURBS curves that define theprofile of the shape that you want for a surface, and then using a specificconstruction method to create the finished surface.

NURBS curves and surfaces have many applications and are the preferred surfacetype for industrial and automotive designers where smooth forms with minimaldata are required to define a particular form. NURBS curves are ideal for defininga smooth motion path for an animated object. With NURBS, a surface can bemodeled and then converted to a poly mesh.

In this chapter, you will learn some basic techniques for working with NURBScurves and surfaces in Maya. This chapter includes these lessons:

n Lesson 1 Revolving a curve to create a surface: Introduction on page 137

n Lesson 2 Sculpting a NURBS surface: Introduction on page 142

n Lesson 3 Lofting curves to create a surface: Introduction on page 157

4

135

Page 150: Autodesk Maya 2009

Preparing for the lessonsTo ensure the lessons work as described, do these steps before beginning:

1 Select File > New Scene to create a new scene before starting each lesson.

2 Make sure the Construction History icon (below the menu bar) is on:

. (If it is turned off, it has a large X across it.)

3 If you have not already done so, copy the GettingStarted folder fromits installation location to your projects directory. Then, set theGettingStarted directory as your Maya project. For more information,see Copying and setting the Maya project on page 25.

4 Select the Surfaces menu set. Unless otherwise noted, the directions inthis chapter for making menu selections assume you’ve already selectedthe Surfaces menu set.

NOTE Before you perform the lessons in this book, ensure that the InteractiveCreation option for primitives is turned off by selecting Create > NURBSPrimitives > Interactive Creation. That is, ensure a check mark does not appearbeside the menu item.

5 Make sure that Soft Selection is turned off by opening the Attribute Editorwith the Select Tool active and unchecking the box marked Soft Select.

136 | Chapter 4 NURBS Modeling

Page 151: Autodesk Maya 2009

Lesson 1: Revolving a curve to create a surface

Introduction

A simple technique for creating NURBS surfaces is to create a curve for theprofile of your desired form and then create a surface using one of the variousNURBS surfacing tools available in Maya. In this lesson, you create an eggholder using NURBS curves and the Revolve Tool.

In this lesson you learn how to:

n Create a NURBS curve using the control vertices (CV) creation technique.

n Use the grid for visual reference when modeling.

n Determine the start and end points for a NURBS curve and its direction.

n Create a revolved NURBS surface using the Revolve tool.

n Change the display shading smoothness for a NURBS surface.

n Edit a NURBS surface by editing its initial profile curve when it is linkedto the surface by construction history.

Creating a profile curve

Revolve is a common modeling technique similar to shaping a vase on aspinning potter’s wheel. You must first create a profile curve in an orthographicview and use the Revolve Tool to create a surface.

Lesson 1: Revolving a curve to create a surface | 137

Page 152: Autodesk Maya 2009

To create a profile curve

1 Make sure you’ve done the steps in Preparing for the lessons on page 136.

2 Select Panels > Layouts > Four Panes so you can see multiple views of thescene.

3 Select Create > CV Curve Tool.

This is the most commonly used tool for drawing curves.

4 In the front view, click the numbered positions as shown in the figure.Make sure the first and last positions are on the grid’s Y-axis (the thickestvertical line of the front view’s grid).

Also, click three times in the same spot for positions 9, 10, and 11. Thisis necessary to create a sharp point or corner in the curve.

To change the position of the most recent point clicked, you canmiddle-mouse drag it.

5 (Windows and Linux) After you click position 13, press Enter to completethe curve’s creation.

(Mac OS X) Press Return to complete the curve’s creation.

The points you clicked in the scene view become the control vertices(CVs) of the completed curve. CVs are points you manipulate to alter theshape of a curve (or surface). These points often lie away from the curve.

138 | Chapter 4 NURBS Modeling

Page 153: Autodesk Maya 2009

It takes a little practice to be able to predict exactly where a curve will bepositioned when you click CV positions with the CV Curve Tool. Onceyou’ve learned the technique, you’ll be able to create and edit curves withgraceful symmetry. By default, you must click at least four points to createa curve with the CV Curve Tool.

For some advanced operations in Maya, you need to know the meaningof the start of a curve and the curve direction. The start of a curve is the firstCV you create when you draw the curve. It is indicated by a small hollowbox at the first CV, visible as you create the curve. Curve direction isshown on the second CV after the start of the curve, indicated by a smallu icon as you create the curve.

Creating a revolve surface

With the Revolve surface tool, a curve is rotated about an axis to create asurface. The user can define the axis of revolution.

To create a revolve surface

1 With the curve selected, select Surfaces > Revolve. This creates the eggholder surface from the revolved profile curve. Examine the results inthe perspective view.

Maya does not delete the profile curve. In a subsequent step, you’ll editthe profile curve to alter the shape of the surface.

2 Select the surface and rename it Eggholder in the Channel Box.

3 With the pointer in the perspective view, press 5 (for Shading > SmoothShade All).

This displays the egg holder as a shaded surface rather than a wireframein the perspective view.

Press 1, 2, and 3 to switch between the different degrees of displaysmoothness. (These hotkeys correspond to the menu items under Display> NURBS menu item (Rough/Medium/Fine).

The finer the smoothness, the greater the impact is on interactiveperformance when you work with complex models.

The smoothness display only affects the scene view. Rendered imagesdisplay with high quality smoothness regardless of this setting.

Creating a revolve surface | 139

Page 154: Autodesk Maya 2009

Editing a revolve surface

After you create a surface from a revolved curve, you can reshape the originalcreation curve to reshape the surface. This is possible because Maya’sConstruction History feature was turned on before you did the revolveoperation.

Selecting the original creation curve can be challenging when it is situatedamongst other existing curves and surfaces. The Outliner is an editor that isuseful for quickly examining the structure and components of a scene. TheOutliner is also useful for selecting objects in situations like this.

To edit a surface with construction history

1 Select In the main menu bar:.

The Outliner appears and displays a list of the items in the scene.

2 In the Outliner, select the curve you revolved (curve1) by clicking on itsname in the list.

The curve becomes highlighted in the scene views.

3 In the front view, right-click and select Control Vertex from the markingmenu.

The CVs for the curve appear.

4 Select and move one or more CVs to adjust the curve shape as desired.

If you have trouble selecting one of the CVs in the front view, select itin the perspective view after dollying and tumbling the camera asnecessary.

140 | Chapter 4 NURBS Modeling

Page 155: Autodesk Maya 2009

This modifies the shape of the egg holder because it is linked to the shapeof the curve by its construction history.

5 If desired, save the scene for future review.

6 Close the Outliner window.

Beyond the lesson

In this lesson you were introduced to a few basic techniques related to NURBSmodeling:

n Revolving a curve is the easiest way to create surfaces with radiallysymmetrical forms— wheels, vases, glasses, pillars, and so on.

n NURBS surfaces are webs of interconnected curves. The creation curves areused to create and subsequently modify the surfaces if required.

n Proficiency at drawing and editing curves is an important part of NURBSmodeling.

n The grid is a useful aid for constructing and modifying curves.

Some additional points you should know are:

n You cannot render curves, so your work with them is always an adjunctto creating and editing surfaces.

n Besides moving a curve’s CVs to alter its shape, you can cut, attach, extend,close, and smooth curves.

n After you create a surface from a revolved curve, you can edit the surfaceat a component level by moving CVs or scaling groups of CVs on thatsurface to customize the shape of the surface. (You will need to turn offconstruction history in order to do this.)

Beyond the lesson | 141

Page 156: Autodesk Maya 2009

Lesson 2: Sculpting a NURBS surface

Introduction

In addition to creating NURBS surfaces using curves, you can edit and sculptsurfaces and primitive objects in Maya using the Sculpt Geometry Tool.

The Sculpt Geometry Tool allows you to interactively push or pull on thesurface regions to create areas that are embossed or in relief in relation to thesurface.

In this lesson, you learn some of the basic concepts of these tools by sculptinga cartoon face and head from a NURBS primitive sphere using the SculptGeometry Tool.

In this lesson you learn:

n Basic sculpting operations (push, pull, smooth, relax and erase) with theSculpt Geometry Tool.

n How the density of isoparametric lines affects the surface detail possiblewhen sculpting.

n How to increase the surface subdivisions on a NURBS surface to aid withsurface sculpting.

n How to change the brush radius for the Sculpt Geometry Tool.

n How Opacity and Max Displacement affect the sculpting operations.

n How to import geometry from a pre-existing file into your current scene.

142 | Chapter 4 NURBS Modeling

Page 157: Autodesk Maya 2009

Preparing a surface for sculpting

Because a head is roughly spherical, you can create a primitive sphere as aquick starting point for creating a head and face.

To prepare a sphere for sculpting

1 Make sure you’ve done the steps in Preparing for the lessons on page 136.

2 Select Create > NURBS Primitives > Sphere > . In the options window,select Edit > Reset Settings, enter the following values, then click theCreate button:n Radius: 6

n Number of Sections: 30

n Number of Spans: 30

The Radius sets the sphere’s size in grid units. A value of 6 creates a spherebig enough to use the grid for size comparison.

The Number of Sections sets the number of vertical curves, called isoparms,for the sphere. Isoparms show the outline of the surface shape. The moreisoparms a surface has, the more CVs it has. (By default, CVs are notdisplayed.) More CVs means better precision as you edit a surface. TheNumber of Spans sets the number of horizontal isoparms.

The drawback to having too many CVs is that you’ll have a harder timemaking smooth shape changes to broad regions. Lots of CVs also meansslower processing time as you work with the surface. It’s best to makesurfaces with as few CVs as necessary.

We chose 30 Sections and Spans for this lesson because experience hasshown that this allows adequate facial subtlety without slowing Mayaoperation on a workstation of modest processing power.

Preparing a surface for sculpting | 143

Page 158: Autodesk Maya 2009

NOTE In wireframe display mode, if you select Display > NURBS > Fine orMedium, more isoparms appear than there are actual spans and sections.The surface is visually displayed with extra precision, but the extra isoparmshave no CVs and cannot be edited.

3 Name the sphere Egghead.

4 Rotate the sphere 90 degrees on its side (Rotate Z: 90). This positions thesphere’s CVs well for modeling a simple head and face. You’ll learn whylater in this lesson.

5 To give Egghead an oval shape, set the ScaleX for the sphere to 1.3 or so.Optionally, you can move Egghead above the grid so the grid doesn’tinterfere with your view of Egghead. Also, position the perspective viewso the Z-axis of the View Axis points toward you.

Modifying the surface material for easier viewing

Because you will do subtle surface modeling in this lesson, it’s helpful todisplay Egghead with bright highlights so you can clearly see the effects ofthe changes you make. In the next steps, you’ll assign a Blinn material toEgghead to give its surface bright highlights. The steps have no explanations,as the shading subject matter is the focus of a later lesson.

To assign a Blinn surface material

1 With Egghead selected, press 5 to display the surface with smooth shading.

2 Right-click Egghead and select Assign New Material > Blinn.

The Attribute Editor will immediately be displayed for the Blinn material.

3 Drag the Color attribute slider roughly 3/4 of the way to the right, setEccentricity to 0, and close the window.

144 | Chapter 4 NURBS Modeling

Page 159: Autodesk Maya 2009

Basic sculpting techniques

In the next steps, you’ll become familiar with features of the Sculpt GeometryTool. With this tool, you use your mouse or stylus to push, pull, or smooth asurface’s shape without selecting or displaying CVs. After you practice sculptingthe surface, you’ll erase your practice strokes then begin sculpting Egghead’sfeatures.

To practice sculpting using basic sculpting operations

1 With Egghead selected, select Edit NURBS > Sculpt Geometry Tool > . In the Tool Settings window, click Reset Tool, and make sure the Sculptparameters are displayed.

In the Sculpt Parameters section, there are four operations for sculptinga surface. Each affects the region of the surface where you drag (stroke)your mouse or stylus relative to the surface normals:

n The Push operation depresses the surface in the region of the stroke.

n The Pull operation raises the surface in the region of the stroke.

n The Smooth operation diminishes bumps or ridges where you drag.

Smoothing works by averaging the position of all features within thebrush radius with all other nearby features.

n The Relax operation paints over bumps to relax most of the out ofplace surface features.

Basic sculpting techniques | 145

Page 160: Autodesk Maya 2009

Unlike smoothing, Relax works by only averaging the largest surfaceanomalies so that the overall shape is maintained.

n The Erase operation eliminates the effects of the other four operations.

The Erase operation works up to the last time you saved the scene orclicked the Update button to the right of Erase Surface.

2 Experiment with each of the five operations on the surface. Don’t beconcerned with the results. Just become familiar with the response toyour mouse strokes.

By default, Push and Pull strokes deform the surface in a direction normal(perpendicular) to the surface. To create the resulting deformation moreaccurately, use Push and Pull strokes in a front, side, or top view whileexamining the results in a separate perspective view. Tumble theperspective view regularly for the best visual feedback.

When you position the mouse pointer on the surface, it changes to a redsculpt icon that shows an abbreviation for the name of the operationyou are performing. For instance, Ps stands for Push.

The red icon also displays the radius of the region affected by the stroke.The Radius(U) value changes the radius.

3 Select the Erase operation and click the Flood button. This erases all yourchanges.

4 Select the Pull operation and enter a Radius(U) of 0.25, then drag betweena pair of horizontal isoparms without crossing either.

This has no effect because the stroke radius didn’t make contact with theCVs of either isoparm. Regardless of which operation you use, only CVsare affected by the strokes.

5 Change the Radius(U) to 2 and repeat the prior strokes.

146 | Chapter 4 NURBS Modeling

Page 161: Autodesk Maya 2009

The strokes alter the surface because the radius overlaps the CVs. As thisexample shows, you need to make sure the radius is big enough toinfluence the desired CVs. It’s common to change the radius many timesduring a sculpting session.

If you prefer to affect a small region without increasing the radius, youcan add CVs to the region by inserting more isoparms. You’ll do this laterin the lesson.

6 Flood-erase the changes to the surface as you did previously.

7 Select the Pull operation with a Radius(U) of 0.5. Drag along a verticalisoparm. For comparison, drag along a horizontal isoparm.

The vertical stroke creates a thinner ridge than the horizontal strokebecause the density of vertical isoparms is greater. The number ofunderlying CVs and their positioning affects the outcome of your strokes.

TIP You can alternatively adjust the radius of the Sculpt Geometry Tool usinga Hotkey. Move the tool over the object, press and hold the b Hotkey anddrag left or right. The circle on the object with numerical radius valuerepresents the size of your tool. Stroke on the object to try out a new size.

Basic sculpting techniques | 147

Page 162: Autodesk Maya 2009

8 Flood-erase the changes to the surface as you did previously.

9 Rotate the camera view so the X axis of the View Axis points toward you.Draw a vertical Pull stroke again.

As your stroke nears the center of Egghead, a kink occurs. It’s challengingto alter a surface symmetrically in a region where many isoparms convergeat a single point, called a pole. Always consider the position of isoparmsas you sculpt a surface. In general, sculpt where isoparms are evenly,regularly distributed.

10 Erase all changes again, then reposition the camera view so the Z-axis ofthe View Axis points toward you.

TIP If the Sculpt Geometry Tool is selected but not the surface you want towork on, right-click the surface and select Select from the marking menu.

Additional sculpting techniques

Now that you’ve learned the basic features, you’ll learn other useful techniquesbefore starting to model the facial features.

To practice additional sculpting techniques

1 In the Sculpt Parameter section of the Sculpt Geometry Tool, set MaxsDisplacement to 2.

148 | Chapter 4 NURBS Modeling

Page 163: Autodesk Maya 2009

2 Draw a vertical Pull stroke.

3 Change the Max Displacement to 1.

4 Draw another vertical stroke nearby.

The Max Displacement sets the maximum distance the surface’s CVs arepushed (or pulled) with a single stroke.

5 Erase the changes to the surface.

6 Set Max Displacement to 2.

7 Draw a vertical Pull stroke.

8 Set the Opacity from the default value of 1 to a value of 0.2.

9 Draw another vertical stroke nearby.

One ridge is higher than the other. The Opacity value scales the influenceof Max Displacement. For example, with an Opacity of 0.2, each strokehas only roughly 0.2 times the effect of the Max Displacement setting.

It’s generally best to use a low Opacity value as you Push or Pull. You canincrease the deformation gradually with multiple strokes.

If you want to affect only a small region of a surface, use your mouse toclick rather than stroke the region. If the Radius(U) and Opacity of thebrush is small, you might need to click the nearest intersection point oftwo isoparms.

10 With Opacity set to 1, erase all changes to the surface again.

Additional sculpting techniques | 149

Page 164: Autodesk Maya 2009

TIP Consider using an electronic tablet with pen stylus. A pen stylus is morenatural for stroking surface changes as it feels like a pen. With a stylus, youcan set an option that causes the Radius or Opacity to vary with styluspressure. For example, you can have heavy strokes create a bigger Radiusthan light strokes.

To do this, display the Stroke tab of the Sculpt Geometry Tool. For StylusPressure, select Opacity, Radius, or Both. Radius is a common choice. Ifyou select Radius, the Radius(U) value on the Sculpt tab sets the maximumradius, while Radius(L) is the minimum. Explore various settings.

If you use a mouse, set the Stylus Pressure to None. The Radius(U) sets afixed radius. Radius(L) is ignored.

Sculpting a nose

Now you’ll begin sculpting Egghead’s face, starting with a simple nose.

To sculpt a nose for the character

1 Position the perspective view so the Z-axis of the View Axis points towardyou.

2 Reset the Sculpt Geometry tool.

3 Select the Pull operation and set the following options:

Radius(U): 1Opacity: 0.2

4 Select the Gaussian brush profile setting so your strokes have a soft, fadededge:

5 Above the midpoint of Egghead, stroke vertically downward from thetop of the nose to the tip—about the distance between two horizontalisoparms (see the following illustration). Use several strokes to build upthe bridge of the nose. Create nostrils by stroking horizontally to theright of the tip of the nose a few times, then to the left of the tip a fewtimes.

150 | Chapter 4 NURBS Modeling

Page 165: Autodesk Maya 2009

To build up a small area, position the stroke icon there and click themouse rather than drag. Tumble the view to examine your results aftereach stroke or click.

If the strokes create a bumpy surface, turn on the Smooth operation andclick Flood once or twice to smooth all strokes on the surface. BecauseOpacity is 0.2, the Smooth operation is subtle. Alternatively, you cansmooth a selected region by stroking just that area. It’s common to smootha surface regularly while using pull and push strokes.

Because there are relatively few isoparms in the nose area, you can onlycreate a simple nose that’s broad and rounded. If you want to createsharper features, for instance, depressed nostrils or sharp ridges, you’llneed to insert isoparms in the nose region. Sculpting a mouth on page153 describes how to insert isoparms.

Sculpting eye sockets

Eye sockets provide an inset and backdrop for eyes.

To sculpt eye sockets for the character

1 Select the Push operation.

2 Leave other settings the same as for the nose.

3 To make a pair of identical eye sockets, display the Stroke settings in theTool Settings window and turn on Reflection.

4 Set the Reflection Axis to X and then position the sculpt icon on Egghead.

A pair of identical Push icons appears on Egghead.

5 Adjust the positioning as desired for the eye sockets. Click the mousemany times in the desired location.

Sculpting eye sockets | 151

Page 166: Autodesk Maya 2009

NOTE If the Reflection setting does not push or pull in the same directionon either side of a NURBS surface you can adjust the Reference Vector to alterthe direction of these operations. In the Sculpt Parameters section select UVVector and turn on Enable UV Vector Adjustment. Click and drag the mouseleft or right to adjust the direction of the U and V reference vectors.

Sculpting eyebrows

Eyebrows help define how stern or pleasant a face appears.

To sculpt eyebrows for the character

1 Select the Pull operation. Use the same option settings as for the eyesockets, including Reflection.

2 Position the sculpt icons above the eyes and draw horizontal strokes. Ifnecessary, click positions where you need to build up the eyebrows.Smooth the eyebrows as necessary.

152 | Chapter 4 NURBS Modeling

Page 167: Autodesk Maya 2009

Sculpting a mouth

With the 30 Sections and 30 Spans specified for the original sphere in thislesson, the large space between isoparms in the mouth region makes itimpossible to create a subtle shape for the lips.

To overcome this problem, you must insert isoparms in the mouth regionbefore sculpting.

To insert additional isoparms

1 Right-click Egghead and select Isoparm from the marking menu.

2 From the Toolbox, choose the Select Tool.

3 Click the horizontal isoparm below the nose and shift-click the next twobelow it so they become yellow.

Sculpting a mouth | 153

Page 168: Autodesk Maya 2009

4 Select Edit NURBS > Insert Isoparms > . In the options window, turnon Between Selections, enter a value of 2 for # Isoparms to Insert, thenclick Insert.

This inserts two extra isoparms between each pair of selected isoparms,for a total of four extra isoparms. This provides enough CVs to createsubtlety in the mouth.

You might want to add vertical isoparms at the lips in a similar way. Theextra isoparms would also be useful if you were to later enhance the shapeof the nose. Insert isoparms only where needed. More isoparms meansslower processing speed.

In any case, do not change the number of isoparms by editing the originalnumber of Sections and Spans in the makeNurbSphere history node. Thiswill reshape your sculpted surface undesirably.

To sculpt a mouth for the character

1 Select the Sculpt Geometry Tool again.

2 Select the Push operation. Enter 0.2 for Radius(U). In the Stroke tab, makesure Reflection is turned on.

3 Starting at the center of the area appropriate for the indentation betweenthe lips, stroke outward from the center. It’s best to start the stroke withthe dual icons on top of one another (in other words, only one icon isdisplayed).

4 Select the Pull operation and set the Radius(U) to 0.3. Using a similartechnique as for the prior step, stroke the upper lip. Repeat for the lowerlip.

154 | Chapter 4 NURBS Modeling

Page 169: Autodesk Maya 2009

NOTE It might be easier to push or pull the lips with the Ref. Vector set toZ Axis. This moves the region you stroke in the world Z-Axis direction. Thedefault Normal setting moves the region in a direction normal (perpendicular)to the surface. Because the normal direction on a lip might be up, down, orstraight out, depending on the part of the lip you stroke, there’s morepossibility of undesired results when you use the Normal setting.

Sculpting other facial features

You can now optionally add other facial features. Consider these tips:

n For facial features such as the chin, cheeks, and forehead, use a Radius(U)larger than 1 and start with a Maximum Displacement between 0.5 and1.

n Insert isoparms wherever you want to add extra detail with the SculptGeometry Tool.

n To create eyeballs for the sockets, create a sphere and scale it as necessaryto fit the socket. You might want to increase the eyeball’s Scale X value tomake it oblong. To duplicate the eyeball, and make a mirrored copy of theoriginal you’ll first need to set the pivot point for the eyeball to be at theorigin 0, 0, 0 using the following steps. With the sphere selected, press theInsert (Windows and Linux) or Home (Mac OS X) key so that the sphere’spivot point is displayed. Next move the pivot point to the origin using theX hotkey so that the pivot snaps to the grid at 0, 0, 0. Select Insert (Home)to turn off the pivot point display. Finally, use Edit > Duplicate Special >

and set the Scale setting to -1, 1, 1. This makes the new eyeball amirrored duplicate of the original on the opposite side of Egghead’s face.Position the eyeballs in the sockets. Parent the eyeballs to Egghead.

Sculpting other facial features | 155

Page 170: Autodesk Maya 2009

n To create simple, unadorned ears, you can create, scale, and squash asphere. Create ridges and valleys by pulling CVs or by using the SculptGeometry Tool. Duplicate the ear by first setting its pivot point to theorigin and with the Scale option set to -1, 1, 1. Parent the ears to Egghead.

To import existing models into your scene:

1 If you saved the Eggholder scene in the prior lesson, you can import theegg holder into this Egghead scene, then position Egghead into the eggholder.

To import the egg holder into the Egghead scene, use File > Import andselect the name of the scene that contains Eggholder.

Importing a scene imports all objects from that scene.

2 Increase (or decrease) the scale of the egg holder (or Egghead) as necessaryfor a snug fit.

Beyond the lesson

In this lesson you were introduced to a few basic techniques related to sculptingsurfaces:

n The Sculpt Geometry Tool is indispensable for quickly shaping a varietyof surfaces. As you do your own projects, pay special attention to theposition and density of isoparms before you begin sculpting.

n Isoparms converge at a single point (the pole). Pole regions of a primitiveor surface are hard to sculpt so it’s best to avoid using the Sculpt GeometryTool there. For example, when you created the original sphere in thislesson, you rotated it 90 degrees around its Z-axis. Because of the rotation,ears for the head would need to be modeled via a different technique (forexample, you could model a pair of ears and parent them to the head).

156 | Chapter 4 NURBS Modeling

Page 171: Autodesk Maya 2009

n The density and orientation of isoparms on a surface affects the resultswith the Sculpt Geometry Tool. As you gain NURBS modeling experience,you’ll learn how to use the density and orientation of isoparms to youradvantage.

n Primitive objects are useful objects for sculpting in many cases. After youcreate a primitive, you typically sculpt, scale, trim, or otherwise alter theobject into a more complex shape. Though most primitives are surfacesrather than curves, they still derive their shape from curves.

In general, a sphere makes a convenient foundation for creating a simplehead, but it’s not ideal if you plan to animate an expressive, talking head.Many 3D artists start with a cylinder or a lofted surface. The proceduresfor doing this are more complex than starting with a sphere and are beyondthe scope of this lesson.

Lesson 3: Lofting curves to create a surface

Introduction

Lesson 3: Lofting curves to create a surface | 157

Page 172: Autodesk Maya 2009

Another method for creating NURBS surfaces is to loft a series of curves thatdefine the cross section of your desired surface form. Lofting a surface workslike stretching a skin over each of the cross sections to create the final surface.

In this lesson, you learn additional NURBS surfacing techniques by using theLoft tool to create the body of a salt shaker. You will also create the cap forthe salt shaker by modifying the shape of a primitive sphere.

In this lesson you learn how to:

n Modify the outline of a circle primitive by editing the position of its CVs.

n Use the magnet snap feature.

n Loft cross section curves to create a NURBS surface using the Loft tool.

n Edit the form of an existing primitive object by moving its CVs.

n Parent one object to another using the Outliner.

Creating profile curves for a surface

You begin the lesson by creating a pair of profile curves. You then createseveral copies of these curves to form the skeletal contours of the salt shaker’ssurface.

To create profile curves for the salt shaker’s body

1 Make sure you’ve done the steps in Preparing for the lessons on page 136.

2 Select Create > NURBS Primitives > Circle > . In the options window,select Edit > Reset Settings, enter the following values, then click theApply button:n Radius: 4

n Number of Sections: 24

The Radius sets the size of the circle in grid units. A value of 4 creates acircle with enough size so that you can use the grid for convenient sizecomparison.

The Number of Sections sets the number of CVs in the circle. By using24 CVs, you can create a circle with the subtle contours required in thislesson. Display the CVs of the circle to see the 24 CVs.

158 | Chapter 4 NURBS Modeling

Page 173: Autodesk Maya 2009

A circle is a curve that loops back on itself. The CVs work the same wayas for any other curve. The more CVs you create for a curve or surface,the more detail you can give its shape.

The drawback to using many CVs is that you’ll have a harder time makingsmooth shape changes to broad regions. Also, more CVs means slowerprocessing time as you work with the curve. It’s best to make curves withas few CVs as necessary. With experience, you’ll learn how many CVs touse in a situation.

3 Create another circle, this time with these options:n Radius: 2

n Number of Sections: 24

This creates a smaller circle inside the first circle as shown below.

4 Change the scene view so you can see the circles from the top view.

5 Right-click the inner circle and select Control Vertex from the markingmenu. Repeat for the outer circle.

6 Turn on Snap to Points (below the menu bar).

7 As shown in the following figure, move CVs from the outer circle to thecorresponding inner circle positions. As you drag a CV near its destination,the Snap to Points mode causes the CV to jump to the exact CV position.

Creating profile curves for a surface | 159

Page 174: Autodesk Maya 2009

8 Turn off Snap to Points. Turn off the display of CVs for both circles byright-clicking on the circles and selecting Object Mode from the markingmenu.

Duplicating curves

In the next steps, you’ll create several copies of the previously created circles(also called curves) to form the skeletal contours of the salt shaker’s surface.

To duplicate curves for the lofted surface

1 Right-click the outer curve and choose Select from the marking menu.

2 Select Edit > Duplicate Special > . In the options window, select Edit> Reset Settings, enter the following values, then click Duplicate Special:

n Translate: 0 3 0

n Scale: 0.93 1 0.93

n Number of Copies: 4

160 | Chapter 4 NURBS Modeling

Page 175: Autodesk Maya 2009

This creates four copies of the original curve, each translated three unitsabove the last, and each scaled smaller than the last.

3 Select the inner circle and then move it to 0, 13, 0 by entering thesetranslate values in the Channel Box. Increase its Scale attributes to 1.33,1.33, 1.33..

4 Use Edit > Duplicate Special > with the following options:n Translate: 0 2 0

n Scale: 1.05 1 1.05

n Number of Copies: 3

This creates three copies of the circle, each translated two units abovethe last, and each bigger than the last.

Lofting a surface

You’ve created a total of nine curves. In the next steps, you loft these curvesinto a surface that matches the contours of their perimeters. Above themidpoint of the surface, the shape will change from a flower-shaped perimeterto a circular perimeter.

To loft a surface for the salt shaker’s body

1 Starting from the bottom circle, and working towards the top, shift-selectall the circles, one at a time.

The order of selection is important when shift-selecting for a loftoperation. You must start with the bottom flower-shaped circle and endwith the top circular-shaped circle. Alternatively, you can drag a selectionbox around the circles. The surface to be lofted will be based on theselection order of the curves.

Lofting a surface | 161

Page 176: Autodesk Maya 2009

2 Select Surfaces > Loft.

This creates the salt shaker’s body.

3 Name the surface shakerBody.

4 Press 5 to display the view with smooth shading.

NOTE Many of the surface creation tools also have the option of creatingpolygon or subdivision surface versions of a surface with the same inputcurves. You do this by setting the appropriate Output Geometry option forthat particular surface tool.

Modifying a primitive object

To create a simple cap for the salt shaker, you’ll create a sphere, alter its shape,and position it above the body.

To create and modify a sphere for the salt shaker’s cap

1 Select Create > NURBS Primitives > Sphere > . In the options window,select Edit > Reset Settings, and click the Create button. Maya puts thesphere at the origin, its display currently obstructed by the salt shakerbody.

2 Name the sphere Cap.

3 Move the cap to the top of the body.

162 | Chapter 4 NURBS Modeling

Page 177: Autodesk Maya 2009

4 Scale the cap size so that its diameter fits snugly at the top of the body.

5 Adjust the cap’s position as desired.

6 In a side view, make sure that the cap is displayed as a wireframe.

7 Right-click on the Cap and choose Control Vertex from the markingmenu.

8 Select the top row of CVs and drag them down until the top of the capis flattened:

Check that the bottom half of the cap isn’t poking through the visiblesurface of the body. You can scale the bottom CVs inward to avoid thisproblem.

Modifying a primitive object | 163

Page 178: Autodesk Maya 2009

Using the Outliner to parent objects

The Outliner is an editor that is useful for quickly examining the structureand components of a scene. You can use the Outliner to quickly parent objectsto create an object hierarchy.

To parent an object using the Outliner

1 From the main menu, select In the main menu bar:.

The Outliner window is displayed. A list of the scene’s components islisted in the Outliner.

2 In the Outliner, click on the word Cap to select it.

3 Parent the cap to the body by middle-mouse dragging Cap ontoshakerBody1 in the Outliner.

164 | Chapter 4 NURBS Modeling

Page 179: Autodesk Maya 2009

By parenting the objects, you can move, rotate, or scale the cap and thebody as a single entity by selecting only the body.

Notice that the salt shaker displays horizontal curves that wrap aroundthe body. The curves are the original circles you used to loft the surface.Because these curves are part of the surface’s construction history, youcan alter their shape if you decide you want to alter the shape of the bodyand the body will update based on the construction history.

If you prefer not to see the curves in the scene view, select the curves andselect Hide Selection. The curves won’t appear when you render an imageof the scene. Maya displays only surfaces, not curves, in rendered images.

Beyond the lesson

In this lesson you were introduced to the basic techniques related to loftingcurves to create NURBS surfaces:

n You made a salt shaker with two surfaces: a body made from lofted curvesand a cap made from an altered sphere. An advantage of creating a separatesurface for the cap and base is that you can easily give each a differentcolor or texture, for example, one chrome and the other marble. Anotheradvantage of creating a separate cap is that you can animate the objectseparately. For example, you could choose to animate the cap unscrewingfrom the shakerBody.

n You used a Loft operation rather than a Revolve operation to create thebody. The vertical corrugations on the surface would be impossible tocreate by revolving a curve.

n You can alter the position of the profile curves and the shape of the shakerwill update because of the construction history. If you’re certain you won’tchange the body’s shape by editing the shape of the lofted curves, you candelete the body’s construction history to quicken Maya’s processing ofyour interaction with the surface. (For a surface as simple as the salt shaker,deleting the history won’t boost processing much.)

n There are many other useful tools for creating and editing surfaces. For aglimpse of the possibilities, take a look at the Surfaces menu and the EditNURBS menu.

If you want to learn more about a particular tool or feature that has beenpresented in this lesson, please refer to the Maya Help.

Beyond the lesson | 165

Page 180: Autodesk Maya 2009

166

Page 181: Autodesk Maya 2009

Subdivision Surfaces

IntroductionSubdivision surfaces are a hybrid surface type that possess characteristics of bothNURBS and polygonal surfaces as well as other features not offered by the othersurface types. Like NURBS, subdivision surfaces are capable of producing smoothorganic forms and can be shaped using relatively few control vertices. Likepolygonal surfaces, subdivision surfaces let you extrude specific areas and createadditional detail in your surfaces. You do this by working at different levels ofdetail on the subdivision surface and switching between the levels whennecessary. With a subdivision surface you can build a smooth organic objectfrom a single primitive and not be concerned about attaching or stitching thevarious surfaces together as you would for a NURBS surface.

Preparing for the lessonTo ensure the lesson works as described, do these steps before beginning:

1 Review the Polygon Modeling lesson in this guide. Knowledge of polygonalmodeling tools is essential to becoming proficient in subdivision surfacemodeling.

2 If you have not already done so, copy the GettingStarted folder from itsinstallation location to your projects directory. Then, set theGettingStarted directory as your Maya project. For more information, seeCopying and setting the Maya project on page 25.

3 Create a new scene.

4 Select the Surfaces menu set.

5

167

Page 182: Autodesk Maya 2009

5 Select Window > Settings/Preferences > Preferences.

6 In the Preferences window, select Subdivs from the Categories list todisplay the subdivision surface preferences.

7 In the Subdivision Surfaces Component Display settings, set theComponent display to Numbers, then click Save.

Setting the subdivision components to display as numbers allows you tosee the subdivision surface level directly on the surface.

NOTE Before you perform the lessons in this book, ensure that the InteractiveCreation option for primitives is turned off by selecting Create > PolygonPrimitives > Interactive Creation. That is, ensure a check mark does not appearbeside the menu item.

8 Make sure that Soft Selection is turned off by opening the Attribute Editorwith the Select Tool active and unchecking the box marked Soft Select.

Lesson 1: Modeling a subdivision surface

Introduction

In this lesson you learn some of the basic tools for working with subdivisionsurfaces as you model a human character's hand.

In this lesson, you learn how to:

n Convert a polygon surface to a subdivision surface.

n Work with subdivision surfaces in Polygon Proxy Mode.

n Split subdivision faces to create areas for more detail in a model.

n Extrude the split faces to create fingers on the hand.

n Work with subdivision surfaces in Standard Mode.

168 | Chapter 5 Subdivision Surfaces

Page 183: Autodesk Maya 2009

n Change the Display Level when working in Standard Mode.

n Add more detail to subdivision surface models using Refine SelectedComponents.

n Create a crease along a vertex edge.

Creating a subdivision surface

You begin the lesson by creating a polygonal cube. You’ll convert this cubeto a subdivision surface that will be the foundation of the hand. The reasonfor starting with a polygonal surface and converting it to a subdivision surfaceis that you can thereafter edit the object’s shape with more versatility: youcan edit with subdivision surface tools and polygonal tools.

To create a polygon cube

1 Select Create > Polygon Primitives > Cube > . In the options window,select Edit > Reset Settings. Then enter the following values and click theCreate button.n Width: 8

n Height: 2.5

n Depth: 8

The resulting polygonal cube is roughly proportional to the palm of ahand.

To convert a polygonal cube to a subdivision surface

1 To convert the polygonal cube to a subdivision surface, select Modify >Convert > NURBS to Subdiv, Polygons to Subdiv.

Creating a subdivision surface | 169

Page 184: Autodesk Maya 2009

2 Press 3 on your keyboard (to select Display > Subdiv Surfaces > Fine).

3 Press 5 (to select Shading > Smooth Shade All).

With the smoothness set to Fine, you can see that the conversion to asubdivision surface creates a rounded, smooth shape. By pressing 3, thesubdivision surface is displayed more precisely in the scene view. Thisgives a closer approximation of what the surface will look like when youcreate a rendered image of the scene.

As an alternative, you could have chosen a Rough smoothness (press 1)so that Maya processes your editing changes in the scene view morequickly. Regardless of the smoothness in the scene view, surfaces alwaysare displayed precisely in rendered images of the scene.

To display a subdivision surface in polygon proxy mode

1 Select Subdiv Surfaces > Polygon Proxy Mode.

170 | Chapter 5 Subdivision Surfaces

Page 185: Autodesk Maya 2009

The wireframe cube looks the same as the original polygonal cube. Thenew cube is called a polyToSubd1 for the subdivision surface as a result ofthe conversion. Rename it LeftHand. You can use polygonal modelingtools to edit the shape of the polygonal proxy, which indirectly altersthe shape of the subdivision surface. Unlike working with an actualpolygonal object, your modifications result in perfectly smooth surfacechanges rather than faceted changes.

Splitting a surface in polygon proxy mode

Next, you use polygonal modeling techniques to split a face into multiplefaces to be extruded as fingers.

To split the polygon face into multiple faces

1 Select the Polygons menu set.

2 With LeftHand still selected, select Edit Mesh > Split Polygon Tool >. In the tool settings window click the Reset Tool button.

You’ll use this tool to split the front face of the proxy into several facesto be extruded into fingers.

3 In the front view, click the point on the top edge as shown in thefollowing figure, then click the corresponding point directly below it onthe bottom edge. If the line between the points isn’t perfectly straight,use the middle mouse to drag the second point to the correct position.Press Enter (Windows and Linux) or Return (Mac OS X).

Splitting a surface in polygon proxy mode | 171

Page 186: Autodesk Maya 2009

This splits the face into two faces. You’ll extrude the left face into a fingerlater.

4 Repeat the preceding two steps as necessary to split the face as follows:

Notice how splitting the face into multiple faces alters the shape of thesubdivision surface. The front part of the subdivision surface nowresembles the proxy shape more. If you were to split the front face severalmore times, especially near the outer edges, the subdivision surface wouldsharpen and resemble the proxy shape even more. More faces means finercontrol, often at the expense of making the surface harder to work with.

With the added faces, the subdivision surface looks a bit like the palm ofa hand. You’ll build upon this shape to create a left hand with palm facingdownward and fingers extruded outward. You’ll extrude the wide facesinto fingers, and you’ll leave the narrow faces as webbing between thefingers.

172 | Chapter 5 Subdivision Surfaces

Page 187: Autodesk Maya 2009

Extruding polygon faces

Next, you’ll extrude faces to create fingers for the hand.

To extrude the polygon faces to create fingers

1 In a perspective view, right-click LeftHand and select Face from themarking menu.

This lets you select faces.

2 Select the right-most face by dragging a selection box around the tinybox at its center. (The subsequent illustration shows which face to select.)

3 Select Edit Mesh > Extrude.

4 Drag the blue arrow manipulator outward a little to create the firstsegment of the smallest finger.

The blue arrow turns yellow when selected.

5 Repeat the prior two steps to create the middle segment of the smallestfinger.

6 Repeat the prior two steps once again to create the top segment andcomplete the finger.

By creating three segments for a finger, you mimic a real finger’s naturalstructure. The borders between the segments have vertices (not displayedcurrently) that let you reshape those regions, for instance, to createknuckles.

Extruding polygon faces | 173

Page 188: Autodesk Maya 2009

7 Similarly, extrude the ring, middle, and index fingers from the appropriatewide faces. Don’t extrude the three small faces that lie between the widespaces. Leave them in position to allow for webbing between the fingers.

NOTE Do not be concerned if the hand you create does not match thelesson’s illustrations. Your goal in this lesson is to learn the workflow ofsubdivision surfaces, not to perfect your modeling technique.

Next, you extrude a thumb using similar techniques as you used for the fingers.The following steps are abbreviated. See the preceding pages for details on thedescribed tools, if necessary.

To split and extrude a face for the thumb

1 Select LeftHand.

Make sure it is highlighted in green in the scene view. If it is not green,select LeftHand in the Outliner.

2 Use Edit Mesh > Split Polygon Tool to split the side face in the thumbregion into three faces.

While splitting, make sure the middle face is larger than the outer facesas shown below.

174 | Chapter 5 Subdivision Surfaces

Page 189: Autodesk Maya 2009

3 Extrude the middle face and drag it directly outward.

4 Click the surrounding blue circle and use the rotate manipulator to aimit in a direction appropriate for a thumb.

5 Extrude three times more to create each segment of the thumb. Use theextrusion manipulator to rotate, move, and scale each extrusion to createthe desired shape of a thumb. Use the following figure as a guideline.Again, it’s unnecessary to match the illustration or create a realistic thumbfor this lesson.

The extrusion manipulator is easy to figure out by clicking and draggingits various elements. If necessary, you can also use the conventional Move,Scale, and Rotate Tools to reshape the faces that control the thumb’sshape.

6 fIn the scene view, right-click LeftHand and select Vertex from themarking menu. The purple vertices at the corners of the faces control theadjacent region of the hand.

Extruding polygon faces | 175

Page 190: Autodesk Maya 2009

7 Make coarse adjustments to various parts of the hand by repositioningthe vertices with the Move, Scale, and Rotate Tools.

The Move Tool works on individual vertices or groups of vertices. Rotateand Scale works on two or more vertices. Undo any changes you don’tlike using Ctrl-Z (Windows and Linux) or Control-z (Mac OS X).

Try to create the approximate thickness, length, and curvature of a cartooncharacter’s hand and fingers. There’s no need for perfection. You’ll refinethe fingers later.

Deleting polygon faces

In the next steps, you delete a face in order to create a hole in the wrist whereyou might choose to attach an arm. Though you won’t create and attach anarm in this lesson, it’s useful to learn the technique for future use.

To create a hole at the wrist by deleting a face

1 In the scene view, right-click LeftHand and select Face from the markingmenu.

2 Select the face at the wrist and press Delete to create a hole where youcould attach an arm.

176 | Chapter 5 Subdivision Surfaces

Page 191: Autodesk Maya 2009

3 Scale the four vertices that surround the hole and scale them inward tonarrow the wrist region of the hand.

Subdivision surface levels

Next, you refine the shape of the fingers by working in Standard Mode. InStandard Mode, you can make edits to mesh vertices, edges, or faces at differentlevels of refinement, that are not possible in Polygon Proxy mode. The differentlevels of refinement are referred to as subdivision surface levels.

To refine the fingers using subdivision surface levels

1 Select LeftHand.

2 Select the Surfaces menu set.

3 Select Subdiv Surfaces > Standard Mode. This switches to a mode thatlets you modify the surface at various levels of detail to suit your needs.

4 In the scene view, right-click LeftHand and select Vertex from the markingmenu.

Subdivision surface levels | 177

Page 192: Autodesk Maya 2009

This displays 0s on the surface in the same positions as the vertices inPolygon Proxy mode. In fact, the 0s are vertices.

The number 0 refers to the level of detail you are capable of editing. The0 level is identical to the coarse control possible in Polygon Proxy modeby manipulating the vertices. You can move, rotate, and scale the 0s toalter the shape of the surface just as you did for vertices in Polygon Proxymode.

5 Right-click the surface and select Display Level > 1.

Though the 1s are displayed in the same regions as the 0s were previously,there are many more 1s displayed. The 1s are also vertices, and theirincreased presence means you can refine the shape with more subtlety.

6 Refine the shape of the fingers, thumb, and hand as desired by selectingvarious level 1 vertices and moving, scaling, and rotating them with thetransformation tools. (Scaling and rotating has effect only if you selecttwo or more vertices.)

It’s essential to tumble the camera from various perspectives to make sureyou’ve selected only the desired vertices.

To return to level 0 to alter the shape with fewer vertices, right-click thesurface and select Display Level > 0. Each level has advantages. Level 1allows finer control because there are more vertices. Level 0 allows controlof broader regions, and it’s often easier to select the desired vertices since

178 | Chapter 5 Subdivision Surfaces

Page 193: Autodesk Maya 2009

there are fewer of them. It’s common to switch back and forth betweenlevels repeatedly in a work session.

The hand has level 2 vertices at various locations, for instance, at thewebbing between the fingers. You can also work at that level of detail ifdesired (select Display Level > 2).

Refining surface components

By default, a subdivision surface displays up to three levels of detail (0, 1, andpossibly 2). The 0 level is the least refined. You can increase the level of detailfor a selected region to at most 13 levels. Though increasing the number oflevels allows more precision, it also slows Maya processing. You’ll accomplishmost of your modeling needs at levels 0, 1, and 2.

If you display level 2 vertices on the hand, you’ll notice that there are no level2 vertices near the fingertips. To create the indentation of a finger nail, youneed more vertices than levels 0 and 1 provide. In the next steps, you’ll addlevel 2 vertices at a fingertip so you can create a fingernail.

To create more precision in the fingernail region

1 Switch to level 1.

2 Right-click the surface and select Edge from the marking menu.

3 Shift-click to select the edges that surround the region where you’ll shapea nail.

4 To increase the amount of detail at the selected edges, select SubdivSurfaces > Refine Selected Components. Additional surface curves appearin the fingernail area, indicating you can edit with more precision.

Refining surface components | 179

Page 194: Autodesk Maya 2009

5 In the scene view, right-click LeftHand and select Vertex from the markingmenu. This displays additional level 2 vertices in the fingertip region.

6 Select Modify > Transformation Tools > Move Tool, Rotate Tool, Scale

Tool, Show Manipulator Tool > . In the Tool Settings window, turnon Normal, then close the window. You can thereafter use the Move Toolmanipulator to move vertices in a direction normal (perpendicular) tothe surface.

7 Select the vertices in the nail region.

NOTE Be careful to select only those vertices in the nail region. You mayneed to tumble the camera to ensure that all extra vertices are de-selected.

8 Drag the Move Tool’s N manipulator down slightly to form the depressionof a fingernail bed.

180 | Chapter 5 Subdivision Surfaces

Page 195: Autodesk Maya 2009

Creating a crease in a subdivision surface

One of the unique features of subdivision surfaces is that it’s easy to create acrease or ridge on a smooth surface. You’ll do this in the next steps.

To crease the edge of the fingernail

1 Switch to Edge selection mode and shift-click the edges around the nailto select them. (It might be easier to see the desired edges by first selectingShading > Wireframe.)

2 After you select the edges, select Subdiv Surfaces > Full Crease Edge/Vertex.

Once you crease an edge, it displays with a dashed line as a visualreminder that the edge has been creased. If you change your mind, youcan remove the crease using Subdiv Surfaces > Uncrease Edge/Vertex.

3 To create a ridge at the edge of the nail, switch to Vertex selection modeand select the level 2 vertices on the skin at the perimeter of the previouslyselected edges. Move them up so that the skin’s juncture with the nailforms a slight ridge.

Creating a crease in a subdivision surface | 181

Page 196: Autodesk Maya 2009

4 Now experiment on your own by moving individual vertices to shapethe nail and surrounding region as desired. A few suggestions follow:

n In Smooth Shade display mode (Shading > Smooth Shade All), certainvertices might be below the shaded surface and therefore impossible toselect and move. To display and select such vertices, switch to wireframeshading (Shading > Wireframe). After selecting the vertices, return toSmooth Shade display mode so you will be able to more easily see theresults of moving them.

n You might get better results using the Move Tool’s default World settingrather than the Normal setting made in a prior step. To return to the defaultsetting, select Modify > Transformation Tools > Move Tool, Rotate Tool,

Scale Tool, Show Manipulator Tool > . In the Tool Settings window,click Reset Tool, and then close the window.

n To extend the front of the nail past the skin with a sharp edge, add a secondcrease on the edges below the tip of the nail. (With the appropriate edgesselected, select Subdiv Surfaces > Full Crease Edge/Vertex.)You might also want to add an additional level of vertices at the edges.(With the appropriate vertices selected, select Subdiv Surfaces > RefineSelected Components.)

After you crease the edges and add the extra vertices, you can make thenail’s edge overhang the skin below it by dragging the vertices at the nailtip out and away from the finger. Then tuck the row of vertices below theoverhanging vertices in the opposite direction.

An example of a completed nail follows:

1 If you want more practice, repeat the procedure for the rest of the nails.

2 When finished, select Modify > Transformation Tools > Move Tool, Rotate

Tool, Scale Tool, Show Manipulator Tool > . In the Tool Settings

182 | Chapter 5 Subdivision Surfaces

Page 197: Autodesk Maya 2009

window, click Reset Tool, and then close the window. This returns theMove Tool to its default settings. This will avoid confusion in futurelessons.

Beyond the lesson

In this lesson, you were introduced to some basic techniques related tosubdivision surface modeling:

n Modeling with subdivision surfaces is an easy way to create intricate,smooth objects such as human hands and faces. The ability to createextrusions, subtle surface alterations, and sharp edges means there areinnumerable types of objects you can model.

n Many of the techniques used in modeling polygonal surfaces are applicableto subdivision surfaces.

There are many other features related to subdivision surfaces not covered inthis lesson. These include the ability to:

n Convert a NURBS surface to subdivision surface.

n Convert a subdivision surface to a polygonal or NURBS surface.

n Create subdivision surface primitive shapes from the Create > SubdivPrimitives menu: Sphere, Cube, Cylinder, Cone, Plane, and Torus. Withthese shapes, you can quickly start your subdivision surface model withoutconverting from polygons or NURBS surfaces.

n Attach two subdivision surfaces to form a single surface, for instance, tomerge a hand and an arm.

n Create a mirrored copy of a subdivision surface.

n You can sculpt subdivision surfaces using the Sculpt Geometry Tool.If you want to learn more about a particular tool or feature that has beenpresented in this lesson, refer to the Maya Help.

Beyond the lesson | 183

Page 198: Autodesk Maya 2009

184

Page 199: Autodesk Maya 2009

Animation

IntroductionMaya lets you apply action to the objects in your 3D scene. In Maya, when anobject or attribute changes in relation to time, it is referred to as being animated.

Maya provides a large selection of tools to help you animate the objects in yourscene. You may decide to use a combination of several techniques to achieveyour desired results.

In this chapter, you learn some common techniques and features that highlightMaya’s computer animation technology:

n Lesson 1 Keyframes and the Graph Editor: Introduction on page 186

n Lesson 2 Set Driven Key: Introduction on page 201

n Lesson 3 Path animation: Introduction on page 206

n Lesson 4 Nonlinear animation with Trax: Introduction on page 225

n Lesson 5 Inverse kinematics: Introduction on page 262

Preparing for the lessonsTo ensure the lessons work as described, do these steps before beginning:

1 Select Window > Settings/Preferences > Preferences. Click the Settingscategory and set the Time option to Film (24 fps) so your animation playsat the rate of 24 frames per second. Click the Save button.

6

185

Page 200: Autodesk Maya 2009

2 If you have not already done so, copy the GettingStarted folder fromits installation location to your projects directory. Then, set theGettingStarted directory as your Maya project. For more information,see Copying and setting the Maya project on page 25.

3 Select the Animation menu set. Unless otherwise noted, the directionsin this chapter for making menu selections assume you’ve already selectedthe Animation menu set.

Lesson 1: Keyframes and the Graph Editor

Introduction

When you set a keyframe (or key), you assign a value to an object’s attribute(for example, translate, rotate, scale, color, etc.) at a specific time.

Most animation systems use the frame as the basic unit of measurement becauseeach frame is played back in rapid succession to provide the illusion of motion.

The frame rate (frames per second) that is used to play back an animation isbased on the medium that the animation will be played back (for example,film, TV, video game, etc.)

When you set several keys at different times with different values, Mayagenerates the attribute values between those times as the scene plays backeach frame. The result is the movement or change over time of those objectsand attributes.

In this lesson, you will use simple keyframing techniques to make a ball flyover a fence and bounce off the ground.

186 | Chapter 6 Animation

Page 201: Autodesk Maya 2009

In this lesson, you learn how to:

n Set keyframes for animatable objects and their attributes.

n Use the Time and Range slider and Playback Controls to control theplayback.

n Use keyboard shortcuts to set keyframes.

n Use the Graph Editor to view animation curves.

n Modify the animation of objects using the Graph Editor.

n Set preferences to increase the playback quality.

Setting the playback range

In this lesson, you work with a scene we’ve created for your use. In thefollowing steps, you open the scene and set how long the animation will play.

To open the scene

1 Make sure you’ve done the steps in Preparing for the lessons on page 185.

2 Open the scene file named Keyframing.ma.

This file can be found in the GettingStarted directory that you set asyour Maya project.

GettingStarted/Anim/Keyframing.ma

The scene contains a ball object that is currently positioned on the X-axisnear the edge of a ground plane.

To animate the ball, you key its position at different times of the playbackrange.

The playback range is defined by the Time and Range slider. The Timeand Range slider controls allow you to playback or scroll through youranimation or move to a specific point in time of your animation so youcan set keyframes.

To set the playback range for the scene

1 Look over the playback controls, as shown in the figure below:

Setting the playback range | 187

Page 202: Autodesk Maya 2009

The Time Slider displays the playback range and keys you’ve set for aselected object. Keys are displayed as red lines. The box at the right ofthe Time Slider lets you set the current frame (time) of the animation.

The Playback Controls control animation playback. You may recognizethe conventional buttons for play and rewind (return to the start time).The stop button appears only when the animation is playing. To findout which operation a button represents, hold the mouse pointer overit.

The Animation Preferences button displays a window for settinganimation preference settings such as the playback speed.

The Range Slider controls the range of frames that play when you clickthe play button.

The above items will have more relevance as you work through this lesson.After you complete this lesson, experiment with these items to learn morewhat they do.

The playback range is currently set at a range of 1 to 24. At a defaultplayback rate of 24 frames per second, the scene can play for one second.Because you’ll animate the ball for a few more seconds than this, youneed to lengthen the playback range.

2 In the Playback End Time box (see above), enter 72.

A frame rate of 24 frames per second (fps) is the frame rate used for motionpicture film. For video, the frame rate can be 30 fps (NTSC) or 25 fps(PAL) depending on the format being used.

With a playback range of 1 to 72, you’ll be able to create three secondsof animation. (72 frames divided by 24 frames per second = 3 seconds.)This is enough time for the short animation you’ll create in this lesson.

Setting keyframes

In the following steps, you use keyframes to set the starting and endingpositions of the ball’s movement.

188 | Chapter 6 Animation

Page 203: Autodesk Maya 2009

To set beginning and ending keyframes

1 Click the rewind button to go to the start of the playback range. Thischanges the current frame to 1.

2 Select the ball, then select Animate > Set Key. (Keyboard shortcut: s).

This sets a key at frame 1 for all transform attributes of the ball. Transformattributes are the X, Y, Z move attributes. Although you animate onlythe translate X and Y attributes of the ball in this lesson, keying alltransform attributes saves you time having to choose specific attributesto be keyed.

In the Time Slider, notice the red marker at frame 1, known as a tick.This tick appeared when you set the key for frame 1. With the ballselected, ticks in the Time Slider indicate where you’ve set keys.

3 Go to frame 72. A convenient way to do this is to click the desired positionin the Time Slider.

4 With the Move Tool, drag the ball’s X-axis handle to position the ball atthe right edge of the ground as shown in the image below.

5 Set a key at frame 72. (Press s.)

6 Go to the start time and play the animation.

From the two keys you’ve set, Maya creates motion between the positions.By default, the animation plays in a loop from frame 1 to 72. The balltravels through the fence at this stage.

7 Press the Stop button on the playback control to stop the animation afteryou view a few repetitions.

You can drag the mouse back and forth (scrub) in the Time Slider to seethe animation play back and forth at the speed you drag the mouse.

If you were to display the scene with Panels > Layouts > Four Panes, onlythe active panel would show the ball moving.

To make the ball fly over the fence rather than pass through it, you need toposition the ball above the fence and set a key there.

Setting keyframes | 189

Page 204: Autodesk Maya 2009

To set intermediate keyframes

1 Go to frame 33 or so—at the moment where the ball sits in the middleof the fence.

2 With the Move tool, drag the Y-axis handle of the ball until it sits slightlyabove the fence.

TIP Throughout this lesson, tumble the perspective view or examine a frontview to make sure the positioning is correct.

3 Set a key. (Press s.)

4 Play the animation.

The ball now flies off the ground, over the fence, and back to the groundin a smooth arc between the keyed start, middle, and end positions.

5 Press the stop button to end the playback.

In subsequent steps, play the animation after each key you set. It’sgenerally useful to check your work in progress after each key, especiallywhen you are learning.

In the next steps, you’ll set keys to bounce the ball in the middle of the righthalf of the ground.

To set keyframes to make the ball bounce

1 Go to frame 50. At this moment, the ball sits in a position above themiddle section of the right half of the ground.

2 Move the ball so it sits on the ground.

190 | Chapter 6 Animation

Page 205: Autodesk Maya 2009

3 Set a key.

4 Go to frame 60.

5 Move the ball up again, but not as high as its peak height above the fence.

6 Set a key. When you play the animation, the ball travels over the fenceand bounces on the other side.

If you have a fast computer, you might notice that the animation playstoo fast. By default, Maya plays the animation as fast as it can beprocessed. Because this scene is simple, the animation might play fasterthan the default film rate (24 frames per second).

Do not be concerned that the animation plays with a halting or jerkymotion. When you render all the frames of your animation for finalproduction, the animation will be smooth. If you want to preview theanimation at the smooth production speed (or nearly so), use Window> Playblast.

Using the Graph Editor

For a more convincing animation, you need to bounce the ball more sharplyoff the ground and speed up the ball’s horizontal movement. You’ll use theGraph Editor to make both modifications.

The Graph Editor is an editor that graphically represents the various animatedattributes in your scene. The animated attributes are represented by curvescalled animation curves. You edit animation curves in the Graph Editor.

To edit animation curves using the Graph Editor

1 With the ball selected, select Window > Animation Editors > Graph Editor.

Using the Graph Editor | 191

Page 206: Autodesk Maya 2009

The Graph Editor displays several animation curves, one for each keyedattribute of the ball. The animatable attributes for the ball are listed inthe left column. Specifically, it displays the attributes of the selectedtransform node of the ball.

Each curve graphs how an attribute changes value during the animation.The column of numbers at the left represents attribute values that canbe animated, while the row of numbers at the bottom represents time(frame) values. At each point on the curve, you can see the value of anattribute at a particular time. The small black squares on the curvesrepresent points where you’ve set keys.

2 Shift-Select only the Translate X and Translate Y attributes in the leftcolumn of the Graph Editor.

Now only the animation curves for Translate X and Translate Y appearin the Graph Editor.

This simplifies the display. With too many curves present, it’s hard tosee specific curves. When you use the Graph Editor, you usually focus onone or a few curves.

3 To center the display of the animation curves, select View > FrameSelection (in the Graph Editor window). If you want to see more detailin the graph, use your mouse to dolly and track the graph view.

192 | Chapter 6 Animation

Page 207: Autodesk Maya 2009

The green curve represents Translate Y, while the red represents TranslateX. The color of each curve matches its attribute name. This color schemeis consistent throughout Maya for X, Y, and Z (red, green, blue).

If you’ve never used a graph editor before, the relationship between acurve’s shape and the animation it represents might be hard tounderstand. With experience, you’ll quickly recognize how curve shapeaffects animation.

In the above graph, the straight curve of Translate X indicates that theball moves horizontally across the ground at a constant rate over time.

The wavy curve of Translate Y indicates that the ball increases its heightsteadily until frame 33, dips more quickly until frame 50, then rises anddips again until frame 72.

When the ball first bounces off the ground at frame 50, it seems to floatand slip rather than rebound. The shape of the Translate Y curve illustrateswhy. Near frame 60, the curve is soft and rounded. The Translate Y valuesgradually decrease to the low point then gradually increase. The transitionfrom decreasing to increasing values is smooth.

The Graph Editor’s usefulness lies in the fact that you can edit the shapeof the animation curves to edit the animation of any keyed attribute. Tocreate a sharp bounce, you can edit the curve so that the transition fromdecreasing to increasing values is abrupt at frame 50. Specifically, you’llcreate a corner at that key point rather than a rounded curve.

4 Select the point on the Translate Y (green) curve at frame 50. This causesa pair of tangent handles to appear at the point. Each end point of thenewly displayed straight line is a tangent handle. The handles let youcontrol the curvature near the key point.

Animation curves have a few control structures for curve editing. Youcan do any of these operations:

n Use the Move tool and middle mouse button to move a key point.You can alternatively use your keyboard to enter precise values for aselected key’s frame and value in the boxes above the graph area.

n Use the Move tool and middle mouse button to drag the tangenthandles and change the adjacent curvature.(You can shift-drag with the Move tool to constrain a move operationto a single direction.)

n Use the Scale tool and middle mouse button to scale selected keypoints closer together or further apart.

Using the Graph Editor | 193

Page 208: Autodesk Maya 2009

n Use the Graph Editor’s Tangents menu items to change the adjacentcurvature. This is the operation you’ll use in the next step.

5 In the Graph Editor, select Tangents > Linear.

This changes the curvature around the key point from rounded tocornered. Specifically, the setting you select specifies how the key pointtangent handles lie at this key point. This affects the type of interpolationbetween key points.

6 Play the animation and you’ll see the ball bounce more sharply.

To sharpen the bounce more, you need to edit the positioning of thetangent handles to steepen the curvature approaching the key point.

7 Select one of the tangent handles.

8 Use the Move Tool and the middle mouse button to drag it upwards alittle so you can see the how the curvature at the key point changes.

By default, when a pair of tangent handles share a key point, they workas a unit. Move one and you move the other in an opposing direction.This is often desirable in an animation curve, because it ensures thecurvature at that point stays symmetrical. Symmetrical curvature oftenhelps prevent unusual animation shifts.

In this case, however, you want to steepen the curvature’s approachtoward the curve point in the same direction on both sides. You thereforeneed to break the symmetrical interdependency between the two tangents.

9 Undo your previous move of the tangent handle.

10 Select the key point at frame 50 (not a tangent handle).

11 In the Graph Editor, select Keys > Break Tangents.

This lets you move each tangent handle independently.

194 | Chapter 6 Animation

Page 209: Autodesk Maya 2009

12 Select the right tangent handle and use the Move Tool to move it up alittle. Do the same for the left tangent handle. Be careful not to select thekey point.

This sharpens the bounce to simulate the effect of gravity and elasticity.

Changing the timing of an attribute

The ball seems to move too slowly in its journey. In the following steps, you’lluse the Graph Editor to hasten its movement. Specifically, you’ll cause theball’s animation to finish its journey in two seconds (48 frames) rather thanthree (72 frames).

To speed up the animation of the ball’s movement

1 Drag a selection box around all key points of both curves.

2 Select the Scale tool.

3 Click and hold the middle mouse button anywhere in the graph at frame1 (slightly to the right of 0).

Notice the question mark icon. The location of this icon indicates thepoint from which scaling occurs. (Because you need to scale the animationinward toward frame 1, you need to start your drag operation at frame1.)

4 Without releasing the mouse button, drag to the left until the right-mostkey points on both curves are positioned roughly at frame 48. (Whenselected, the right-most key points are yellow.)

Changing the timing of an attribute | 195

Page 210: Autodesk Maya 2009

This scales the curves symmetrically towards frame 1. The animation ofthe ball now plays from frame 1 to 48 rather than 1 to 72. The balltraverses the scene in less time, which, of course, means it moves faster.

If you had started your drag operation from the middle of the framerange, the scale operation would have pulled the curves toward the middleof the frame range. You can snap the keypoints to whole values to keepthe keyframes on a consistent timing.

5 Widen the Graph Editor window as necessary to see the graph clearly.Also, dolly the view or select View > Frame Selection (in the Graph Editorwindow).

Fine tuning an animation

Now you can improvise adjustments to the animation on your own. Forexample, you might choose to speed the ball’s horizontal movement up tothe first bounce but not thereafter. You might also decide to raise the peakheight of the ball’s motion so that it doesn’t seem to hover over the fenceunrealistically.

Whatever you choose to do, you’ll likely need to edit both the Translate Xand Translate Y curves, not just one of them. Play the animation after eachadjustment.

The following two figures show examples of curves after modification. Thetwo graphs are identical, except the curve points are selected in the secondfigure. The second graph shows the position of the tangent handles.

196 | Chapter 6 Animation

Page 211: Autodesk Maya 2009

If you want your curves to match the shape of the curves in the above figure,here’s what you would need to do:

To adjust the animation curves to match the above images

1 On the Translate X curve, delete the three key points between the twokey points at the end. To delete keys, select the key points and pressDelete. (The preceding figures show the curve after the points weredeleted.) To delete the points, drag a selection box around them and pressDelete.

With fewer key points on the curve, it’s easier to maintain the curve’ssmoothness for larger distances as you edit its shape. Small kinks in ananimation curve can ruin an otherwise perfect animation, so it’s usefulto remove key points that you aren’t using.

2 On the Translate X curve, select the left-most key point and move itsright tangent handle down slightly. (Remember to use the middle mousebutton when moving a handle or point.) Select the right-most key pointand move its left tangent handle up slightly.

Notice that the slope of the Translate X curve increases slightly in theearly part of the animation, then tapers off toward the end. This causesthe ball to accelerate slightly at the beginning of the animation, thendecelerate after its first bounce.

3 On the Translate Y curve, remove the key point at frame 22. (Thepreceding figures show the curve after the point was removed.) This pointwasn’t essential to the curve shape.

Fine tuning an animation | 197

Page 212: Autodesk Maya 2009

4 On the Translate Y curve, select the left-most key point and move itsright tangent handle up slightly.

5 At the key point where the bounce occurs on the Translate Y curve, movethe left tangent handle up a bit. This raises the high part of the curve leftof that key point, which makes the ball rise higher over the fence.

6 If you want to change the shape of Translate Y curve but lack adequatecontrol with the existing key points, you can add a key point at theposition of your choice. (No key points were added in the prior figures.)To add a key, click the Add Keys Tool icon, select the curve, andmiddle-click the desired position on or off the curve.

Deleting extra keyframes and static channels

As you set keys, you often create many unintended keys. For example, whenyou used the Set Key operation on the ball, Maya created keys on all transformnode attributes of the ball, for instance Rotate Z, not just the intended TranslateX and Translate Y attributes. The curves representing such attributes haveunchanging values. The attributes are known as static channels.

You can identify static channels by examining animation curves in the GraphEditor. If a curve is horizontally flat its whole length, the value of the attributeit represents isn’t changing. The attribute is a static channel. Static channelsslow Maya processing, so it’s beneficial to remove them in complex scenes.

To delete static channels

1 From the main menu, select Edit > Delete by Type > Channels, StaticChannels, Non-particle Expressions.

This deletes all unnecessary keys for all objects in the scene. Alternatively,you can remove the static channels for a selected object with Edit > Delete byType > Channels, Static Channels, Non-particle Expressions.

In addition to static channels, you’ll often create excess keys—keys that aren’tbeing used to control the shape of a curve. Whenever you see three key pointsthat lie in a straight line, the one in the middle is unnecessary. For example,in this lesson’s original Translate X curve, there were four redundant keys:

198 | Chapter 6 Animation

Page 213: Autodesk Maya 2009

When you remove redundant key points, the shape of the curve doesn’t changeand you speed up Maya processing.

Using Playblast to playback an animation

When you play a scene, you see a rough approximation of the animation. Theplayback speed and quality is imprecise as compared to rendering each frameand playing the frames in sequence with a playback utility specifically designedfor this purpose. The reason for this is that Maya processes the animation ofeach frame before display, while a playback utility simply plays previouslyprocessed and rendered images.

The more detail that Maya needs to process, the slower the playback. Forexample, playback will likely be slow for any scene that has several complexobjects displayed with Smooth Shade All and Hardware Texturing.

To preview the animation with more accurate timing

1 Select Window > Playblast.

For the next several seconds, Maya processes the entire animation frameby frame. When the process is complete, a playback window appears.

2 Click the play button in this window to watch the animation.

3 Close the Playblast window when you’re done.

Using Playblast to playback an animation | 199

Page 214: Autodesk Maya 2009

Beyond the lesson

In this lesson, you learned how to:

n Set keys for attributes, then use the Graph Editor to refine the animationand remove unnecessary keys. This is a typical workflow when keyframing.You can animate most any attribute in Maya, not just the Translate, Rotate,and Scale attributes of a surface. For example, you can animate the intensityof a light, the transparency of a surface, the rotation of a camera view, orthe position of CVs.

n Work with the Graph Editor to adjust the animation attributes animationcurves directly.The Graph Editor is the best tool for editing keyed animation by reshapinganimation curves. You can use it to change key positions, add or removekeys, and alter the fluidity and symmetry of animation.

Each key point on an animation curve has a Tangent setting that specifiesthe curvature leading into that point. The default Tangent setting (Spline)creates rounded curvature—useful for animating attributes that changesmoothly over time. The Linear setting creates angular curvature, usefulfor a bounce effect or any other abrupt change in attribute value. OtherTangent settings are available for different animation effects. For example,a Stepped setting lets you make an instantaneous leap in value, usefulwhen you want to flash a light off and on.

n Use the Time and Range slider to play back your animation.Although the Graph Editor is a popular animation tool, you can also cut,copy, paste, and delete keys directly in the Time Slider to edit animation.Select a key position in the Time Slider, then right-click to select the desiredoperation from a pop-up menu.

You may find the following techniques useful when keyframing youranimations:

n There are alternative object display modes that quicken the display ofanimation in the scene view. When you select Shading > Bounding Box(from the panel menu in the scene view), Maya displays simple box-shapedgeometry in place of the actual objects in your scene. The simpler shapesenable Maya to respond to any camera and object movement faster. Thedrawback is that you cannot edit the shape of the objects in this displaymode.

n It is generally a recommended practice to animate a parent (group) noderather than objects themselves. By animating a parent node, you can avoid

200 | Chapter 6 Animation

Page 215: Autodesk Maya 2009

problems that occur when the animation of one object in a hierarchyconflicts with the animation in another part of the hierarchy.

Lesson 2: Set Driven Key

Introduction

With keyframe animation, you key an attribute value to a time in the TimeSlider. You repeat this process with different values at different times to animatethe object.

When you must animate multiple objects or attributes that interrelate, settingkeyframes can quickly become a complex task. Set Driven Key is a techniquefor driving one object’s or attribute’s animation from another attribute.

With driven keys, you relate an attribute value to the value of another attribute.You repeat this with different values to create a dependent link between a pairof attributes. A change in the driver attribute alters the value of the drivenattribute. In this way the animation of the driven attribute doesn’t need tobe manually set; it occurs automatically once the relationship betweenattributes has been established. This makes setting up some types of animationsmuch more efficient. For example, you can use driven keys to make a dooropen when a character walks in front of it.

In this lesson, you will learn how to use Set Driven Key in order to animate adoor rising upwards when a ball approaches it.

In this lesson you learn how to:

n Link the object attribute behavior between two objects which will link themovement of one keyframed object to another with no keyframes assigned.

n Use the Graph Editor to adjust the animation for the driven object.

Lesson 2: Set Driven Key | 201

Page 216: Autodesk Maya 2009

Lesson setup

In the following steps, you set a playback range that’s long enough to see theanimation clearly. You also create the ball and the door, and position themin the scene view in preparation for the animation.

1 Make sure you’ve done the steps in Preparing for the lessons on page 185.

2 Create a new scene.

3 Go to the start frame.

4 Create a polygonal cube and name it Door.

5 Scale and position it roughly as shown in the previous figure. Have thebottom edge of the door lie roughly along the X-axis.

6 With the pointer in the perspective view, press 5 (for Shading > SmoothShade All).

7 Create a small polygonal sphere and name it Ball. Scale and position itroughly as shown in the prior figure in the introduction. Have it sitroughly at 0, 1, 10 (X, Y, Z).

Use the default color for the door and the ball.

Using Set Driven Key to link attributes

The following steps link the door’s movement to the ball’s movement usingSet Driven Key.

To link the door’s movement to the ball’s movement

1 Select the door and choose Animate > Set Driven Key > Set.

The Set Driven Key window appears with the door in the Driven list.

202 | Chapter 6 Animation

Page 217: Autodesk Maya 2009

2 Click translateY in the Driven list.

This is the attribute to be driven by the ball’s movement.

3 Select the ball in the scene view.

4 In the Set Driven Key window, click the Load Driver button.

The ball appears in the Driver list.

5 In the Set Driven Key window, click translateZ in the Driver list.

This is the attribute that will drive the door’s movement.

You can set a driven key only after you select an attribute in the Driverlist and in the Driven list.

6 In the Set Driven Key window, click Key.

This sets a driven key relationship that links the current Translate Z valueof the ball to the current Translate Y value of the door. Whenever theball’s Translate Z is at this position, the door’s Translate Y will be at itscurrent position.

Using Set Driven Key to link attributes | 203

Page 218: Autodesk Maya 2009

The Time Slider is not involved in a driven key relationship and displaysno red markers for keys.

7 Move the ball to the door’s position and then move the door above theball.

8 In the Set Driven Key window, click Key.

This sets another driven key that links the current Translate Z value ofthe ball to the Translate Y value of the door.

9 Move the ball to the right of the door and then lower the door to itsprevious position as shown in the following figure.

10 In the Set Driven Key window, click Key.

This sets another driven key that links the attributes.

You’ve set three driven keys that link the attribute values at differentpositions. Maya interpolates the linked values to generate the valuesbetween the keys.

If you drag the ball toward the door from either side, the door risessmoothly.

Playing back the animation from the Time Slider doesn’t move the ballor the door. Driven keys link one attribute to another. They don’t linkattributes to times in the Time Slider. However, if you were to animatethe movement of the ball, the door would move based on the driven keyrelationship that has been set.

204 | Chapter 6 Animation

Page 219: Autodesk Maya 2009

Viewing the results in the Graph Editor

In the next steps you’ll examine the animation curve resulting from the drivenkeys you’ve set. If you are unfamiliar with animation curves and the GraphEditor, see Lesson 1: Keyframes and the Graph Editor on page 186.

To view the set driven key results in the Graph Editor

1 Select the door. To display the animation curve for a driven key in theGraph Editor, you must select the object containing the driven attribute,not the object containing the driving attribute.

2 Select Window > Animation Editors > Graph Editor.

3 From the Graph Editor, select View > Frame All. The Graph Editor showsthe driven keys that link the door’s TranslateY value to the ball’s TranslateZ value. An example follows:

The column of numbers on the left lists the driven attribute values. Therow at the bottom lists driver attribute values. The animation curve showsthe relationship between the values—the door’s Translate Y value risesas the ball’s Translate Z value approaches 0.

You can use the Graph Editor to edit the shape of the curve to make thedoor rise faster, slower, and higher as the ball approaches it.

Beyond the lesson

In this lesson you learned how to:

n Set driven keys to link one attribute’s values to another.A driven attribute is not directly affected when you play the animation.It is linked to a driving attribute’s value, not animation time. However,

Viewing the results in the Graph Editor | 205

Page 220: Autodesk Maya 2009

you can use regular animation keys, expressions, motion paths, or othertechniques to animate the driving attributes. This indirectly animates thedriven attribute.

You may find the following notes helpful when using Set Driven Key:

n You can set driven keys to control a driven attribute with multiple drivingattributes. For instance, you can have a muscle bulge when an elbow rotates,and have the bulge increase when the wrist rotates.

Lesson 3: Path animation

Introduction

Path animation allows you to animate an object along a path specified by acurve. In this way, the curve controls the motion of the object. With keyframeanimation, Maya calculates the motion of the object for the animation basedon the positions that were set at the keyframes. With path animation themotion for the object is defined by its location along the path curve.

Path animation is useful for animating objects such as trains, boats, airplanes,and moving cameras whose motion follows a set path. To animate an objectto do this type of motion smoothly with keyframe animation would requireyou to laboriously create and edit many keys for the motion. By having theobject move along a curve, you can easily adjust the object’s path by editingthe curve.

206 | Chapter 6 Animation

Page 221: Autodesk Maya 2009

In this lesson, you make an aircraft follow a motion path so it appears to flyand bank while it changes trajectory. We provide a scene for your use in thelesson.

In this lesson, you learn how to:

n Set an object to animate along a motion path using a NURBS curve as thepath.

n Modify the timing and rotation of an object along a motion path.

n Blend between keyframe and motion path animation.

Open the scene for the lesson

In this lesson, you work with a scene we created for your use.

1 Make sure you’ve done the steps in Preparing for the lessons on page 185.

2 Open the scene file named PathAnim.ma.

This file can be found in the GettingStarted directory that you set asyour Maya project:

GettingStarted/Anim/PathAnim.ma

The scene contains two objects named Aircraft and PathCurve. Whenthe aircraft travels on the path curve it will return to where it began.

3 In the Time Slider, ensure that the Playback End Time is set to 240.

Open the scene for the lesson | 207

Page 222: Autodesk Maya 2009

The path animation occurs between frames 60 and 240 (180 frames in total).Between frames 1 and 60, you keyframe the aircraft’s motion so it rises fromthe ground plane. You then blend between the two animation types.

Animating an object along a motion path

To animate the aircraft along the path curve, first select the aircraft and thepath curve and then set appropriate options for the motion path animation.In the options window, you need to set the required time range for the pathanimation. You also need to ensure that the aircraft is oriented facing towardsthe direction of travel. The Follow, Front, and Up axis option settingsdetermine the aircraft’s orientation along the path.

To attach the aircraft to the motion path

1 Set the Time Slider to frame 1.

2 Select the aircraft and then shift-select the path curve.

3 In the main menu, select Animate > Motion Paths > Attach to Motion

Path > .

The Attach to Motion Path Options window appears.

4 In the options window, ensure the options are set as follows, then clickAttach:n Time Range: Start/End

n Start Time: 60

n End Time: 240

n Follow: On

n Front Axis: X

n Up Axis: Y

n World Up Type: Scene Up

n Leave all other settings off

208 | Chapter 6 Animation

Page 223: Autodesk Maya 2009

The aircraft is repositioned to the start of the curve, and oriented towardsthe direction of travel.

The Start and End Times set the time duration the aircraft travels alongthe path curve (240 - 60 = 180 frames). The start and end times aredisplayed at the ends of the curve.

5 Click play on the Timeslider playback controls to play back the animation.

The aircraft travels along the path. Observe that it begins its motion atframe 60.

Animating an object along a motion path | 209

Page 224: Autodesk Maya 2009

Changing the timing of an object along a motionpath

When you first assign an object to a motion path, by default, the object travelsalong the path at a constant speed. In this lesson, you want the aircraft toinitially travel along the path slowly, accelerate, and then finally move moreslowly when it nears the end of the motion path.

You can change the rate of travel for the aircraft by keyframing attributes thataffect where the aircraft is positioned on the curve at a given time.

To view the attributes for the motion path

1 Set the Time Slider to frame 1.

2 Select the aircraft.

3 Open the Channel Box by clicking the Show/Hide Channel Box icon onthe Status Line.

4 In the Channel Box, click on the word motionPath1 that appears in theAircraft’s Inputs list.

The attributes for motionPath1 appear at the bottom of the Inputs list.(Scroll the Channel Box window if the MotionPath1 attributes are notfully visible).

The UValue attribute controls where the aircraft gets positioned along thecurve. The UValue refers to the curves parameterization. Parameterization is amethod used by Maya to divide a curve into increments of known amountsso that a location along the curve can be determined.

210 | Chapter 6 Animation

Page 225: Autodesk Maya 2009

By default, the parameterization of a path curve is set between zero and one.At frame 60, the aircraft is at the beginning of the curve where theparameterization value is zero. When the aircraft is at the end of the curve(frame 240) the parameterization value for the curve is one. When the aircraftis halfway through the path animation (frame 150), it is located along thecurve at a UValue of 0.5.

By setting the frame number and UValue and then setting a key, you changethe timing for the aircraft’s motion along the path.

To change the timing for the aircraft along the path

1 Ensure the aircraft is selected so its attributes display in the Channel Box.

2 In the Time Slider, drag the current time indicator to frame 120 usingthe middle mouse button.

Middle-dragging the current time indicator, instead of using the leftmouse button, changes the current time without repositioning the aircraftalong the path.

3 In the Channel Box, set the UValue for MotionPath1 to 0.1.

The aircraft is repositioned along the curve near the first bend. Whenyou set the UValue to 0.1, the aircraft is positioned at a point that is adistance of 10 percent from the beginning of the curve (that is, the aircrafthas completed 10 percent of the distance along the path).

4 In the Channel Box, select the UValue channel by clicking on its nameso it becomes highlighted.

Changing the timing of an object along a motion path | 211

Page 226: Autodesk Maya 2009

5 Right-click on the selected name.

A drop-down list appears.

6 From the drop-down list, choose Key Selected.

A position marker appears on the path curve indicating that a key framehas been set. The position marker is useful for determining where theaircraft is at a given time. Position markers do not appear when yourender the animation. Using Key Selected ensures that a keyframe is setonly for the item selected and nothing else.

7 In the Time Slider, middle-drag the current time indicator to frame 180.

8 In the Channel Box, set the UValue for MotionPath1 to 0.9.

The aircraft is repositioned along the curve near the last bend. When youset the UValue to 0.9, the aircraft is positioned at a point that is a distanceof 90 percent from the beginning of the curve. (that is, the aircraft hascompleted 90 percent of the distance along the path)

9 In the Channel Box, select the UValue channel by clicking on its nameso it becomes highlighted.

10 Right-click on the selected name and choose Key Selected.

A position marker appears on the path curve.

212 | Chapter 6 Animation

Page 227: Autodesk Maya 2009

11 Click play on the Time Slider’s playback control to play back theanimation.

The motion of the aircraft is not smooth as it travels along the path. Itinitially moves forwards and backwards a bit at the beginning and endof the path. This indicates that some adjustment of the animation isrequired. You adjust the animation using the Graph Editor.

To view the Graph Editor

1 From the main menu, select Window > Animation Editors > Graph Editor.

The Graph Editor appears.

2 In the Graph Editor, select View > Frame All.

The Graph Editor updates to display the animation curve for the motionpath animation.

The shape of the animation curve provides some clues as to why the motionof the aircraft is not smooth. Between frames 60 and 84 the curve rises andthen drops slightly. Because the animation curve represents translation alongthe curve, a drop in the curve indicates that the object travels backwards. Asimilar occurrence happens at the end of the curve as well. To correct this,you need to modify the tangents for the keys in the Graph Editor.

To edit the tangents for the keys in the Graph Editor

1 In the Graph Editor, press the shift key, then double click on theanimation curve to select the four keys (frames 60, 120, 180 & 240)

2 In the Graph Editor menu, select Tangents > Linear.

Changing the timing of an object along a motion path | 213

Page 228: Autodesk Maya 2009

The animation curve updates so that the keys connect via straight lines.This eliminates the dips in the curve that caused the aircraft to travelbackwards.

Next, you modify the tangents for keys 120 and 180 so the aircraft acceleratesand decelerates near those points on the path curve.

1 In the Graph Editor, shift-select only the two keys for frames 120 and180.

2 In the Graph Editor menu, select Keys > Break Tangents.

Breaking the tangent for the keys allows you to modify the shape of thecurve as it enters or leaves a key.

3 Select only the key for frame 120.

A pair of tangent handles appear on either side of the key. The handleslet you edit the curvature of the animation curve near the key point.

4 Select the tangent handle to the right of the key.

The handle highlights in a yellow color.

5 From the Toolbox, select the move tool.

6 Using the middle mouse button, drag the handle so the curve has a gentlecurvature as it leaves the key as shown below.

Modifying the tangent in this manner changes how the motion transitionsas the curve changes direction as it passes through the key. The aircraftwill accelerate smoothly instead of immediately travelling at a differentrate of speed.

214 | Chapter 6 Animation

Page 229: Autodesk Maya 2009

7 Select the key for frame 180.

8 Select the handle to the left of the key.

The handle highlights in blue.

9 Using the middle mouse button, drag the handle so the curve has a gentlecurvature as it enters the key as shown below.

Modifying this tangent for this key will cause the aircraft to deceleratesmoothly near the end of its travel.

The modified animation curve appears as shown below.

10 Close the Graph Editor.

11 Click play on the Time Slider’s playback control to play back theanimation.

Changing the timing of an object along a motion path | 215

Page 230: Autodesk Maya 2009

The backwards and forwards motion that previously occurred is corrected.The aircraft travels slowly towards the first bend in the path curve, thenaccelerates and travels at a constant speed around the curve until it nearsthe end of the path where it decelerates and then slowly moves towardsthe end of the curve.

Rotating an object along a motion path

As the aircraft travels along the motion path, its orientation remains the samethroughout the animation. A real aircraft rolls to one side (banks) as it fliesin an arc. To make the aircraft roll to one side as it travels along the path youset keyframes for the Twist attributes in the Channel Box.

To animate the roll of the aircraft along the path

1 Ensure the aircraft is selected.

2 Set the Time Slider to frame 120.

The aircraft is repositioned along the curve near the first bend.

3 In the Inputs section of the Channel Box, click on motionPath1 to viewits attributes.

4 Ensure the Front Twist value for motionPath1 is set to 0.

5 In the Channel Box, select the FrontTwist channel by clicking on itsname.

6 Right-click on the selected name.

A drop-down list appears.

7 From the drop-down list, choose Key Selected.

8 To set the remaining keyframes for the rotation of the aircraft, use thetable below as a guide, keeping in mind that you set the keyframes in thefollowing order:n Set the frame in the Timeslider

216 | Chapter 6 Animation

Page 231: Autodesk Maya 2009

n Set the values for Front Twist in the Channel Box.

n Select the Front Twist channel by clicking its name. Right-click onthe selected name and choose Key Selected.

ChooseSet channel attrib-ute

SelectFrame

key selectedFront Twist: -15Aircraft130

key selectedFront Twist: -45Aircraft135

key selectedFront Twist: -70Aircraft150

key selectedFront Twist: -45Aircraft165

key selectedFront Twist: -15Aircraft170

key selectedFront Twist: 0Aircraft180

9 Click play on the Time Slider playback controls to play back theanimation.

The aircraft rolls to one side (banks) as it travels along the motion path.

Blending keyframe and motion path animation

Blending between motion path and keyframe animation types is possible inMaya. Blending between the two animation types allows you to take advantageof the characteristics each animation type can provide without having toexpend a lot of effort in determining where the change between the two typesmust occur.

Blending keyframe and motion path animation | 217

Page 232: Autodesk Maya 2009

In the steps that follow, you keyframe the aircraft to rise vertically from thefloor surface and then travel along the motion path by blending between thetwo animation types. To accomplish this, you do the following:

n Move the motion path up above the ground plane.

n Keyframe the aircraft so it rises vertically above the ground plane.

n Blend between the keyframe and motion path animations.

To move the motion path

1 In the scene view, select only the path curve.

2 In the Channel Box, set Translate Y to 5 for PathCurve.

The path curve is repositioned above the ground plane in the scene view.The aircraft moves with the path curve because it is attached to the motionpath.

To keyframe the motion for the aircraft

1 Select only the aircraft.

2 Set the Timeslider to frame 1.

3 In the Channel Box, set the following for the aircraft:n Translate Y: 0

The aircraft is repositioned so it rests on the ground plane.

4 Select the Translate X, Y, and Z channels as well as the Rotate X, Y, andZ channels by click-dragging on their names so they become highlighted.

218 | Chapter 6 Animation

Page 233: Autodesk Maya 2009

5 Right-click on any of the highlighted names, and choose Key Selectedfrom the drop down list that appears.

Keys are set for the selected channels. Keyframing these channelsestablishes a blending connection that will be discussed in subsequentsteps.

6 In the Channel Box, set the following:n Rotate Y: - 90

The aircraft is rotated 90 degrees from its motion path position.

7 Select the Rotate Y channel by clicking on its name so it becomeshighlighted.

8 Right-click on the name, and choose Key Selected from the drop downlist that appears.

A keyframe is set for the aircraft.

Additional channels have appeared in the Channel Box. When a keyframe isset for an object that already has motion path animation, the softwareautomatically creates a connection to blend between the two animation types.These new channels are used to control the blend between the keyframe andmotion path animation types. They control the blend for the Translation andRotation attributes.

Blending keyframe and motion path animation | 219

Page 234: Autodesk Maya 2009

1 To set the remaining keyframes for the keyframe motion of the aircraft,use the table below as a guide, keeping in mind that you set the keyframesin the following order:n Set the frame in the Time Slider.

n Set the Translate and Rotate values in the Channel Box.

n Select only the channels for those values. Right-click on the selectedname and choose Key Selected.

ChooseSet channel attrib-ute

SelectFrame

key selectedTranslate Y: 1Aircraft20

key selectedTranslate Y: 2Aircraft30

key selectedRotate Z: 170Aircraft30

key selectedTranslate Y: 3Aircraft40

key selectedRotate Z: 170Aircraft40

2 Click play on the Timeslider playback controls to play back the animation.

220 | Chapter 6 Animation

Page 235: Autodesk Maya 2009

The aircraft rises above the ground plane and then stops at frame 40.

The animation stops because the motion path animation was shut off whenthe blend attribute was automatically created when you set the first keyframe.The blend attribute values are set to zero by default. When the blend valuesare set to zero, the keyframe animation has full influence on the object, andthe path animation is shut off. When the blend values are set to one, themotion path has full influence on the object and the keyframing is shut off.When the blend values are between zero and one, the aircraft’s motion isblended between the keyframe and motion path animation.

In the next steps, you keyframe the blending attributes so the blending beginsat frame 30 and ends at frame 70. This blends the two animation types togetherover a period of 40 frames.

To blend between the two animation types

1 Set the Timeslider to frame 30.

2 In the Channel Box, ensure the blend values are set as follows:n BlendAddDoubleLinear: 0

n BlendMotionPath: 0

3 Select the BlendAddDoubleLinear1 and BlendMotionPath1 channels byclick-dragging on their names so they become highlighted.

Blending keyframe and motion path animation | 221

Page 236: Autodesk Maya 2009

4 Right-click on one of the names, and choose Key Selected from the dropdown list that appears.

A key is set for the blend starting point for the aircraft. At frame 30 thetwo animation types will begin to blend together.

5 Set the Timeslider to frame 70.

6 In the Channel Box, set the following:n BlendAddDoubleLinear1: 1

n BlendMotionPath1: 1

7 Right-click on one of the names, and choose Key Selected from the dropdown list that appears.

A key is set for the blend ending point for the aircraft. At frame 70 themotion path animation will have full influence.

8 Click play on the Timeslider playback controls to play back the animation.

The two animation types are combined but the motion does not appearcorrect. The aircraft rotation flips upward momentarily when it beginsto travel along the motion path.

The interpolation type for the rotations during the blending is not setcorrectly.

Setting the pairBlend Rot Interpolation setting to Quaternions changes howthe rotations are interpolated during the blend. In this example, Quaternionsprovides a better interpolation type when blending between the keyframe andmotion path animation. For more information see quaternion rotation in theMaya Help.

222 | Chapter 6 Animation

Page 237: Autodesk Maya 2009

To edit the rotation interpolation type for blending

1 In the Channel Box, click on the pairBlend1 channel.

2 Scroll the Channel Box so you can view the Attributes for pairBlend1.

3 Set the Rot Interpolation setting to Quaternions by clicking on the Eulerangles name with the left mouse button.

4 Click on the pairBlend2 channel.

5 Click on the Euler angles name in the Rot Interpolation attribute andchoose Quaternions.

6 Click play on the Timeslider playback controls to play back the animation.

The animation plays back smoothly. Observe how the blending also takesinto account the rotation of the aircraft so it meets up with the motionpath smoothly.

Using Playblast to playback an animation

Playblast allows you to preview an animation by calculating the separateframes and playing them back in a multimedia player window based on thePlayblast options. Playblast provides a more accurately timed playback thanusing the Timeslider.

To playback the animation using Playblast

1 Select the path curve, and then select Display > Hide > Hide Selection tohide the curve while you Playblast.

2 Select Window > Playblast.

Using Playblast to playback an animation | 223

Page 238: Autodesk Maya 2009

Playblast calculates the frames for the animation and then plays themback in the player window.

You have completed this lesson.

Beyond the lesson

In this lesson you learned how to:

n Create a motion path animation using a NURBS curve as the motion path.When you draw your own curves remember that a curve has a definedstart and an end point based on how you create it. If your object is initiallypositioned at the wrong end of the curve, you can reverse the direction ofthe curve by setting the Menu Set to Modeling and then selecting EditCurves > Reverse Curve Direction.

If your objects are not oriented correctly on the path initially, you canchange the options in the Attach to Motion Path Options window. SeeAnimate > Motion Paths > Attach to Motion Path in the Maya Help.

n Adjust the timing and rotation of an object when it travels along themotion path.In this lesson you were shown how to keyframe the roll (bank) of theaircraft. The Attach to Motion Path Options window provides an optioncalled Bank. The Bank option rotates an object as it travels around curvedportions of a motion path. It is useful for simple motion path animation.

n Blend between keyframe and motion path animation types on the sameobject.For more information on how this works, see pairBlend in the Maya Help.

224 | Chapter 6 Animation

Page 239: Autodesk Maya 2009

Lesson 4: Nonlinear animation with Trax

Introduction

Nonlinear animation allows you to create and edit an animation sequence byarranging smaller animation sequences (known as clips) on a timeline. A clipis a time-independent sequence of animation that you create from an existinganimation (keyframe animation, expressions, constraints, and motion capturedata - except motion path animation).

Nonlinear animation tools in Maya® TraxTM give you the ability to experimentwith your animation sequences and character animations without having toredo all of your work when you want to modify or construct a differentanimation.

Nonlinear animation is a non-destructive process. You can modify a particularclip’s attributes without affecting the source animation: the source materialremains untouched. This makes nonlinear animation useful when you wantto experiment, iterate, or change a particular animation sequence.

The primary tool for working with nonlinear animation is the Trax Editor.You can also store your clips for future use by creating a library of clips.

In this lesson you learn how to:

n Key animation sequences for use as nonlinear clips in Trax.

Lesson 4: Nonlinear animation with Trax | 225

Page 240: Autodesk Maya 2009

n Create clips from your animation sequences for use in the Trax Editor.

n Use the Trax editor to position, modify, and arrange clips in order to createand modify animation sequences in the scene.

n Scale clips to modify the timing of an animation sequence.

n Trim clips to remove unwanted motion.

n Cycle clips to create motion that repeats.

n Use the Graph Editor to modify the animation of a clip.

n Use the Trax Editor to work with motion capture data.

n Reuse clips using the Outliner and the Visor.

Open the first scene for the lesson

This lesson is presented in two parts. You work with two separate scene fileswe’ve created for your use. In the first part of this lesson, you learn some ofthe fundamental techniques for working with clips in the Trax Editor byanimating an aircraft taking off and landing.

1 Make sure you’ve done the steps in Preparing for the lessons on page 185.

2 Open the scene file named Trax_Lesson1.ma.

This file can be found in the GettingStarted directory that you set asyour Maya project:

GettingStarted/Anim/Trax_Lesson1.ma

The scene contains a model of an aircraft. For the first part of this lesson,you create and work with animation clips to control the motion of theaircraft.

226 | Chapter 6 Animation

Page 241: Autodesk Maya 2009

3 In the Time Slider, set the Playback range as follows:n Playback Start Time: 1

n Playback End Time: 240

To work more efficiently with the scene and the Trax Editor, you need to seta panel layout.

To set a panel layout for use with the Trax Editor

1 From the perspective view’s menu, select Panels > Saved Layouts >Persp/Trax/Outliner.

The panel layout updates to display the Perspective view, Outliner, andTrax Editor simultaneously. This allows you to easily work with thesewindows without having to open and close them repeatedly.

Next, set the Outliner so it displays clips. The Outliner allows you to managethe various clips that get created with Trax.

To set the Outliner to display clips

1 In the Outliner menu, make sure that Display > DAG Objects Only isunchecked.

2 In the Outliner menu, select Show > Objects > Clips.

The Outliner displays an empty list until you create your first clip.

Open the first scene for the lesson | 227

Page 242: Autodesk Maya 2009

Creating clips with Trax

A clip is a time-independent sequence of animation data for one or moreanimated attributes that you create from existing animation (keyframeanimation, expressions, constraints, motion capture data, and so on). A clipis time independent, allowing you to position, scale, and cycle a clipindependently of other animatable attributes or other clips. This means youcan arrange the clips into a particular sequence, and then play it back to seethe results. You can adjust the timing, length, and rearrange or edit the sameclips in a different order to modify the motion sequence.

Most commonly-used clips are reusable sequences of animation that are easyto sequence or blend with other clips. For example, suppose you create threeclips: a karate punch, tumble, and kick. You can run the clips in any order,and you can repeat clips or blend the motion between them. You can scaleor cycle clips to alter the time frame over which the animation occurs. Youcan either return the clip to its original state or reload a duplicate of the originalsource clip and begin again. In this way, the Trax Editor allows you toexperiment with animation sequences on a character.

In the steps that follow, you key some animation for the aircraft and thencreate clips from the keyed animation for use in the Trax Editor.

To create keyframe animation for the aircraft

1 From the perspective view’s panel menu, select Panels > Orthographic >front.

The panel updates to display the aircraft’s side from the front view.

2 In the front view, click on the aircraft to select it.

3 In the Channel Box, set the following:n Translate X: -25

The aircraft is repositioned at -25 along the X axis. The aircraft disappearsfrom the front view because it has been repositioned outside of theviewing area.

4 Dolly and track the front view until the aircraft appears on the lower lefthand side of the front view as shown below.

228 | Chapter 6 Animation

Page 243: Autodesk Maya 2009

5 Press s to set a keyframe.

In the Channel Box, the channels display in a different color. The colorchange indicates that the channels now have animation applied to them.

NOTE If you normally use the Auto Keyframe function, you must shut it offfor this lesson. For more information see Auto Key in the Maya Help.

6 In the Time Slider, set the current time indicator to frame 240.

7 In the Channel Box, set the following:n Translate X: 25

The aircraft is repositioned at 25 along the X axis (the right hand side ofthe current front view).

8 In the Channel Box, select the Translate X channel by clicking on thename.

The Translate X name becomes highlighted.

9 Right-click on the selected name and choose Key Selected from thedrop-down list that appears.

Key Selected sets a keyframe for only the selected attribute.

Confirm that the animation sequence works as expected in the steps thatfollow.

To playback the animation using the playback controls

1 Click play on the Time Slider’s playback control to play back theanimation.

Creating clips with Trax | 229

Page 244: Autodesk Maya 2009

The aircraft travels from left to right in the front view.

2 Click stop on the Time Slider’s playback control.

Now that you have keyframed an animation sequence and confirmed that itworks, you can create an animation clip.

To create an animation clip of the keyframe animation

1 In the Trax Editor menu, with the aircraft still selected, select Create >

Animation Clip > .

2 In the Create Clip Options window, select Edit > Reset Settings, and thenclick on the Create Clip button.

The Outliner updates and lists two items: clip1 and clip1Source. If theclips do not display refer to To set the Outliner to display clips on page227

When you created the clip, two clips were generated: a regular clip and asource clip. The source clip contains the animation curves for the character(based on the keyed attributes that the clip was created from). The sourceclip is stored with the file and can only be accessed from the Visor orOutliner. Maya saves the source clip outside of the Trax Editor to protectthe original animation curves from being accidentally modified andensures you have an unmodified clip to revert back to.

A regular clip (referred to simply as a clip) contains the same informationas the source clip, and is placed in a track in the Trax timeline. It is thisregular clip that you work with and modify in Trax.

230 | Chapter 6 Animation

Page 245: Autodesk Maya 2009

A clip does not yet appear in the track area of Trax Editor because thecharacter set associated with the clip (the aircraft) has not been loadedto display.

3 In the Trax menu, with the aircraft selected, click the Load SelectedCharacters icon.

The clip appears as a blue rectangular box in a track in the Trax Editor. Atrack is an area in the Trax Editor to place and work with one or morenon-overlapping clips in relation to the animation timeline. Tracks allowyou to work with your clips in a nonlinear manner by allowing you toreposition and scale clips in time or juxtapose them with other clips. Youcan work with multiple tracks in the Trax Editor.

4 In the Trax menu, select View > Frame All.

The Trax Editor updates to show the beginning and end point for all ofthe items displayed in the Trax Editor. (In this case the new clip.) Theclip represents the Translate X animation for the aircraft going from -25to 25, for a time range of 1 to 240 frames.

Anatomy of a clip

Every clip contains interaction controls that relate to information about theclip:

n Frame In and Frame Out indicates the current start and end frame numbersfor the clip in relation to its position on the timeline.

Creating clips with Trax | 231

Page 246: Autodesk Maya 2009

n Source In and Source Out indicates the range of frames from the originalsource clip.

n Duration indicates the length (duration) of the original source clip in frames.

n Clip Name...the name of the clip. A default clip name is assigned to theclip, unless you specify it from the Create Clip Options window when youfirst create the clip.

n Scale indicates the scale percentage for the clip. The scale percentage is themultiplier on the length of the original clip. For example, if you scale aclip fifty percent longer than its original length, the scale value would read150%.

Each area on the clip has a hot spot which you can either double-click on fornumeric values, and in some cases, click-drag to modify the related attribute.For example, you can double-click on the hot spot for the clip name to editthe name. For more information about clips and tracks, see Track view areain the Maya Help.

To edit the name of the clip in the Trax Editor

1 In the Trax Editor, double-click on the clip1 name on the clip.

The clip highlights in yellow to indicate it is selected and the clip1 namebecomes highlighted.

2 Type Travel_Forward and then press Enter.

The clip is renamed to Travel_Forward. The clip and the source clip’sname are updated in the Outliner to reflect the change.

If you play this clip in Trax, the animation is played back from the clip data,not the keyframe data that you set previously in the scene. When you createdthe clip, the source of the animation for the aircraft was changed to comefrom the clip instead of the keyframes.

When you create a clip, Maya creates a character set to contain the clip. Acharacter set is the parent of the hierarchy of clips and tracks for a particularanimated object. A clip’s animation resides under the character set node andadditional clips are placed under that node unless you specify otherwise.

232 | Chapter 6 Animation

Page 247: Autodesk Maya 2009

For more information see Nonlinear animation components in Trax in theMaya Help.

Now that you have created your first animation clip and renamed it using theTrax Editor, you need to create a few more clips by setting additional keys andcreating clips of the sequences. You need to create separate clips of the aircrafttaking off and landing.

To create an animation clip of the aircraft taking off

1 In the scene view, select the aircraft.

2 In the Channel Box, set the following:n Translate Y: 0

3 In the Channel Box, select the Translate Y name so it becomeshighlighted.

4 Right-click on the name and choose Key Selected to set a keyframe forthis position.

Key Selected sets a keyframe for only the selected attribute.

5 In the Time Slider, drag the current time indicator to frame 60.

6 In the Channel Box, set the following:n Translate Y: 7.0

7 In the Channel Box, select the Translate Y name so it becomeshighlighted.

8 Right-click on the name and choose Key Selected to set a keyframe forthis position.

9 In the Trax Editor menu, with the aircraft selected, select Create >Animation Clip (or click the Create Clip icon on the Toolbar).

Creating clips with Trax | 233

Page 248: Autodesk Maya 2009

The Trax Editor updates to create an additional track and places the newclip on the new track. The Outliner updates to list the new clip and sourceclip.

10 In the Trax Editor, double-click on the new clip and rename it toAircraft_Rise.

11 Click play on the Time Slider’s playback control to play back theanimation.

The aircraft rises as it travels forward.

12 Click stop on the Time Slider’s playback control.

To create an animation clip of the aircraft landing

1 In the Timeslider, set the current time indicator to frame 180.

2 In the Channel Box, with the aircraft still selected, set Translate Y to 7.

3 In the Channel Box, select the Translate Y name so it becomeshighlighted.

4 Right-click on the name and choose Key Selected to set a keyframe forthis position.

5 In the Time Slider, set the current time indicator to frame 240.

6 In the Channel Box, set the Translate Y to 0.

234 | Chapter 6 Animation

Page 249: Autodesk Maya 2009

7 In the Channel Box, select the Translate Y name so it becomeshighlighted.

8 Right-click on the name and choose Key Selected to set a keyframe forthis position.

9 Click play on the Time Slider playback controls to play back theanimation.

The aircraft travels forward and then lands as it nears the end of its travel.

10 Click stop on the Time Slider’s playback control.

11 In the Trax Editor menu, with the aircraft selected, select Create >Animation Clip.

The Trax Editor and Outliner update to show the new clip.

12 In the Trax Editor, double-click on the new clip and rename it toAircraft_Lower.

Changing the position of clips with Trax

It’s easy to alter the start time of clips to synchronize the action between clips.For example, the aircraft rises as it travels forward because the Travel_Forwardand Aircraft_Rise clips overlap in time. If you position the clips on theirrespective tracks so that one clip’s action occurs in the Trax timeline beforeor after the other, the motion occurs separately.

In this section, you learn how to reposition the clips so that the aircraft takesoff before it travels forward in X, and then have the aircraft land at the endof the sequence.

Changing the position of clips with Trax | 235

Page 250: Autodesk Maya 2009

To change the position of a clip in a track

1 In the Trax Editor, move the mouse cursor over top of the Travel_Forwardclip.

When the mouse cursor is over top of a clip in the Trax Editor, the cursoricon changes to a pointer indicating that you can drag the clip to eitherside or up and down between tracks.

2 Click-drag the Travel_Forward clip horizontally to the right in its trackuntil the Frame In reads 60 as shown below.

3 Click play on the Time Slider playback controls to play back theanimation.

The aircraft takes off vertically, then travels to the right, and lands whileit is still travelling to the right. Because the two clips (Travel_Forwardand Aircraft_Rise) are positioned one after the other, the actions occurin a series versus simultaneously.

4 Click stop on the Time Slider’s playback control.

5 Click-drag the Aircraft_Lower clip horizontally to the right until thebeginning of the clip matches the end of the Travel_Forward clip on thetrack above it. (Frame In = 299)

If the view of the clips appears limited, select View > Frame All in theTrax Editor to resize the view to encompass the clips.

236 | Chapter 6 Animation

Page 251: Autodesk Maya 2009

You also need to modify the Playback End Time because the animation timelineis longer as a result of repositioning the clips.

1 In the Time Slider, edit the Playback range as follows:n Playback End Time: 360

2 Click play on the Time Slider playback controls to play back theanimation.

The aircraft takes off vertically, then travels to the right, and then landsvertically once the Travel_Forward clip’s motion is complete. Because thethree clips are positioned end to end in relation to the timeline, theanimation occurs as a series of separate events.

3 Click stop on the Time Slider’s playback control.

Editing the animation of clips

You can modify the animation of a clip using the Graph Editor in the sameway that you would modify any other type of animation. Because you areworking with the clip, and not the original animation, you won’t change theoriginal source clip animation.

In this section, you use the Graph Editor to modify the animation for eachclip so the aircraft’s motion accelerates and decelerates at the beginning andend of each clip.

To use the Graph Editor to modify a clip in Trax

1 Click on the Aircraft_Rise clip to select it.

Editing the animation of clips | 237

Page 252: Autodesk Maya 2009

The selected clip highlights in yellow.

2 From the Trax menu, select View > Graph Anim Curves.

The Graph Editor appears.

3 In the Graph Editor, shift-select the two keys on the animation curve asshown below.

4 In the Graph Editor, select Tangents > Flat.

The shape of the animation curve updates to a gentle S-shape. Settingthe tangents for the animation curve in this manner modifies the clip’sanimation to cause the aircraft to accelerate when it first rises, anddecelerate when it nears the end of its vertical travel.

5 Repeat steps 1 through 4 to set the animation curve tangents in a similarmanner for the two remaining clips: Travel_Forward and Aircraft_Lower.

The shape of the animation curve for Aircraft_Lower will be reversed fromthe other clip curves because the motion is occurring in the oppositedirection.

6 Close the Graph Editor window.

7 Set the Time Slider’s current time indicator to frame 1.

8 Click play on the Time Slider’s playback control to play back theanimation.

The motion accelerates and decelerates at the beginning and end of eachclip. As a result, the motion appears more natural. It’s important to notethat the modified tangents for each clip are independent from the otheranimation clips and do not affect any other motion.

9 Click stop on the Time Slider’s playback control.

238 | Chapter 6 Animation

Page 253: Autodesk Maya 2009

Reusing clips within Trax

You can save and reuse clips for future use. You can key specific types ofmotion or attribute effects, save them as clips, and reuse the clips for othercharacters.

When you reuse a clip created for one character and apply it to another, theclip attributes must be mapped to correspond between the two characters. Formore information, see Mapping animation between characters in the MayaHelp.

In this lesson, you work with clips created for this aircraft animation. Theclips contain animation to make the aircraft shift to the left and right andbank left and right.

To load a clip from disk

1 From the Trax menu, select File > Import Animation Clip.

The File Browser appears. When importing a clip, the File Browser defaultsto the clip directory of your current project.

2 Find the clip file named Bank_Left.ma in the GettingStarted/Anim/clipsdirectory.

3 Select the file named Bank_Left.ma and click the Import button.

The clip is imported and appears in the Outliner named asBank_LeftSource to indicate it is a source clip.

4 Repeat steps 1 and 2 to import the clips Bank_Right, Shift_Left andShift_Right.

When you have finished, four new clips appear in the Outliner as sourceclips. In the steps that follow, you place and position the clips on tracksin the Trax Editor.

NOTE When you import clips they also appear in, and can be accessed from,the Visor (Window > General Editors > Visor). The Visor is a graphical interfacethat allows you to import items that reside on disk or in your current file (files,textures, clips poses, etc.). Clips that are assigned to a character in Trax willappear listed under the Character Clips tab in the Visor. Clips that have notyet been placed on a track will appear listed in the Visor under the UnusedClips tab.

Reusing clips within Trax | 239

Page 254: Autodesk Maya 2009

To place clips into a track from the Outliner

1 In the Outliner, using the middle mouse button drag the clip namedBank_LeftSource into the same track as the Rise and Lower clips. Ensureyou drag into an open area on the track that the clip will fit into.

2 Position the Bank_Left clip on the track so its Frame In number matchesthe Frame Out number on the Aircraft_Rise clip, as shown below.

3 Using the middle mouse button drag the clip named Bank_RightSourcefrom the Outliner into the same track as the Rise and Lower clips. Ensureyou drag into an open area on the track that the clip will fit into.

4 Position the Bank_Right clip on the track so its Frame In number matchesthe Frame Out number on the Bank_Left clip, as shown below.

You can also drag clips from the Outliner or Visor into the Trax Editor andcreate a new track for them to be placed in.

1 Drag the clip named Shift_Left1Source from the Outliner using the middlemouse button, but this time, drag to the narrow blue area above the tracksbefore releasing your middle mouse button.

240 | Chapter 6 Animation

Page 255: Autodesk Maya 2009

A new track appears in the Trax Editor and the clip is placed on the newtrack.

The narrow blue box is the summary track for the character set (in thiscase the Aircraft) The summary track represents all of the clips under acharacter, subcharacter, or group. When you import a clip onto thesummary area by dragging it from the Outliner or Visor, the Trax Editorcreates a new track for the clip.

2 Click-drag the Shift_Left clip so it lies directly below the Bank_Left clipon the track above it.

Because the Shift_Left clip is positioned directly below the Bank_Left clip,the actions will occur simultaneously when the animation is played back.

3 Using the middle mouse button drag the clip named Shift_Right1Sourcefrom the Outliner into the same track as the Shift_Left clip . Ensure youdrag into an open area on the track.

4 Position the Shift_Right clip on the track so its Frame In number matchesthe Frame Out number on the Shift_Left clip, as shown below.

5 In the front view menu, select Panels > Perspective > persp.

The view updates to display the aircraft from a perspective view.

Reusing clips within Trax | 241

Page 256: Autodesk Maya 2009

6 Dolly and track the view so you can fully see the area the aircraft willtravel within.

7 Click play on the Time Slider’s playback control to play back theanimation.

After the aircraft rises, it travels forwards as before but now it shiftssideways to the left while one wing tips downwards, and then shiftssideways to the right, while the opposite wing tips downwards.

8 Click stop on the Time Slider’s playback control.

Soloing and muting tracks

Soloing a track allows you to see a track play back in isolation from othertracks. When a track is soloed, the other tracks are disabled and do not playback. Soloing is useful when you want to review the effect a specific track willhave on a character.

To solo a track

1 In the Trax control area, click the Solo button for the track that containsthe Aircraft_Rise and Bank_Left clips.

The other tracks dim to indicate that they will be disabled when theanimation is played back.

2 Click play on the Time Slider’s playback control to play back theanimation.

242 | Chapter 6 Animation

Page 257: Autodesk Maya 2009

The aircraft rises, tilts left and right, and then lowers, without movingforward. Because the other tracks have been shut off temporarily, theaircraft’s motion is controlled by only one track.

3 Click stop on the Time Slider’s playback control.

4 Click the Solo button again to enable all the tracks.

The dimmed tracks become active again.

Muting a track disables only the selected track so it does not play back. Mutingis useful when you want to review the animation on one or more trackstogether without specific tracks being activated. You can mute one or moretracks.

To mute a track

1 In the Trax control area, click the Mute button for the track that containsthe Shift_Left and Shift_Right clips.

The muted track dims to indicate it is disabled.

2 Click play on the Time Slider’s playback control to play back theanimation.

The aircraft rises and tilts left and right as it travels forward, and thenlowers. Because the Shift_Left and Shift_Right track is temporarily muted,only the two remaining tracks affect the animation playback.

3 Click stop on the Time Slider’s playback control.

4 Unmute the track by clicking its mute button before proceeding to thenext section.

Scaling clips within Trax

You can scale single or multiple clips within the Trax Editor. Scaling a clipeither compresses or expands the animation of a clip so it occurs over a shorter

Scaling clips within Trax | 243

Page 258: Autodesk Maya 2009

or longer period of time. The resulting animation occurs faster or slower as aresult.

In the next steps, you select the four clips you imported to Trax, and scalethem together so they occur over the same time frame as the Travel_Forwardclip.

To scale multiple clips in the Trax Editor

1 In the Trax Editor, shift-click on the clips: Bank_Left, Bank_Right,Shift_Left1, and Shift_Right1.

The clip manipulator appears. The clip manipulator appears as a white boxthat encompasses the four clips with handles (triangles) on either endand a circle handle in the center. The clip manipulator allows you tomove or scale multiple clips.

2 Using the clip manipulator, click-drag the right-hand scale handle to theright until the Frame Out numbers on the Bank_Right and Shift_Rightclips match the Travel_Forward clip (Frame 299).

3 Click play on the Time Slider playback controls to play back theanimation.

When the aircraft travels, the sideways and banking motions occur overthe entire length of the Travel_Forward clip.

4 Click the stop button on the playback controls to stop the playback.

This completes the first half of the Trax lesson. In the second half of this lessonyou work with motion capture data in Trax.

244 | Chapter 6 Animation

Page 259: Autodesk Maya 2009

Open the second scene for the lesson

In this second half of this lesson, you work with a second scene file thatcontains motion capture data applied to a skeleton.

Motion capture data is produced by capturing the movement of a real humanor animal and digitizing it so it can be applied to a 3D animation character.Motion capture data contains keyframe animation. Motion capture data isuseful because it can capture the subtle nuances of motion and gesture thatmake a character’s actions appear life-like. Motion capture data cansubstantially reduce the work related to posing and keyframing your characters.

1 Open the scene file named Trax_Lesson2.ma.

This file can be found in the GettingStarted directory that you set asyour Maya project:

GettingStarted/Anim/Trax_Lesson2.ma.

The skeleton appears in the Maya scene in the standard da Vinci pose.In this pose, the character stands straight with its arms extended out toeither side. This pose is useful when you need to skin a character, retargetanimation from one skeleton to another, or set a rest pose for the skeleton.

In this half of the lesson you learn how to use the Trax Editor to workwith motion capture data by extending and redirecting the motion fora character.

Open the second scene for the lesson | 245

Page 260: Autodesk Maya 2009

NOTE If you are beginning the lesson from this point, you must first set yourpanel layouts and display settings for the Trax Editor and Outliner. Refer toTo set a panel layout for use with the Trax Editor on page 227 and To set theOutliner to display clips on page 227.

If your skeleton doesn’t appear as shown, you will need to increase thesize of the skeleton’s joints.

To resize the joints on the skeleton

1 From the main menu, select Display > Animation > Joint Size.

The Joint Display Scale window appears.

2 Set the Joint Display Scale to 10.

3 Close the Joint Display Scale window.

To preview the motion capture animation

1 Click play on the Time Slider playback controls to play back theanimation.

The skeleton is repositioned and then walks from left to right, stops, andthen sits.

2 Press stop on the Time Slider’s playback control.

Creating clips from motion capture data

When creating a clip from motion capture, it is a good practice to begin bycreating a source clip from the entire motion sequence that excludes the DaVinci pose. You can create the clip and save it to the Visor or Outliner directlywithout loading it onto a track. You can later revert back to the source clipand load it into a track if necessary.

To create a source clip of the motion capture data

1 In the Time Slider, set the Playback Start Time to 1.

246 | Chapter 6 Animation

Page 261: Autodesk Maya 2009

2 Press the Go to Start of playback range button to return to frame 1 in theTime Slider.

The skeleton is repositioned at frame 1 where the walking motion begins.

3 In the persp view, select the skeleton by click-dragging a bounding boxaround the skeleton.

The skeleton is highlighted. When the skeleton is selected, many redticks appear in the Time Slider. The red ticks represent keyframes fromthe motion capture data.

4 In the Trax Editor menu, select Create > Animation Clip > .

The Create Clip Options window appears.

5 In the Create Clip Options window, click Edit > Reset Settings to set thetool to its default settings, and then set the following:n Type WalkSit in the Name field.

n Keys - Leave Keys in Timeline: On

n Put Clip in Visor Only: On

n Click Create Clip.

The source clip appears in the Outliner named as WalkSitSource. (If youuse the Visor, the clip appears under the Character Clips tab.)

Creating clips from motion capture data | 247

Page 262: Autodesk Maya 2009

Extending the length of motion capture data

You often need more animation of a motion sequence than is provided in themotion capture data. For example, you may need to have a walk cycle that issubstantially longer than what was provided in the original file. You can usethe Trax Editor to edit the motion capture data and create clips that can becycled to make longer animation sequences. When you cycle a clip, the clip isextended in length with duplicate animation from the original clip over adefined interval of time.

If you want to cycle a clip, you must first determine areas within the animationsequence where the clip repeats seamlessly. For example, if you want to createa walk cycle from the motion capture data, you need to determine the time(frame) where the right foot is planted on the ground, and then move forwardin the Time Slider, frame by frame, until you find the next frame where theright foot is planted on the ground in exactly the same (or very similar)manner, and then create a clip. The resulting clip will contain two steps ofthe walking motion. The clip can then be cycled to produce a motion thatrepeats. How seamlessly it cycles depends on the original motion capture data.

In the steps that follow you create a walk cycle from the motion capture databy:

n Creating a clip from the walking portion of the motion capture sequencethat can be repeated.

n Cycle the clip to create a longer walk sequence.

To create a clip that can be cycled

1 In the Time Slider, drag the current time indicator to frame 6.

The skeleton updates in the scene to a walking pose where the right footis planted on the ground.

2 Drag the current time indicator forward in the Time Slider until you reachframe 45.

At frame 45, the skeleton is posed in a similar manner as it appeared atframe 6. If you use this range of frames (6 to 45), you can create a clipthat can be cycled.

3 In the persp view ensure the skeleton is selected.

4 In the Trax Editor menu, select Create > Animation Clip > .

The Create Clip Options window appears.

248 | Chapter 6 Animation

Page 263: Autodesk Maya 2009

5 In the Create Clip Options window, click Edit > Reset Settings to set thetool to its default settings, and then set the following:n Type WalkCycle in the Name field.

n Put Clip in Trax Editor and Visor: On

n Time Range: Start/End

n Start Time: 6

n End Time: 45

n Click Create Clip

Two clips appear in the Outliner named WalkCycle and WalkCycleSource.

6 In the Trax Editor, with the skeleton selected, click the Load SelectedCharacters icon.

The clip named WalkCycle appears in a new track. Loading the Characterdisplays any tracks associated with the character; in this case theWalkCycle clip.

Extending the length of motion capture data | 249

Page 264: Autodesk Maya 2009

7 In the Time Slider, set the current time indicator to frame 1.

8 Click play on the Time Slider playback controls to play back the clip.

The skeleton takes two steps and stops.

9 Press stop on the playback controls to stop the playback and reset thecurrent time indicator to frame 1.

10 In the Trax Editor, drag the clip to the left in its track until the Frame Innumber reads 1.

This sets the clip to begin at frame 1 in the Time Slider.

In the steps that follow, you cycle the clip to extend the animation so theskeleton repeats the two step motion and travels farther in the scene.

To cycle the motion for the walk clip

1 In the Trax Editor, shift-drag the lower right corner of the Walk clip tothe right until a C2.0 number appears in the new region of the clip.

When you shift-drag over the Frame Out area, the mouse cursor changesto a circular pointing arrow to indicate you are cycling the clip.

2 Double-click on the cycled clip in the C2 region.

250 | Chapter 6 Animation

Page 265: Autodesk Maya 2009

The region is highlighted to indicate you can edit the values in the region.The number will likely not be exactly 2.0. This means that the cycle willnot repeat exactly twice.

3 Type 2.0 to modify the clip so it cycles exactly twice.

4 With the clip selected in the Trax Editor, open the Attribute Editor. Openthe Channel Offsets menu and ensure that the WalkCycle clip’s root.scaleand root.translate offset attributes are set to Relative and root.rotate offsetattributes are set to Absolute.

Setting the offset attributes for the clip to Relative ensures that each cyclebegins at the position where the last sequence left off. This ensures thatthe skeleton doesn’t jump back to its start point after each cycle.

5 Click play on the Time Slider playback controls to play back the clip.

The skeleton takes six steps and then stops.

When the clip is cycled twice, the two-step walking motion occurs threetimes in total.

Extending the length of motion capture data | 251

Page 266: Autodesk Maya 2009

6 Press stop on the playback controls to stop the playback and reset thecurrent time indicator to frame 1.

Redirecting the motion within a clip

Motion capture data can be used in a variety of ways. You can redirect themotion of a character using the same motion capture data. The Redirect toolallows you to alter the original animation for a character by modifying itspath or orientation at any time during its animation. The Redirect tool doesthis by offsetting the translation and rotation attributes for the selectedcharacter.

For example, you can change the start or end point of a character’s animationby redirecting the character’s starting position or by redirecting its motionduring the animation. You can redirect a character in an existing animationsequence in the scene or a character associated with a clip within the TraxEditor.

In the steps that follow, you redirect the skeleton to turn to the right whilewalking. The workflow for the redirection is as follows:

n Scrub forward in the animation to determine a location in the clip whereyou want the character to turn. A realistic choice is where the ball of theskeleton’s right foot is planted on the ground plane because this accuratelysimulates how a real person might turn.

n Select the entire skeleton. In this example, selecting the entire skeletonselects it at the root joint (the top node of the skeleton’s hierarchy)Selecting at the root joint ensures that the entire skeleton gets redirectedwhen the redirection control is applied.

n Create and position a rotation redirection control using the Redirect tool.

n Keyframe an initial starting rotation for the redirection control.

n Rotate the redirection control so the skeleton faces the new direction oftravel.

n Keyframe the second rotation for the redirection control.

To create a redirection control for the skeleton

1 In the Time Slider, drag the current time indicator to frame 36.

252 | Chapter 6 Animation

Page 267: Autodesk Maya 2009

This frame is where the ball of the skeleton’s right foot is planted on theground plane. Use this frame as the location where the skeleton will turnto the right.

2 Select the skeleton in the scene view by click-dragging a bounding boxaround it.

3 In the main menu, select Character > Redirect > .

4 In the Character Redirection Options Window set the Redirection Typeto Rotation only and then click the Redirect button.

A Rotation redirection control appears between the hips of the skeleton,where the root joint for the skeleton’s hierarchy is.

You want the skeleton to pivot (rotate) while standing on the ball of its rightfoot. To do this, you need to move the redirection control to the ball of theright foot of the skeleton.

To move the redirection control to the ball of the foot

1 From the Toolbox, select the Move tool.

The Move tool manipulator appears on the redirect manipulator.

Redirecting the motion within a clip | 253

Page 268: Autodesk Maya 2009

2 Press the v key and click-drag the redirection control until it is locatedon the ball of the right foot as shown below.

Pressing the v key while using the Move Tool momentarily enables theSnap to Points tool.

The redirection control is now positioned to redirect the skeleton’s walkingmotion. To complete the redirection process, you need to set keyframes whilesetting the redirection control so the redirection of the skeleton can occur.

To keyframe the redirection control

1 With the redirection control selected, press s to set a keyframe.

A red tick appears in the Time Slider at frame 36 indicating the keyframe.Setting a keyframe establishes the starting rotation for the redirectionrotation of the skeleton.

2 In the Time Slider, drag the current time indicator to frame 57.

The skeleton updates to a position where its left foot is planted on theground plane. This is the location where you want the skeleton to berotated to its new direction of travel.

3 In the Channel Box, with the redirection control still selected, set theRotate Y attribute to -45.

4 Rotate the redirection control approximately -45 degrees about the Y axisuntil the skeleton is facing in the direction shown below. (You can usethe Channel Box values as a guide.)

254 | Chapter 6 Animation

Page 269: Autodesk Maya 2009

5 With the redirection control still selected, press s to set a keyframe.

Setting a second keyframe establishes when the redirection rotation forthe skeleton ends.

6 Set the current time indicator to frame 1.

7 Click anywhere in the perspective view to deselect any items in the scene.

8 Click play on the Time Slider playback controls to play back the clip.

The skeleton takes two steps and then turns to its right after it reachesthe redirection control, and continues walking in the new direction oftravel and stops when it completes its walk cycle.

9 Press stop on the playback controls to stop the playback and reset thecurrent time indicator to frame 1.

Redirecting the motion within a clip | 255

Page 270: Autodesk Maya 2009

NOTE When redirecting motion within Trax, you may want to considercreating a clip that contains the redirection animation to make it possible toreposition the redirect animation as a clip.

Now that you’ve redirected the character to a different direction of travelduring the walk cycle, you can reuse some of the motion from the originalsource clip you created earlier in the lesson and saved to the Outliner/Visor.

You insert the source clip from the clip Library in Trax. The clip Library keepstrack of the source clips and poses for the current character set. When thesource clip is inserted from the Library, a copy of the source clip is created ina new track.

Once you import the source clip and make a copy of it, you trim the duplicateclip to make the character stop walking and then sit in a different locationthan the original motion capture.

To insert the source clip

1 In the Trax Editor, select Library > Insert Clip. Choose WalkSitSourcefrom the drop-down list.

A duplicate copy of the WalkSitSource clip is created, and inserted ontoa new track.

2 In the Trax Editor, select View > Frame All.

The track view area updates to display all clips in their entirety.

3 In the Trax control area, click the Mute button for the track that containsthe WalkCycle clip.

The muted track dims to indicate it is inactive. When the walk cycle trackis muted, the character updates to appear in the Da Vinci pose at theorigin based on the original source clip.

4 Drag the current time indicator to frame 98.

The skeleton updates in the view and the redirection that was appliedalso occurs. Remember that the redirection occurs for the character, andnot the clip.

5 Click on the WalkSit clip in the track to select it.

256 | Chapter 6 Animation

Page 271: Autodesk Maya 2009

6 In the Trax tool bar, click the Trim Clip Before Current Time icon to trimthe section of the clip that occurs before frame 98.

The WalkSit clip is trimmed and the portion of the clip before frame 98is discarded.

7 Click the Mute button again for the track containing the WalkCycle clipto reactivate the track.

The dimmed track becomes active again. The skeleton however hasupdated to an incorrect pose near its previous position. This occursbecause the two active clips overlap, and the character is receivingconflicting positional information as a result. (That is, double translationand rotation information.)

8 Drag the WalkSit clip to the right in its track until its Frame In numbermatches the Frame Out for the WalkCycle clip.

The pose for the skeleton is updated to the correct position.

9 Reset the current time indicator to frame 1.

10 Click play on the Time Slider playback controls to play back theanimation.

The skeleton takes two steps and then turns to its right after it reachesthe redirection control, and continues walking in the new direction oftravel, stops, and then sits.

Redirecting the motion within a clip | 257

Page 272: Autodesk Maya 2009

11 Press stop on the playback controls to stop the playback and reset thecurrent time indicator to frame 1.

A small jump cut occurs during the transition between the two clips. The jumpcut occurs because the poses for the skeleton do not match from the end ofthe first clip and the beginning of the second. In your own work, try toanticipate how motion will blend between clips when working in Trax. Youcan correct the jump cut in this particular example by extending the WalkCycleclip.

To extend the WalkCycle clip to correct the jump cut

1 In the Trax Editor, double-click on the WalkCycle clip in the C2 region.

The number becomes highlighted indicating you can edit the number.

2 Type 2.2 to edit the clip so it cycles 2.2 times.

The new Frame Out number for the WalkCycle clip becomes 126. It nowoverlaps in time with the WalkSit clip.

3 Drag the WalkSit clip to the right until its Frame In number becomes126.

258 | Chapter 6 Animation

Page 273: Autodesk Maya 2009

4 Click play on the Time Slider’s playback control to play back theanimation.

The jump cut is less noticeable than before.

5 Press stop on the Time Slider’s playback control.

You have completed this lesson. Before leaving this lesson, reset the jointsize back to its default setting.

To reset the joint size

1 From the main menu, select Display > Animation.

The Joint Display Scale window appears.

2 Set the Joint Display Scale to 1.

3 Close the Joint Display Scale window.

Beyond the lesson

In this lesson, you learned some fundamental techniques for using thenonlinear animation tools in Trax. You learned how to:

n Key animation sequences for use as nonlinear clips in Trax.Clips can contain minimal or many animated attributes. You can createclips from existing animation or key animation specifically for use in clips.You should consider what attributes you need represented in a clip whenyou key the animation before you decide to use nonlinear animation inyour work. In this way, a clip can be used to control a specific attribute.

n Create clips from your animation sequences for use in the Trax Editor.

Beyond the lesson | 259

Page 274: Autodesk Maya 2009

When you create a clip, a character set is created if one does not alreadyexist. You can load and work with multiple character sets in the Trax Editor.To select different character sets when working in Trax you can use theSelect Current Character drop-down menu. Clips can also be arranged,scaled, and moved as groups. For more information see Move clips andTrack view area in the Maya Help.

n Use the Trax editor to position, re-arrange, cycle, and scale clips in orderto create and modify animation sequences in the scene.If a character animates or scales in a manner you had not expected whenworking in Trax, you may want to check to see if the clips overlap or arearranged in a manner that doesn’t provide the expected results. In addition,a clip containing motion that is intended to be appended to another clip’smotion must have its Offset attribute set to Relative, and Absolute Rotationsset to On (in most instances). There are many other tasks you can performwith clips in the Trax Editor that are beyond the scope of this lesson. Formore information see Nonlinear animation components in Trax in theMaya Help.

n Use the Trax Editor to work with motion capture data.The Trax Editor is useful when working with motion capture data. Sincemotion capture data usually contains a lot of keyframe information, theTrax Editor can be useful for creating, modify, and extending the motiondata provided. Cycling and redirecting motion are two methods that canbe used to get more from your motion capture data. For more informationsee the section on Motion Capture Animation in the Maya Help.

n Redirect the motion for a character using the Redirect tool.You can use redirection controls to redirect any type of motion in Maya(Keyframe, motion capture, expressions, dynamics, and so on). For moreinformation and additional examples on redirection see Redirect the motionof an animated character in the Maya Help.

n Trim clips in the Trax Editor.You can trim a clip either before or after the current time indicatordiscarding the remainder of the clip in the process. You can also split aclip into two parts. The original source clip is not affected. For moreinformation see Split clips in the Maya Help.

Blending clips

You can blend the animation between clips. Blends allow you to create smoothtransitions and mixes between different motions. A blend can be appliedbetween any two clips that overlap entirely, partially, or not at all. The best

260 | Chapter 6 Animation

Page 275: Autodesk Maya 2009

results are obtained when blending between similar motions. In somesituations, a blend can be used to correct jump cuts. For more informationsee Create and edit blends in the Maya Help.

Key into clip

You can set keyframes to alter the animation within a clip. This process iscalled Keying into a clip. When you key into a clip, keyframes are placed atthe current time on all the animation curves in the selected clip. For moreinformation see Key into a clip in the Maya Help.

Time Warps

Time Warps let you change the timing of a clip without modifying the clip'sanimation curves. You modify the Time Warp by editing the animation curvethat controls the warp. Time Warps can also be used to reverse the animationin a clip. For more information see Create and edit time warps in the MayaHelp.

Visor and Outliner

Both the Visor and Outliner can be used to access clips. The Visor provides agraphical interface to access other resources (clips, poses, shaders, textures,brushes etc.) in your scene. The Outliner displays clips in a textual manner,and is a bit more compact.

Audio clips

You can display and play multiple audio files in Trax allowing you tosynchronize your motion clips to specific audio events (sound effects, musicalnotes, drum beats etc.) in the audio file. Once you import an audio file intoTrax, you can then move and rename the audio clip. For more informationsee Work with audio in the Maya Help.

Beyond the lesson | 261

Page 276: Autodesk Maya 2009

Lesson 5: Inverse kinematics

Introduction

Inverse Kinematics (IK) allows you to efficiently pose your models andcharacters for animation. You pose the skeleton by positioning IK handles,usually located at the end of an IK joint chain (for example at the hand). Therotations for the other joints are calculated automatically by an IK solver. AnIK solver calculates the rotations of each joint back up the hierarchy of thejoint chain based on the position of the IK handle. See Creating a skeletonhierarchy on page 267 for more information on skeletons and joints.

By contrast, Forward Kinematics (FK) requires you to rotate each joint in turnuntil you have the desired pose for a keyframe. This can be a tedious processwhen posing a complex skeleton. When using Inverse Kinematics, it’s fasterto pose a character because the joint rotations further up the hierarchy arecalculated automatically based on the placement of the IK Handle. Using bothFK and IK techniques on the same skeleton is called FK/IK blending.

IK is obviously useful for posing animated characters that have a skeleton(two-legged, four-legged etc.) and has others applications, such as posingskeletons within mechanical-like models.

The goal of this lesson is to animate a mechanical arm so that it extends intoa position over a cargo box, picks up and moves the cargo box to anotherlocation, and then sets it down.

262 | Chapter 6 Animation

Page 277: Autodesk Maya 2009

As you work through the lesson, you’ll learn about many of the basic featuresrelated to skeleton hierarchies, IK, and parent constraints. Some initial setupof the model and IK is required so that it can be posed and keyframed toprovide a convincing animation.

In this lesson you learn how to:

n Create and use hierarchies to define logical relationships betweenanimatable objects.

n Combine the components of a 3D mechanical arm model into ahierarchical grouping.

n Construct a skeleton for use with IK.

n Combine the skeleton with the mechanical arm model by parenting thecomponents into a hierarchy.

n Create an IK system to allow the skeleton hierarchy to be posed.

n Create a control object to manipulate the IK system.

n Use constraints to control the position and orientation of componentswithin the IK system.

n Limit the range of movement on the IK system.

n Pose and set keyframes for the IK system.

n Animate an object by constraining its motion to two or more objects.

Open the scene for the lesson

In this lesson, you work with a scene we created for your use. In the first stepsof this lesson, you open the scene and view the various elements that havebeen created for your use.

1 Make sure you’ve done the steps in Preparing for the lessons on page 185.

2 Open the scene file named IK_MechArm.ma.

This file can be found in the GettingStarted directory that you set asyour Maya project:

GettingStarted/Anim/IK_MechArm.ma

Open the scene for the lesson | 263

Page 278: Autodesk Maya 2009

The scene contains a model of a mechanical arm and a cargo box to bemoved by the arm. The components of the mechanical arm include:

n A cargo magnet cup on the end

n Three arm segments

n A base for the arm to swivel about

n A four-legged base for the assembly

To work with this model using IK you must create a hierarchy for it.

Understanding hierarchies

Inverse Kinematics relies on hierarchical relationships between the componentsof a model and the IK system to pose and animate the components. Beforeusing Inverse Kinematics it is important to understand hierarchies in Maya.

A hierarchy is composed of a series of nodes that are combined for somepurposeful relationship. Individual nodes may represent the surfaces of amodel, a network of textures that describe a shading material, or series ofjoints in a skeleton. Hierarchies are structured in a top-down manner, withone node at the top (the parent node or root node) and other nodes (child nodesor leaf nodes) attached and interconnected beneath the top node.

264 | Chapter 6 Animation

Page 279: Autodesk Maya 2009

Selecting the parent node at the top of the hierarchy also selects the itemscontained in the hierarchy below. Selecting a child node lower in the hierarchyselects any child nodes that are lower in the hierarchy.

Hierarchies allow you to create complex structures with relationships betweencomponents. For example, when you animate a hierarchical model, you simplyneed to select and move the parent node of the hierarchy and the rest of themodel (child nodes) also moves.

Regardless of whether you decide to animate the mechanical arm using FK orIK, or a combination of both methods on the same model, the best approachinvolves making the mechanical arm model into a hierarchical structure.

Creating a hierarchy for the mechanical arm ensures that:

n Components of the hierarchy can be rotated as if they were one unit. Acommon pivot point is created at the parent node level. This allows theseparate components to rotate as one unit based on their membership inthe hierarchy. For example, if the mechanical arm’s base (parent node) isrotated, anything lower down the hierarchy, for example, the mechanicalarm which is constructed of child nodes, will also rotate because of itsmembership and position in the hierarchy.

n When a particular segment of the model is posed and keyframed, thecomponents that are lower in the hierarchy are also posed and keyframed.

Viewing hierarchies using the Hypergraph

In the following steps, you use the Hypergraph to view the hierarchy for themechanical arm. The Hypergraph is a scene management editor that presentsa graphical view of the scene hierarchy. It allows you to more easily create,understand, and manage the hierarchy of objects and nodes in your scene.

To view hierarchies using the Hypergraph

1 From the perspective view’s panel menu, select Panels > Layouts > TwoPanes Stacked.

The workspace displays two panels stacked on top of each other with anidentical perspective view of the scene.

2 In the lower panel, select Panels > Hypergraph Panel > HypergraphHierarchy.

The lower panel displays the Hypergraph.

Viewing hierarchies using the Hypergraph | 265

Page 280: Autodesk Maya 2009

3 In the Hypergraph menu, select Graph > Scene Hierarchy.

If the menu item appears dimmed, it indicates that the Hypergraph isalready displaying the scene hierarchy

The Hypergraph displays with a black background by default. In orderto see the relationships between the items, the background has beenmodified for the images in this lesson.

4 In the Hypergraph menu, select View > Frame All to see all thecomponents of your scene.

The boxes represent the nodes for the various items in the scene. Some itemsin the scene have already been parented into a hierarchy. This is indicated bythe lines connecting some of the nodes. Selecting the nodes in the Hypergraphalso selects the item in the scene view.

To select an item using the Hypergraph

1 In the Hypergraph, click each of the separate items in the hierarchy atthe parent level to select them. At the same time, observe which objectsbecome highlighted on the model in the perspective view.

266 | Chapter 6 Animation

Page 281: Autodesk Maya 2009

Hierarchies combine the various objects into discrete components for themechanical arm, that is, the base, lower arm, middle arm, upper arm, etc. Ifyou select and rotate any of the parent nodes in the hierarchies, none of theother arm components follow because they are not combined into one unifiedhierarchy.

Creating a skeleton hierarchy

To link the various components of the mechanical arm into a hierarchy thatcan be posed, you need to create a skeleton. A skeleton is a hierarchy of jointsthat are connected together with bones.

In the scene, a joint represents a special type of node that gets created in askeleton hierarchy. A joint acts as the parent node for any other joints thatoccur in the hierarchy below it. Each joint has a rotational pivot pointassociated with it. A bone is the visual representation used in the scene viewto connect the joints and help visualize the joint chain.

A skeleton is similar to a skeleton in the real world in that it acts as theunderlying structure for the surfaces to be attached. While you can view theskeleton with its bones and joints in the scene view, it does not appear in yourrendered images. Its purpose is to assist you in setting up and posing yourmodels and characters and to visualize the motion you want to achieve.

Creating a skeleton hierarchy | 267

Page 282: Autodesk Maya 2009

Skeletons are integral to the animation of any character or hierarchical model.Examples of characters that use skeletons are two and four legged animals.Skeletons are also useful for animating other organic components such as thetail of an animal, a tentacle of an octopus, or a snake.

In the following steps, you create a simple skeleton consisting of four jointsthat you combine with the mechanical arm model into a skeleton hierarchy,allowing you to pose and animate the model.

To create a skeleton for the mechanical arm

1 In the perspective view menu, select Panels > Orthographic > side.

The view updates to display the side view.

You need to view the components of the mechanical arm fully in theside view so you can draw the joints for the skeleton.

2 Resize the side view to a larger size by dragging the border between theside and Hypergraph panel views downwards.

3 In the side view menu, select Shading > Wireframe (Hotkey 4).

268 | Chapter 6 Animation

Page 283: Autodesk Maya 2009

4 From the main menu, select Skeleton > Joint Tool > .

The Tool Settings window for the Joint Tool appears. The Joint Tool isused to create the joints and bones for a skeleton.

5 In the Joint Tool settings window, do the following:n Click Reset Tool to set the tool to its default settings.

n Hide the Tool Settings window by clicking the right-pointing arrowthat is located in the upper left corner of the Tool Settings window.

6 In the side view, starting from the base of the mechanical arm, do thefollowing:n Click in the center of each pivot pin on the mechanical arm to place

four joints as shown in the image below.

Try to click as close to the center of each pivot pin as you can, as therotation of the joints on the model will be based on the location of thejoints on the skeleton. As you place the joints, a bone appears, connectingeach joint. (Because the model lies along the YZ plane, the joints arecreated close to the center of each corresponding joint on the mechanicalarm model.)

n After you place the fourth joint, press Enter to indicate that the lastjoint has been placed.

Creating a skeleton hierarchy | 269

Page 284: Autodesk Maya 2009

7 In the Hypergraph, dolly the view to see the skeleton node hierarchy youjust created. (It appears at the right side of the view.)

8 In the Hypergraph, select the joint1 node.

The entire skeleton becomes selected. Any rotations on this node alsoaffect anything lower down the hierarchy.

9 Select joint2 (You can also press the down arrow on your keyboard toselect further down the hierarchy).

The skeleton is selected from joint2 downwards in the hierarchy. Anyrotations that you make on this node affect only joint2 and nodes belowjoint2.

270 | Chapter 6 Animation

Page 285: Autodesk Maya 2009

Once a skeletal hierarchy is created, the various surface components can beadded to the hierarchy.

Parenting a model into a skeleton hierarchy

Parenting is the term used when placing a node beneath another in a hierarchyso it becomes the child of the node above it (its parent) in the hierarchy.

In the following steps, you add the surfaces of the mechanical arm model intothe skeleton hierarchy. This process links the models’ surfaces to the skeletonhierarchy making it possible to pose and animate the model like a realmechanical arm. Using the Hypergraph to select the nodes allows you to bettervisualize the process and the hierarchical relationships that result.

NOTE The following parenting procedure works well for the mechanical arm (noorganic bending or deformation occurs) and provides one technique for addingmodeled objects to a skeletal hierarchy.

A more common technique for combining a character model into a skeletonhierarchy is referred to as skinning or binding. The Bind Skin tool combines thesurface components and joints together into a hierarchy and also takes intoaccount any deformations that may occur when a character bends or flexes(knees, waist, neck, elbows etc.). Maya provides a few methods for skinning.For more information see Skeletons and skinning in the Maya Help. For atutorial on skinning see the Smooth Skinning lesson in the Character Setupchapter in this guide.

To parent the mechanical arm into the skeleton

1 In the Hypergraph menu, select View > Frame All.

The Hypergraph displays all the nodes for the scene.

2 In the Hypergraph, select the node named ArmEnd and then shift-selectthe node named joint4.

The order of selection is important. You want to select the child nodefirst, and then shift-select the item that will become the parent nodesecond.

3 In the main menu, select Edit > Parent (Hotkey p).

In the Hypergraph, joint4 is now the parent node for the Arm_end nodein the skeleton hierarchy.

Parenting a model into a skeleton hierarchy | 271

Page 286: Autodesk Maya 2009

4 Repeat the parenting process for the following items:n pin3 is parented under joint3

n pin2 is parented under joint2

n pin1 is parented under joint1

Your new hierarchy should appear as shown in the diagram below.

In the next steps, SwivelBase becomes the parent node for the newhierarchy so that the entire arm assembly swivels about the center of thebase component.

5 In the Hypergraph, select the node named joint1 and then shift-selectthe node named SwivelBase.

6 In the main menu, select Edit > Parent (Hotkey p).

Change the panel display to a layout that allows you to view the hierarchyin the Hypergraph.

7 In the side view menu, select Panels > Layouts > Two panes side by side.

The panels display in a side by side configuration.

8 Dolly the Hypergraph view as required to view the new hierarchy.

272 | Chapter 6 Animation

Page 287: Autodesk Maya 2009

9 In the Hypergraph, select the node named Swivel_base.

In the side view, observe that both the mechanical arm model and theskeleton are selected. Swivel_base is the parent or root node for thehierarchy. If you rotate SwivelBase, everything else below that node (theentire arm with skeleton) rotates.

10 Select the node named joint3.

Observe that the last two components of the mechanical arm are selected.If you rotate joint3, only the components below that node in thehierarchy will be affected.

11 Select the node named pin2.

Observe that only one isolated segment of the model is selected. No othercomponents or joints are selected when pin2 node is selected. If yourotate the model at pin2, only the component at pin2 will rotate inisolation from the rest of the hierarchy because it is located lower in thehierarchy.

It is now possible to select and rotate the skeleton joints to pose the mechanicalarm as a unit, and then set keyframes to animate it. Posing a character usingjoint rotations is referred to as Forward Kinematics (FK). FK allows for precisecontrol when setting up a pose, but it can be a time consuming process toselect and rotate each joint into the desired position.

When an animation is more focused on the goal of placing the end joint ina hierarchy in a particular position, (for example, a hand or a foot), it is more

Parenting a model into a skeleton hierarchy | 273

Page 288: Autodesk Maya 2009

efficient to use Inverse Kinematics to pose the skeleton. For more informationon forward and inverse kinematics, see Posing skeletons in the Maya Help.

NOTE It’s not a simple matter to state that one technique or another is the onlyapproach to achieving a desired result when animating in Maya. You must decidewhether a particular technique works for a particular scenario based on the optionsit provides. A combination of animation techniques can be creatively used in avariety of ways.

Applying IK to a skeleton hierarchy

IK allows you to control the joint rotations in a skeleton using an IK handle.You pose the skeleton by positioning the IK handle (usually located at theend extremity of the skeleton) and having the rotations for the other jointscalculated automatically by the IK solver. In the steps that follow, you applyIK to the skeletal hierarchy.

To create an IK handle for the mechanical arm

1 From the main menu, select Skeleton > IK Handle Tool > .

The IK Handle Tool Settings window for the Joint Tool appears. Whenthe mouse pointer is in the orthographic view its appearance changes tothe tool's cross hair cursor.

2 In the IK Handle Tool Settings window, do the following:n Click Reset Tool to set the tool to its default settings.

n Set the IK Handle Settings: Current Solver - ikSCsolver.

274 | Chapter 6 Animation

Page 289: Autodesk Maya 2009

n Hide the Tool Settings window by clicking the right-pointing arrowthat is located in the upper left corner of the Tool Settings window.

The ikSCsolver setting selects the IK Single Chain Solver. This solverensures that the joints in the skeleton will lie along a single plane. Thissolver is well suited for the mechanical arm, because the arm doesn’tneed to twist, unlike a real arm.

3 Working in the side view, starting from the base of the mechanical arm,do the following:n Click on the skeleton joint at the base of the mechanical arm.

n Click on the skeleton joint at the tip of the mechanical arm. (The IKTool is designed to attach to the joints closest to your selection point.)

In the side view, the IK handle is drawn as a line from the start and endjoints of the IK chain.

4 In the Hypergraph menu, select View > Frame All.

In the Hypergraph, two new nodes appear in the hierarchy that representthe IK chain: an IK Handle node and an end effector node.

Applying IK to a skeleton hierarchy | 275

Page 290: Autodesk Maya 2009

5 In the Hypergraph, select the node named ikHandle1.

The IK Handle (in combination with the end effector) is used by the IKsolver to calculate the rotation of the joints in the IK chain. By default,the IK Handle is located at the last joint of the IK chain in the scene view.

6 Select the Move Tool from the Toolbox, and drag the Move Tool’s Z axismanipulator (blue arrow) to reposition the mechanical arm.

When you drag the manipulator, the skeleton and mechanical arm modelare repositioned.

7 Reset the mechanical arm to its previous position by selecting Edit >Undo, Redo, Repeat until the mechanical arm is positioned into itsprevious orientation.

NOTE When using the Undo feature, do not undo so many times youinadvertently undo the IK handle you’ve just created.

The next steps describe how to manipulate the IK Handle using a controlobject.

Creating a control object for an IK system

Using the IK Handle to pose an IK chain is generally not a good practice. TheIK Handle can be challenging to select in the scene view, especially when it’sgrouped into a hierarchy that includes a skeleton and other surfacecomponents. A better practice is to create a control object.

276 | Chapter 6 Animation

Page 291: Autodesk Maya 2009

You create a control object to select and manipulate an IK system instead ofdirectly using the IK Handle. You can create a control object with a curve ora locator, which are often used because they don’t appear in the renderedimage.

The control object controls the movement of the IK Handle using a constraint.You can constrain the position, orientation, or scale of an object to otherobjects using constraints.

To create a control object:

n Create and position the control object in the scene view.

n Name the node for the control object in the Hypergraph.

n Freeze transformations for the control object.

n Label the control object in the scene view.

n Constrain the IK Handle to the control object.

To create a control object using a locator

1 From the main menu, select Create > Locator.

A three-dimensional cross is created at the origin in the scene view.

2 Select the Move Tool from the Toolbox.

3 In the side view, reposition the locator slightly above and in front of theend of the mechanical arm as shown in the image below.

To easily identify the locator as a control object in the Hypergraph, renamethe locator.

Creating a control object for an IK system | 277

Page 292: Autodesk Maya 2009

To rename the control object using the Hypergraph

1 In the Hypergraph, right-click the node named locator1. Choose Renamefrom the pop-up menu that appears.

The locator1 name is highlighted on the node.

2 Type the name ArmControl and press Enter to save the name for thelocator.

Before you constrain the IK handle to the control object, you need to freezethe transformations for the control object. Freeze Transformations zeros thetransformations for an object without changing the position of the object.This is another good practice; If it becomes necessary to reset the arm to itsdefault position, you can set the transformation on the control object to zero,and the arm will return to this default pose.

To freeze the transformations for the control object

1 In the Hypergraph, select the node named ArmControl.

The control object is selected in the scene view.

2 In the main menu, select Modify > Reset Transformations, Freeze

Transformations > .

3 In the Freeze Transformation Options window do the following:n Select Edit > Reset Settings to set the tool to its default settings.

n Click the Freeze Transform button.

The transformations for ArmControl are set to zero. From this pointonwards, you can reset its position to this location by zeroing itstranslations in the Channel Box.

278 | Chapter 6 Animation

Page 293: Autodesk Maya 2009

To easily identify the locator as the control object in the scene view, label thecontrol object using an annotation. An annotation is a text label that can beset to point at the labeled item. Annotations are useful because they alwaysface the viewer, regardless of the orientation of the model in the scene view.

To label the control object in the scene view

1 In the Hypergraph, select the ArmControl node.

2 In the main menu, select Create > Annotation.

A input window appears.

3 Type ArmControl and click OK.

In the scene view, the word ArmControl appears near the locator/controlobject. In the Hypergraph, two new nodes appear in a hierarchy beneathArmControl.

4 With the annotation still selected, select the Move Tool.

5 In the side view, drag only the annotation so it appears slightly offsetfrom the locator object as shown below.

The annotation displays in any scene view so you can easily identify thecontrol object for selection.

Creating a control object for an IK system | 279

Page 294: Autodesk Maya 2009

To simplify the display of the Arm Control node

1 In the Hypergraph, right-click the ArmControl node. Choose Collapsefrom the pop-up menu. (You can also double-click a node to collapse orexpand the hierarchy below it.)

The ArmControl node appears as a single node instead of the previousthree node hierarchy. The small arrowhead on the lower left-hand cornerof the node indicates that the node is collapsed.

The control object must be linked to the IK Handle to control the IK Handle.

Constraining an IK system

You can constrain the IK Handle to the control object (ArmControl) using apoint constraint. A point constraint allows the transformation attributes of oneobject to be controlled by the transformations of another object. For example,you select and position ArmControl without having to touch the IK Handle.You also set the constraint so ArmControl maintains the current distance(offset) from the IK Handle. The offset ensures that the constrained IK handledoesn’t move to the same position as the control object.

To constrain the IK Handle to the control object

1 In the Hypergraph, select the ArmControl node and then shift select theikHandle1 node.

The order of selection when applying a constraint is important: you mustselect the constraining object first, and the item to be constrained second.

2 In the main menu, select Constrain > Point > .

The Point Constraint Options window appears.

3 In the Point Constraint Options window, do the following:n Select Edit > Reset Settings to set the tool to its default settings.

n Turn on the Maintain Offset setting.

n Click the Add button.

280 | Chapter 6 Animation

Page 295: Autodesk Maya 2009

The IK handle is constrained to the control object. In the Hypergraph, aconstraint node is created beneath the ikHandle1 node.

4 In the Hypergraph, select only the ArmControl node.

5 In the Toolbox, select the Move Tool.

6 In the side view, drag the manipulator to reposition the control object.(Experiment with a few different positions in the side view only.)

When you drag the manipulator, the control object moves, which in turnmoves the IKHandle. Because the IK handle controls the skeleton andthe mechanical arm model, they also move. The offset between the controlobject and the IK Handle is maintained.

The Cargo Magnet does not continuously point downwards when rotated. Itsorientation is based on the rotation it had in its original position.

The mechanical arm will be easier to pose if you set Cargo Magnet to beoriented downwards towards the floor of the scene regardless of the orientationof the other components of the arm.

Constraining an IK system | 281

Page 296: Autodesk Maya 2009

You make CargoMagnet point downwards using an orient constraint. An orientconstraint constrains the orientation (rotation) of the X, Y, and Z axes of oneobject to match those of the constraining (target) object.

In the next steps, you reset the position of the mechanical arm to its defaultposition, and then apply an orient constraint to the last joint in the IK systemso that its orientation matches the control object. The effect is thatCargoMagnet points downwards regardless of any other movement in thescene.

To set the IK system to its default position

1 In the Hypergraph, select the ArmControl node.

2 Open the Channel Box by clicking the Show/Hide Channel Box icon.

3 In the Channel Box, set the X, Y, and Z transformations for ArmControlto 0.

Zeroing the transformations on ArmControl resets the mechanical armto its home position because of the freeze transformations step youperformed in the previous section.

4 Close the Channel Box by clicking the Show/Hide Channel Box icon.

To apply an orient constraint for the IK system

1 In the Hypergraph menu, select View > Frame All.

The Hypergraph displays all the nodes in the scene.

282 | Chapter 6 Animation

Page 297: Autodesk Maya 2009

2 In the Hypergraph, select ArmControl and then shift-select the nodenamed joint4. (You may need to dolly and track the Hypergraph view toview these nodes.)

3 In the Main Menu bar, select Constrain > Orient > .

4 In the Orient Constraint Options window, do the following:n Select Edit > Reset Settings to set the tool to the default settings.

n Click the Add button.

Joint4 is constrained to have the same orientation as the control object.In the Hypergraph, the constraint node is created below the joint4 nodein the hierarchy.

5 With only the ArmControl node selected, use the Move Tool to repositionArmControl in the side view.

CargoMagnet maintains an orientation facing the floor of the sceneregardless of how the mechanical arm is positioned in the side view.

In the next section, you learn how to limit the range of movement for the IKsystem.

Constraining an IK system | 283

Page 298: Autodesk Maya 2009

Limiting the range of motion of an IK system

It’s possible to move ArmControl so that the mechanical arm fully extendsto a straight position or orients itself to other positions that you don’tnecessarily want.

You can limit the range of motion of the arm to ensure that the IK systemposes in a predictable manner. In the following section, you limit the motionfor the IK system as follows:

n Lock the translation of the control object (ArmControl) so that it can onlymove in Y and Z. By locking the X channel so it cannot be selected ormodified, the arm will not be able to move from side to side.

n Lock the rotations on the swiveling base for the arm so it only rotatesabout its Y axis, and not about its X or Z axes.

n Limit the translations for the Arm Control so the mechanical arm cannotfully extend to a straightened position.

To lock the Translate X channel for ArmControl

1 In the Hypergraph, select the ArmControl node.

2 Open the Channel Box to view the transform channels for ArmControl.

3 Set all Translate or Rotate channels to 0, if they are not already.

4 In the Channel Box, select the Translate X channel by clicking on itsname.

5 Right click on the word Translate X.

A drop-down menu appears.

6 From the drop-down menu, choose Lock Selected.

284 | Chapter 6 Animation

Page 299: Autodesk Maya 2009

The numerical field for Translate X is dimmed indicating that the channelis locked. If you try to move ArmControl in X, it will not be possibleunless you unlock the Translate X channel.

To lock the Rotate X and Z channels for SwivelBase

1 In the Hypergraph, select only the SwivelBase node.

2 Open the Channel Box to view the rotation channels for SwivelBase.

3 Set all Translate or Rotate channels to 0, if they are not already.

4 In the Channel Box, select the Rotate X and Rotate Z channels bycontrol-clicking on their names.

5 Right click on either of the selected names.

A drop-down menu appears.

6 From the drop-down menu, select Lock Selected.

To confirm that the Rotate X & Z channels are locked

1 In the Hypergraph, ensure only the SwivelBase node is selected.

2 In the view, select Panels > Orthographic > top.

3 In the view, select Shading > Smooth Shade All.

4 Dolly the top view so you can fully view the mechanical arm as shownbelow.

5 Using the ChannelBox, rotate SwivelBase by typing 45 in the Rotate Ychannel and pressing Enter.

Limiting the range of motion of an IK system | 285

Page 300: Autodesk Maya 2009

SwivelBase rotates in the view but the mechanical arm does not rotate.You first might think something is wrong because SwivelBase and all ofthe arm’s skeletons and surfaces are parented into the same hierarchy.

NOTE You may sometimes discover that something doesn’t work in themanner you originally anticipated when setting up an IK system. When thisoccurs, it’s useful to stop and diagnose why something is working the wayit is (or not working the way it should). In that way you can retrace youractions to determine where the problem resides.

ArmControl and IK Handle are not parented into the SwivelBase hierarchy.Because ArmControl and IK Handle control the movements of the mechanicalarm, they must be parented into the SwivelBase hierarchy in order for the armto rotate when SwivelBase is rotated.

To parent the IK Handle into the skeleton hierarchy

1 In the Hypergraph, select the SwivelBase node.

2 In the ChannelBox, reset the Rotate Y channel for SwivelBase to 0.

Setting any previous transformations to zero is necessary before parentingthe IK Handle beneath SwivelBase in the hierarchy.

3 Unselect the SwivelBase node before performing the following steps.

4 In the Hypergraph menu, select View > Frame All.

The Hypergraph displays all the nodes for the scene.

5 In the Hypergraph, shift-select the nodes named ikHandle1, ArmControl,and SwivelBase.

286 | Chapter 6 Animation

Page 301: Autodesk Maya 2009

The order of selection is important. You want to shift-select the itemsthat will be the child nodes first, and then shift-select the item that willbe the parent node last.

6 In the main menu, select Edit > Parent (Hotkey p).

In the Hypergraph, IKHandle and ArmControl are now child nodes forthe SwivelBase node in the skeleton hierarchy.

7 In the Hypergraph, select only SwivelBase.

8 Using the ChannelBox, set Rotate Y for SwivelBase to 45.

When SwivelBase is rotated, the mechanical arm rotates because of itsrelationship within the hierarchy.

9 Reset the Rotate Y value for SwivelBase back to 0.

Finally, you want to limit how far Arm Control can translate away from thebase of the model so the arm does not extend to a fully straightened position.

To determine the settings for the translation limits you need to examine theposition of the mechanical arm in various positions while simultaneouslyviewing the translation values in the ChannelBox.

Limiting the range of motion of an IK system | 287

Page 302: Autodesk Maya 2009

To determine translation limits for the Arm Control

1 In the Hypergraph, select ArmControl.

2 Ensure the Channel Box is open so you can view the translate channelsfor ArmControl.

3 In the view, select Panels > Orthographic > side.

4 Dolly the side view so you can fully view the mechanical arm.

5 Select the Move Tool.

6 In the side view, press the middle mouse button and drag the mousediagonally until the mechanical arm is fully extended as shown below.

7 In the Channel Box, observe the number that displays in the TranslateY and Z channels.

When the arm is diagonally articulated above the cargo box, it is almostfully extended when the translation values are roughly as follows:

n Translate Y: 7.5

n Translate Z: 1

8 In the side view, press the middle mouse button and drag the mouse ina diagonally until the mechanical arm is almost fully compressed asshown below.

288 | Chapter 6 Animation

Page 303: Autodesk Maya 2009

9 In the Channel Box, observe the numbers that display in the TranslateY and Z channels.

When the arm is articulated to a compressed pose, the translation valuesare roughly as follows:

n Translate Y: -13

n Translate Z: -13

These minimum and maximum values will be used in the steps thatfollow as the minimum and maximum translation limits for theArmControl.

To set translation limits for the Arm Control

1 In the Hypergraph, select the ArmControl node.

2 Open the Attribute Editor (Window > Attribute Editor or click on theShow/Hide Attribute Editor icon on the Status Line).

The Attribute Editor displays the nodes associated with Arm Control.

3 In the Attribute Editor, click the ArmControl tab.

If the ArmControl tab is not visible, use the left and right scrolls arrowsto scroll the view sideways to view it.

4 In the Attribute Editor, expand the Limit Information attributes, andthen the Translate attributes.

Limiting the range of motion of an IK system | 289

Page 304: Autodesk Maya 2009

5 In the Translate attributes, click the Trans Limit Y and Z check boxes toundim the numerical boxes and then set the following values:n Trans Limit Y (Min): -13

n Trans Limit Y (Max): 7.5

n Trans Limit Z (Min): -13

n Trans Limit Z (Max): 1

6 Hide the Attribute Editor.

7 Select ArmControl.

8 In the side view, move ArmControl to test the range of movement forthe IK system.

The mechanical arm moves with a limited range of motion.

Simplifying the display of a hierarchy

The number of nodes in the IK system’s hierarchy at this point may appear abit overwhelming, but it allows the posing of the mechanical arm to be efficientand effective. You can simplify the display of the nodes by collapsing portionsof the hierarchy.

To collapse the display of the hierarchy

1 In the Hypergraph, right-click on joint1, and choose Collapse from thepop-up menu.

290 | Chapter 6 Animation

Page 305: Autodesk Maya 2009

The child nodes below joint1 disappear, simplifying the display of thehierarchy. The small arrowhead on the corner of the joint1 node indicatesthat a hierarchy exists below joint1. If you later need to view or selectthese nodes you can expand them again.

2 Collapse the ArmControl and IKHandle nodes.

The display of the hierarchy is simplified as shown below.

The IK system is now rigged and ready for animation.

Applying parent constraints on an IK system

To animate the cargo box so that it is picked up by the mechanical arm youneed a method of constraining the cargo box to the mechanical arm so thatit moves with the arm at specific times in the animation. This is accomplishedusing a parent constraint.

When a parent constraint is applied to an object, the constrained objectbehaves as if it were a child node of the constraining object.

An object can have multiple constraints applied to it. The influence eachconstraint has on the object can be changed by modifying the weight attributefor the parent constraint. The weight attribute is an animatable parameterand can be set to be on or off at specific frames.

In this lesson, the cargo box is constrained to both the ArmControl and thePlatform on the floor. By animating the weight attributes for these two parentconstraints, the cargo box will move from one location to another dependingon which constraint is influencing it at specific times in the animation.

To set up the parent constraints you need to position the constrained objectat the locations where the influence will begin or end, and then set the parentconstraints.

To set parent constraints for the cargo box

1 In the side view menu, select Shading > Smooth Shade All.

2 In the side view menu, select Panels > Perspective > persp.

Applying parent constraints on an IK system | 291

Page 306: Autodesk Maya 2009

3 In the Hypergraph, select ArmControl.

4 In the ChannelBox, set the Translate Y and Z values as follows:n Translate Y: -9

n Translate Z: 0

The arm is repositioned so that the cargo magnet is directly above the cargobox as shown below. Track, tumble, or dolly the view if required so you cansee the mechanical arm unobstructed.

1 In the Hypergraph, with ArmControl still selected, shift-select theCargoBox node.

The order of selection is important when you apply constraints. You mustselect the constraining object first, and the item to be constrained second.

2 In the main menu, select Constrain > Parent > .

3 In the Parent Constraint Options window, do the following:n Select Edit > Reset Settings to set the tool to its default settings.

n Click the Add button.

CargoBox is constrained to ControlArm. A new constraint node has beencreated below the CargoBox node in the Hypergraph. If you repositionthe mechanical arm, CargoBox moves with it because of the constraintthat is now applied.

4 In the Hypergraph, select only SwivelBase.

292 | Chapter 6 Animation

Page 307: Autodesk Maya 2009

5 In the ChannelBox, set the Rotate Y value for SwivelBase as follows:n Rotate Y: -100

The mechanical arm and the cargo box are positioned as shown below.

6 In the Hypergraph, select Platform and then shift-select the CargoBoxnode.

7 In the main menu, select Constrain > Parent.

CargoBox is constrained to Platform. This is the second constraint forthe CargoBox.

8 In the Hypergraph, select only CargoBox.

9 In the ChannelBox, view the parent constraints for CargoBox.

CargoBox has two parent constraints applied to it: Arm Control andPlatform. In the ChannelBox, the numerical settings beside ArmControlW0 and Platform W1 represent the influence weight each parentconstraint has on CargoBox. At this point, each influence weight is set

Applying parent constraints on an IK system | 293

Page 308: Autodesk Maya 2009

to a value of 1. If you move the mechanical arm, the cargo box will movesomewhere between its first and second position. This occurs becauseeach constraint has equal influence on the cargo box at this point.

Before you can animate the objects in the scene, you also need to reset thedefault weight values for each constraint, so that one parent constraint hasfull influence on CargoBox when the other does not.

To set the weighting for the parent constraints

1 In the Hypergraph, select only CargoBox.

2 In the ChannelBox, set the following:n Platform W1: 0

3 Select only SwivelBase.

4 In the ChannelBox, set the Rotate Y value to 0.

The mechanical arm and cargo box are rotated back.

5 In the Hypergraph, select only CargoBox.

6 In the main menu, select Constrain > Set Rest Position.

Setting a rest position for CargoBox sets a position for the cargo box whenno constraints are acting upon it. If the rest position is not set, CargoBoxwill be repositioned to the second constraint position.

7 In the ChannelBox, set the following:n ArmControl W0: 0

At this point, both parent constraints are set to have no influence on thecargo box because their weight attributes are set to zero. When youanimate the components in the scene, the weight attributes for the parentconstraints will be set and keyframed depending on which constrainingobject (Arm or Platform) is required to have full influence.

In the next steps, you plan the action for animation of the IK system.

Planning an animation for an IK system

Now that the mechanical arm and cargo box are fully set up for animationit’s a simple matter to pose the arm and set keyframes. Prior to setting anykeyframes you should take a few moments to plan the action for the scene.

294 | Chapter 6 Animation

Page 309: Autodesk Maya 2009

Planning the action usually involves sketching a simple storyboard, and writingout a brief timeline for the action for each component. In this lesson we’veprovided a simple version for you. The basic premise for the action is as follows:

n The cargo box is positioned directly in front of the mechanical arm.

n The mechanical arm extends, and positions the cargo magnet to be directlytouching the top of the cargo box.

n The mechanical arm extends upwards, lifting the cargo box, and rotatesto the side.

Planning an animation for an IK system | 295

Page 310: Autodesk Maya 2009

n The mechanical arm lowers the box, placing it in a new position.

n The mechanical arm extends upwards, leaves the cargo box in the newlocation, and rotates back to its original position.

The table below breaks down the action indicating what action occurs foreach object at the specified keyframes.

Cargo BoxMechanical ArmFrame

Initial positionCollapsed position1

Initial positionVertically extended position30

Initial positionVertically lowered so thatcargo magnet is positionedon top of cargo box

60

Cargo box lifted withmechanical arm

Vertically lifted to extendedposition with cargo box

80

Cargo box repositionedalong with mechanical arm

SwivelBase rotated alongwith arm to side

100

Cargo box is lowered alongwith mechanical arm tosecond position

Vertically lowered alongwith cargo box to secondposition above surface

120

Second positionVertically lifted to extendedposition

140

296 | Chapter 6 Animation

Page 311: Autodesk Maya 2009

Cargo BoxMechanical ArmFrame

Second positionSwivelBase rotated witharm to original position

160

Second positionCollapsed position180

To pose the mechanical arm you select either the ArmControl or SwivelBasenodes and set a keyframe depending on which component you want to pose:

n ArmControl controls the movement of the mechanical arm.

n SwivelBase controls the rotation of the arm.

n CargoBox’s position is based on the parent constraint weights.

Animating an IK system

The animation sequence occurs over a 180 frame period. Before you begin toset keyframes you set the playback range in the Animation Timeline/Slider.

To set the playback range in the Time Slider

1 In the Animation Time and Range Slider, set the following start and endtimes for the animation:n Playback Start Time: 1

n Playback End Time: 180

To simplify the keyframe workflow, you first set keyframes for the mechanicalarm, and then set keyframes for the weight attributes of each parent constraintfor the cargo box.

To set keyframes for the mechanical arm

1 In the Timeline, set the Time Slider to frame 1.

2 Select only ArmControl.

Animating an IK system | 297

Page 312: Autodesk Maya 2009

3 In the Channel Box, set the following values:n Translate Y: 0

n Translate Z: -13

4 From the main menu, select Animate > Set Key.

To set the remaining keyframes for the arm and the swivel base, use the tablebelow as a guide, and set the attributes in the following order:

n Set the frame using the Time Slider.

n Set the attributes for the object in the ChannelBox.

n Set the keyframe (Animate > Set Key).

NOTE Don’t be concerned if the list of keyframes indicates to set a key twicefor the same position over two frames. This is necessary to animate the parentconstraint weights over a period of one frame.

SelectSet attributeSelectFrame

Set KeyTransY: 0ArmControl1TransZ: -13

Set KeyTransY: 7ArmControl30TransZ: -13

Set KeyTransY: -9ArmControl59TransZ: 0

Set KeyTransY: -9ArmControl60TransZ: 0

Set KeyTransY: 6ArmControl80TransZ: -13

Set KeyRotateY: 0SwivelBase80

Set KeyRotateY: -100SwivelBase100

Set KeyTransY: 6ArmControl100TransZ: -13

298 | Chapter 6 Animation

Page 313: Autodesk Maya 2009

SelectSet attributeSelectFrame

Set KeyTransY: -9ArmControl120TransZ: 0

Set KeyTransY: -9ArmControl121TransZ: 0

Set KeyTransY: 6ArmControl140TransZ: -13

Set KeyRotateY: -100SwivelBase140

Set KeyRotateY: 0SwivelBase160

Set KeyTransY: 6ArmControl160TransZ: -13

Set KeyTransY: 0ArmControl180TransZ: -13

Once the keyframes for the mechanical arm are set you can use the playbackcontrols to playback the motion for the mechanical arm.

To playback the animation using the playback controls

1 Click play on the TimeSlider playback controls to play the animation.

The mechanical arm animates over 180 frames. The cargo box does notmove because the weight attributes for the parent constraints are set tozero and have not yet been set for the animation.

2 Click stop on the TimeSlider playback controls to stop the playback.

In the next steps, you set keyframes for the parent constraint weight attributesso the cargo box is lifted, moved, and placed in the second location. You setkeys for the weight attributes on the parent constraint node.

To set keyframes for the parent constraint weights

1 In the Timeline, set the Time Slider to frame 1.

2 In the Hypergraph, select the node for the parent constraint directlybelow CargoBox.

Animating an IK system | 299

Page 314: Autodesk Maya 2009

3 In the Channel Box, set the following values (if they are not set already):n ArmControl W0: 0

n Platform W1: 0

4 In the Channel Box, select the ArmControl and Platform channels byshift-clicking on the names.

5 Right-click on either one of the selected names.

A drop-down list appears.

6 From the drop-down list, choose Key Selected.

Key Selected sets a keyframe for the selected attributes only.

To set the remaining keyframes for the parent constraint weights, use the tablebelow as a guide, keeping in mind that you set the attributes in the followingorder:

n Set the frame using the TimeSlider.

n Set the parent constraint attributes in the ChannelBox.

n Right-click on the selected names and select Key Selected.SelectSet attributeSelectFrame

key selectedArmControl W0: 0CargoBox parent-Constraint

1Platform W1: 0

key selectedArmControl W0: 0CargoBox parent-Constraint

59Platform W1: 0

300 | Chapter 6 Animation

Page 315: Autodesk Maya 2009

SelectSet attributeSelectFrame

key selectedArmControl W0: 1CargoBox parent-Constraint

60Platform W1: 0

key selectedArmControl W0: 1CargoBox parent-Constraint

120Platform W1: 0

key selectedArmControl W0: 0CargoBox parent-Constraint

121Platform W1: 1

To playback the animation using the playback controls

1 Click play on the TimeSlider playback controls to play back the animation.

The mechanical arm moves through the motion of the animation andpicks up and moves the cargo box to the new location.

2 Click stop on the TimeSlider playback controls to stop the playback.

You have completed this lesson.

Beyond the lesson

In this lesson, you completed the animation of a mechanical arm model thatpicked up and moved a cargo box. You learned how to:

n Construct a model hierarchy to provide relationships between thecomponents for posing and keyframing.

n Construct a single chain skeleton to pose the arm model using InverseKinematics.It is common to create characters with multiple joint chains. For example,two and four-legged characters would use multiple joint chain skeletonsto assist with posing their hierarchical structure. See Skeleton hierarchy inthe Maya Help. For a tutorial on creating a multiple chain skeleton seeLesson 1: Skeletons and Kinematics (Introduction on page 304).

n Parent the components of the mechanical arm model into the skeletonhierarchy.Parenting is one method for combining a model into a skeleton hierarchy.When using characters that have bending or deforming features a morecommon technique is to use Skin > Bind Skin. For more information see

Beyond the lesson | 301

Page 316: Autodesk Maya 2009

Skeletons and skinning in the Maya Help. For a tutorial on smooth skinningsee Lesson 2: Smooth Skinning (Introduction on page 304).

An easy method to parent one node to another using the Hypergraph isto drag one node over top of the other using your middle mouse button.

n Create an IK system with a control object for manipulation.It is very common to create characters with multiple joint chains andmultiple IK handles to control them. Control objects simplify the selectionand posing of the character.

n Use three types of constraints (Point, Orient, Parent) to control componentsof the IK system and other components in the scene.Constraints are useful for animating the attributes of one object based onthe attributes of another. Other types of constraints not covered in thislesson include aim and scale constraints. See Aim constraints and Scaleconstraints in the Maya Help.

Using the parent constraint, the platform could also be animated to movethe cargo box as if it were on an elevator, or a conveyor belt.

n Apply limits to the movement of the IK system.In this lesson, you constrained the translation of the control object inorder to constrain the movement of the IK. It is not recommended thatyou set limits on the rotation of an IK system as it limits how the solvercalculates the position of the joints. See Setting up joints for posing andanimation in the Maya Help.

Although not covered in this lesson, it is possible to simplify the displayof attributes in the ChannelBox so that only the animatable attributesassociated with a character are displayed.

n Pose and set keyframes for an IK system.

302 | Chapter 6 Animation

Page 317: Autodesk Maya 2009

Character Setup

IntroductionA typical 3D character can be made up of many surfaces and components. Toensure that the character animates in the way that you want, it is important tocarefully plan the process of character setup.

Character setup or rigging is the general term used for the preparation of 3Dmodels with their accompanying joints and skeletons for animation.

Depending on the model to be animated, character setup can involve thefollowing techniques:

n Creating a skeleton with joints that acts as a framework for the 3D charactermodel. You set limits on the joints so they rotate in a convincing manner.When you animate the character, you will be posing the character via itsjoints using either forward or inverse kinematic techniques (FK or IK).

n Binding the 3D surfaces to the skeleton so that they move together. Theprocess of binding may also include defining how the character’s joints bendor how the skin surfaces bulge to simulate muscles.

n Defining and setting constraints for particular animated attributes in orderto restrict the range of motion or to control an attribute based on themovement of another.

n Grouping surface components such as CVs into sets called clusters so thatparts of the character can be animated at a more detailed level.

This chapter introduces you to the most common character setup features:

n Lesson 1 Skeletons and kinematics: Introduction on page 304

7

303

Page 318: Autodesk Maya 2009

n Lesson 2 Smooth skinning: Introduction on page 319

n Lesson 3 Cluster and blend shape deformers: Introduction on page 330

Preparing for the lessons1 To ensure the lessons work as described, select the Animation menu set.

Unless otherwise noted, the procedures in this chapter assume theAnimation menu set is selected.

2 If you have not already done so, copy the GettingStarted folder fromits installation location to your projects directory. Then, set theGettingStarted directory as your Maya project. For more information,see Copying and setting the Maya project on page 25.

3 Make sure that Soft Selection is turned off by opening the Attribute Editorwith the Select Tool active and unchecking the box marked Soft Select.

Lesson 1: Skeletons and kinematics

Introduction

After you model the surfaces that make up a human, animal, or other character,you create a skeleton and bind it to the character’s surface (called skin).

A skeleton provides a structure for animating the character. When you createa skeleton in Maya, you create a series of bones with joints in the skeletallocations where you want the character to bend or twist. (You can animate askeleton without having a skinned character.)

In this lesson, you learn the techniques for creating a simple skeleton for ahuman character. You will learn how to:

n Create joints for a character.

n Name joints in the Hypergraph.

n Use symmetry when creating a character.

n Parent joints into an existing skeleton.

304 | Chapter 7 Character Setup

Page 319: Autodesk Maya 2009

n Use Inverse Kinematics (IK) techniques to pose a skeleton.

Learning how to bind a character to a skeleton is described in the next lesson.

Open the scene for the lesson

In this lesson, you’ll work with a scene that we created for your use. The scenecontains a human character. In the remainder of the lesson, you’ll create andanimate a skeleton for the character.

To open the scene

1 Make sure you’ve done the steps in Preparing for the lessons on page 304.

2 Open the scene file named Skeleton.ma.

This file can be found in the GettingStarted directory that you set asyour Maya project:

GettingStarted/CharSetup/Skeleton.ma

The character displayed in the scene, Jackie, is a template, so you cannotunintentionally select it during the lesson. Jackie was modeled in the DaVinci pose, the position that’s easiest for creating a skeleton.

Creating joints

A skeleton is made of bones and joints. When you create a skeleton in Maya,you create a series of joints in the skeletal locations where you want thecharacter to bend or twist.

A common technique for creating a skeleton is to create several independentjoint chains—one for each arm, one for each leg, one for the spine/head—then

Open the scene for the lesson | 305

Page 320: Autodesk Maya 2009

group the chains together to create a single skeletal hierarchy. In the stepsthat follow, you create the joints for the legs.

To create joints for the legs

1 Select Window > Settings/Preferences > Preferences. In the Preferenceswindow, click the Kinematics Category. Enter 0.4 for the Joint Size, thenclick the Save button.

This displays the joints smaller when you create them in the next steps.At the default size, 1.0, the size of the joints makes them hard to positionaccurately for this character.

NOTE The default joint size of 1.0 has been used to create the joints picturedin the following illustrations. The joints you create may appear smaller thanthose pictured in this lesson.

2 Select Skeleton > Joint Tool. This is the tool for creating the joint chainsthat make up a skeleton.

3 In a side view, click at the hip, knee, ankle, ball of foot, and toe to createjoints at these positions (see the following figure). Make sure the knee

306 | Chapter 7 Character Setup

Page 321: Autodesk Maya 2009

joint is in a position that creates a slight forward bend. The forward bendensures that you will be able to animate the leg easily in a directionnatural for a leg.

4 Press Enter (Windows and Linux) or Return (Mac OS X) after creating thetoe joint. This completes the joint chain.

5 Select Window > Hypergraph: Hierarchy.

The Hypergraph is a convenient place to select, rename, and parentobjects. It is similar to the Outliner, but it has features tailored forcharacter setup. For example, it depicts all parent-child relationships inan easy-to-read indented format.

The Hypergraph shows the default names given to the joints just created:joint1, joint2, and so on. The joints have a hierarchical relationship.Joint1 is the parent of joint2, which is the parent of joint3, and so on.Joint1 is the root of the hierarchy. If you reposition joint1, you repositionthe whole joint chain.

In the scene view, joints are represented by spherical icons. Bones separatethe joints, and are represented by elongated pyramid icons. The narrowpart of a bone points in the downward direction of the hierarchy.

The reason you create the hip joint first and the toe joint last is to havethe hip at the top of the hierarchy and the toe at the bottom. You’llusually want the toe (and other joints) to move whenever you move thehip, but not necessarily vice versa. In general, joint chains emanate fromthe interior of the character outward.

6 Rename the joints as left_hip, left_knee, left_ankle, left_ball, and left_toe.To rename a joint, right-click the joint name in the Hypergraph and selectRename from the drop down menu. Type the new name and press Enter.

7 In the front view, click the left_hip joint to select it. Move it along theX-axis to the center of the top of the left leg. (In this lesson, left and right

Creating joints | 307

Page 322: Autodesk Maya 2009

refer to directions from Jackie’s point of view, not from your view of thescene.)

As mentioned before, when you move a joint, all joints lower in thehierarchy move with it. If you press Insert (Windows and Linux) or Home(Mac OS X) while a joint is selected, you can move the joint withoutmoving joints below it in the hierarchy. (To exit this mode, press Insertor Home again.)

NOTE You may need to rotate left_hip so that the skeleton fits inside the leg.It’s unnecessary to fit the skeleton perfectly inside the character, as it won’tbe displayed when you render an image from the scene.

8 To create the joints for the other leg, you can save time and ensuresymmetry by duplicating the existing leg joint chain with mirroring.

With left_hip selected, select Skeleton > Mirror Joint > . In the optionswindow, turn on YZ for Mirror Across.

Jackie’s legs straddle the YZ plane, so mirroring the joint chain across theYZ plane positions the duplicate joint chain in the desired location. Thisoperation illustrates that Jackie’s original position affects the ease withwhich you can create the skeleton. Had Jackie been positioned away fromthe origin, you would not have been able to use Mirror Joint convenientlyto duplicate the leg’s joint chain.

9 Enter left in the Search For field and enter right in the Replace With field.

The Replacement names for duplicated joints feature automaticallyreplaces the names of all duplicate joints with the specified joint prefix.

10 Click the Mirror button.

The right leg bones and joints appear in a mirrored position.

308 | Chapter 7 Character Setup

Page 323: Autodesk Maya 2009

In the next steps, you create a joint chain for the spinal column. You alsoextend a joint from the upper neck region of the joint chain so that you cananimate the jaw.

To create joints for the spine and jaw

1 In the side view, use the Joint Tool to create a series of joints at thelocations shown in the figure. Start at the base of the spine near theexisting hip joints (left_hip and right_hip) and end at the top of the head.Make sure you create the first joint a little bit away from the existing hipjoint displayed in the front view. Otherwise the first joint will beconnected to the hip joint. Remember to press Enter (Windows andLinux) or Return (Mac OS X) when you are done creating the joint chain.

With the exception of the joints at each end of the joint chain, the jointsare located where the character is likely to bend or twist at the spine andneck.

Creating joints | 309

Page 324: Autodesk Maya 2009

The S-shaped curvature of the joint chain resembles Jackie’s spinalcurvature. This makes it easier to animate the character’s torso and necknaturally.

2 Starting at the base of the spine, name the joints back_root, pelvis,lower_back, mid_back, upper_back, lower_neck, upper_neck, and crown.

3 To set up the skeleton for jaw movement, extend a joint from theupper_neck joint. With the Joint Tool selected, click the upper_neck jointin the Hypergraph to select it, then click to create a new joint near thelips, and press Enter or Return. Name the new joint as jaw.

Creating joints for the arms is similar to creating joints for the legs.

To create joints for the arms

1 In the front view, create a series of joints at the locations shown in thefigure. Start at the pectoral region (near the upper_back joint) and endat the wrist.

2 Name the joints left_arm_root, left_shoulder, left_elbow, and left_wrist.

310 | Chapter 7 Character Setup

Page 325: Autodesk Maya 2009

3 In the top view, select the left_elbow joint, select the Move tool, pressInsert (Windows and Linux) or Home (Mac OS X), then move the jointto the back of the arm. Press Insert or Home again.

Moving the joint to the back of the arm creates a bend at the elbow. Thiswill make it easier to animate the character’s arm in the direction an armnaturally bends.

4 In the perspective view, select left_arm_root. Select Skeleton > MirrorJoint. This creates a copy of the left arm’s joint chain for the right armand renames them in the process.

The right arm bones and joints appear in a mirrored position.

Adding joints to a skeleton

When you bind a character to a skeleton (described in the next lesson), theskeleton provides a structure for the character’s skin and prevents the skinfrom collapsing as you pose the skeleton.

Adding joints to a skeleton | 311

Page 326: Autodesk Maya 2009

It’s useful to add extra joints in areas of the character where you want thesurface to keep its volume upon deformation. In the next steps, you’ll addribs to Jackie’s skeleton. Although you will not bind the character in thislesson, the technique of adding ribs is important to learn so that when youdo bind a character, the skin in the torso area will not collapse as you poseshoulder and spinal rotations. The rib joints are for structure only, not forposing the skeleton.

To add ribs to the skeleton

1 In the Hypergraph, click the mid_back joint to highlight the joint in thefront view. Remember the location of the joint in the front view so youcan select it later.

2 Select Skeleton > Joint Tool.

3 In the front view, click on the mid_back joint to select it again.

4 Click to the side of the joint to add a rib bone, then press Enter (Windowsand Linux) or Return (Mac OS X).

5 With the same technique as in the prior steps, create two more ribs forthe left side. The ribs extend from the mid_back, lower_back, and pelvisjoints.

312 | Chapter 7 Character Setup

Page 327: Autodesk Maya 2009

6 For easy identification in the Hypergraph, you can optionally name theribs as desired. For instance, name them left_top_rib, left_mid_rib,left_bottom_rib, and so on.

7 Mirror the left rib joints to create ribs for the right side of the skeleton.

Creating a skeleton hierarchy

So far you have created five separate joint chains: one for the spine, and onefor each arm and each leg. You need to create a single hierarchy from the fivejoint chains so you can move all of them as a single unit. To create the singlehierarchy, you parent the arms and legs to the nearest joint in the spine.

To parent the arm and leg joint chains to the spine

1 In the Hypergraph, use the middle mouse button to drag left_arm_rootto upper_back.

When you parent one joint to another, Maya creates a bone that connectsthe parent to the child. In this case, the bone connects upper_back toleft_arm_root.

2 Use the middle mouse button to drag right_arm_root to upper_back.

3 Use the middle mouse button to drag left_hip to back_root.

4 Use the middle mouse button to drag right_hip to back_root.

Now if you need to move the entire skeleton, you can moveback_root—the root of the hierarchy. The completed skeleton is shownin the following figure (with Jackie hidden):

Creating a skeleton hierarchy | 313

Page 328: Autodesk Maya 2009

Forward and inverse kinematics

There are two techniques for posing a skeleton: forward kinematics and inversekinematics.

Forward kinematics (FK)

To pose a character with forward kinematics, you rotate each joint individuallyuntil you get the desired positioning. For example, to move a hand to somelocation, you must rotate several arm joints to reach the location.

When you animate a skeleton posed with forward kinematics, Mayainterpolates the joint rotations starting with the root joint, then the root’schild joints, and so on down through the skeleton’s action hierarchy. Mayaproceeds forward through the action hierarchy, starting at the root joint.

Forward kinematics is intuitive for creating simple arc motions, but it’s tediousif you are animating a complex skeleton. It’s also not intuitive for specifyinggoal-directed motion. For example, to move a hand to some location, it’s notobvious how to rotate the joints in an arm.

Inverse kinematics (IK)

With IK, you create an extra control structure, an IK handle, for certain jointchains such as arms and legs. An IK handle lets you pose and animate an entirejoint chain by moving a single manipulator.

As you pose the IK handle, it automatically rotates all the joints in the jointchain. For example, if you move a hand to a doorknob, the other joints in thearm rotate to accommodate the hand’s new positioning.

IK is more intuitive than forward kinematics for goal-directed motion becauseyou can focus on the goal rather than on how you need to rotate each jointto achieve that goal.

Posing and animating using inverse kinematics

Next, you create IK handles that you’ll later use to pose the arms and legs.The next steps describe some initial setup you should perform before creatingthe IK handles.

314 | Chapter 7 Character Setup

Page 329: Autodesk Maya 2009

To set up the character prior to creating IK handles

1 Select the root of the hierarchy, back_root, and then select Skeleton > SetPreferred Angle.

This sets the current joint angles throughout the skeleton as the preferredangles. This is a useful step after you complete a skeleton. Maya thereafteruses the current bend in the knees and elbows as the preferred initialrotation direction of these joints during inverse kinematics (IK) posing.This makes it easier to pose the character with motion that is natural fora human character.

2 Select Jackie in the Outliner and, from the main menu, select HideSelection. (You must select and hide Jackie from the Outliner becauseJackie is a template object.) By hiding Jackie, you’ll lessen scene clutteras you pose the skeleton in the following steps.

To create, pose, and animate IK handles for the legs

1 Select Skeleton > IK Handle Tool > .

2 In the Tool Settings window, make sure Current Solver is set to ikRPsolver.

This type of IK solver has characteristics that work well for thisapplication.

3 In the perspective view, click left_hip and left_ankle.

This creates an IK handle that lets you control all joints from left_hipthrough left_ankle. The handle’s main manipulator is at the left_ankle.

The IK handle is the selected object after you create it. If youunintentionally cancel the selection of the handle, you can select it againby clicking the left_ankle—the last joint you clicked after using the IKHandle Tool. Whenever you select a handle, make sure you do not selectjoints or other objects along with the handle. You can check the Outlinerto confirm your selection.

4 Go to the start of the playback range.

5 With the IK handle selected, select Animate > Set Key to key the leg’scurrent position at the first frame.

6 Go to frame 12.

Posing and animating using inverse kinematics | 315

Page 330: Autodesk Maya 2009

7 In the side view, use the Move tool to drag the IK handle up and to theleft (see illustration), as if Jackie were stepping up a staircase. The footand knee move while the hip stays in place.

8 Set another key for the IK handle.

9 Go to frame 24. Move the IK handle back to its prior position. Set anotherkey.

10 Play the animation to see the leg step up and down during the first 24frames.

This completes a simple animation of the leg using an IK handle to controlits position.

To practice additional IK techniques

1 Go the start of the animation.

2 In a perspective view, practice posing the leg in various directions bymoving the IK handle.

No matter how far you drag the handle manipulator, the joints of theleg will not stretch beyond the straight leg position. This is desirable; youdo not want the size of a skeleton to change as you pose it. However, ifyou drag a leg joint, the bone hierarchically above that joint will lengthen.This is why it’s important to check that you haven’t selected a joint withthe IK handle before you move the handle.

316 | Chapter 7 Character Setup

Page 331: Autodesk Maya 2009

As you drag the handle to some positions, you might notice the leg jointsflip abruptly (see the next figure for an example position). It’s thereforehard to control the leg positioning in this region.

The default IK handle (IK Rotate Plane handle) has manipulators you canuse to avoid joint flipping. With the handle selected, select Modify >Transformation Tools > Move Tool, Rotate Tool, Scale Tool, ShowManipulator Tool. Move the Pole Vector XYZ manipulator to a slightlydifferent position (see the following figure).

If this doesn’t solve the problem, rotate the Twist manipulator to rotatethe leg. You can key the Pole Vector XYZ and Twist attributes to fixedvalues to avoid the flipping as the character moves.

A more precise way to avoid joint flipping, which requires some initialsetup, is to use a Pole Vector Constraint. For more information see theMaya Help.

3 Repeat the preceding steps for the right leg. (Create an IK handle for theright_hip to right_ankle, then practice posing and animating the handle.)

NOTE If you want to move the entire skeleton, group the back_root and allIK handles under a single node, select the group node, and then use theMove tool. With this grouping, the motion of the entire skeleton won’t conflictwith the keys you set for the handles.

To create, pose, and animate IK handles for the arms

1 Select Skeleton > IK Handle Tool.

Posing and animating using inverse kinematics | 317

Page 332: Autodesk Maya 2009

2 Click left_shoulder, and then click left_wrist. This creates an IK handlefor the left arm.

3 Select Skeleton > IK Handle Tool.

4 Click right_shoulder, then click right_wrist. This creates an IK handle forthe right arm.

5 Practice posing and animating the handles.

Posing and animating using forward kinematics

As the last part of the lesson, you can optionally practice posing and animatingthe character by rotating joints that are not controlled by IK handles—theball joints of the feet, and joints from the back_root through the upper_neck.Rotating such joints is forward kinematics.

With the exception of the back_root, you’ll invariably rotate rather than movethe joints that aren’t part of an IK handle. If you move the joints, the boneslengthen. This deforms bound skin undesirably unless you are creatingcartoon-like distortions.

Because you’ve already set keys for IK handles, some joint rotations on non-IKhandle joints will be restrained by the IK handle positioning. If this interfereswith the intended poses, you can remove all prior animation from an IK handleby selecting Edit > Keys > Delete Keys. You can also use Delete Keys to removeall animation from keys you’ve set with forward kinematics.

Beyond the lesson

In this lesson you learned how to:

n Create a skeleton with bones and joints.

n Pose the skeleton using Inverse Kinematics.

Additional things to consider when working with skeletons:

n The appropriate number of joints in a skeleton depends on the anatomicalparts of the character you want to manipulate. More joints means finercontrol at the expense of greater complexity.

318 | Chapter 7 Character Setup

Page 333: Autodesk Maya 2009

n As you created the skeleton in this lesson, you ended the arm’s joint chainat the wrist. This prevents you from animating hand motion. If you needto animate hand motion or even finger motion, you would need to makeadditional joints and IK handles. The same applies to foot and toe motion.

n When you create a skeleton, you can animate a character bound to it toproduce natural skin deformations. Although you animated an unskinnedskeleton in this lesson, it’s more common to animate a skinned skeleton.Binding a character is the topic of the next lesson.

n It’s typically best to animate the entire skeleton from pose to pose at desiredframes. It’s hard to get desired results by animating one limb for a framerange, another limb for a frame range, and so on.

There are many other ways to work with skeletons not described in this lesson:

n You can blend or switch between IK and forward kinematics on jointscontrolled by an IK handle.

n There are other types of IK handles that provide different controls formanipulating parts of a skeleton. Especially noteworthy is the IK splinehandle, which makes it easy to animate the twisting, wavy motion in tails,necks, spines, snakes, and so on.

For more details on these and other features, please refer to the Maya Help.

Lesson 2: Smooth skinning

Introduction

After you create a skeleton, you bind it with the character’s surface so that thesurfaces move with the skeleton during animation. Binding is also calledskinning, and a character’s surface after binding is called a skin.

It is important that the character’s skin deforms naturally as the skeletonmoves. Near joints, the skin bulges or indents when you rotate the joints.

In Maya, the skin deforms because the surface’s vertices (or CVs) move inresponse to the rotation of adjacent joints. The vertices are known as skinpoints. This is useful for animating elbows, shoulders, necks, and so on.

Lesson 2: Smooth skinning | 319

Page 334: Autodesk Maya 2009

By default, the influence a joint has on a skin point’s movement depends onhow close it is to that joint. You can edit skin point weighting to change thedefault movement.

In this lesson you learn how to:

n Bind a skeleton using a smooth bind technique.

n View and modify skin weights using the Skin Weights Tool.

n Use influence objects to enhance the skin deformation of a character.

Open the scene for the lesson

In this lesson, you work with a scene we created for your use. The scenecontains a human character and skeleton. Each leg and arm of the skeletonhas an IK handle that lets you pose the limbs conveniently. If you completedthe prior lesson, the character, skeleton, and IK handles will be familiar.

1 Make sure you’ve done the steps in Preparing for the lessons on page 304.

2 Open the scene file named SmoothSkin.ma.

This file can be found in the GettingStarted directory that you set asyour Maya project:

GettingStarted/CharSetup/SmoothSkin.ma

The character in the scene, Jackie, is displayed in a transparent fashionso you can see the skeleton beneath the surface.

320 | Chapter 7 Character Setup

Page 335: Autodesk Maya 2009

3 Select Window > Settings/Preferences > Preferences. In the Preferenceswindow, click the Kinematics Category. Enter 0.4 for the Joint Size, thenclick the Save button.

This displays the joints smaller. At the default size, 1.0, the large size ofthe joints obstructs the view of the skin.

Smooth binding a skeleton

You use Jackie as the surface to be bound to the skeleton.

To bind the skeleton using smooth skinning

1 Select Jackie.

2 Shift-select the back_root joint.

The back_root joint is at the base of Jackie’s spine. If you are not surewhich joint it is, select it in the Hypergraph (Window > Hypergraph:Hierarchy).

3 Select Skin > Bind Skin > Smooth Bind > .

The Smooth Bind Options window appears.

4 In the Smooth Bind Options window, set Max Influences to 3, then clickBind Skin.

A Max Influences value of 3 specifies that three joints influence each skinpoint. By default, the joint closest to the point has the most influence.The second most influential joint is that joint’s parent or child joint,whichever is closest to the point. The third most influential joint is thenearest parent or child of the second joint. The influence drops with thedistance from the joints. The amount of influence each joint has on anyskin point is the skin weight.

The default skin weights create smooth deformations of the skin at elbows,knees, and elsewhere as the nearby joints rotate.

5 Select and move any or all of the four IK handles to pose the arms andlegs in various positions in order to get used to posing with the IK handles.

To select an IK handle, drag a selection box around a wrist or ankle joint.To move a handle, use the Move tool to drag the handle in the desireddirection.

Smooth binding a skeleton | 321

Page 336: Autodesk Maya 2009

Note that you can also select the IK handles in the Hypergraph. Thehandles are indented under jackieSkeleton. Each is named for a leg orarm, for example, ikHandleLeftLeg. For more details on IK handles, seeLesson 1: Skeletons and kinematics on page 304.

6 If you prefer to turn off the skin’s transparency so you can see the skinmore clearly, turn off Shading > X-Ray. Do not be concerned that theskeleton pokes through the skin, as the skeleton is not displayed in arendered image.

As you pose the arms and legs, examine the skin in the regions wherejoints bend. For many poses, the skin looks natural. For others, the skinfolds, compresses, or bulges unnaturally. The pelvis, shoulders, and torsoare common problem areas for various poses. For example, if you movean arm straight up, the shoulder compresses as in the following figure.

There are two ways to improve the smooth skin deformations:

n Add an influence object to eliminate collapsing regions or to create musclebulge. For example, you can use an influence object to make the shoulderregion look more natural in the prior pose.

n Edit skin weights—to remove minor lumps or indented regions. Forexample, you can fill out an undesirable concave region at the chest thatappears when you move the arm to certain poses.The following procedures explain the techniques.

322 | Chapter 7 Character Setup

Page 337: Autodesk Maya 2009

Skin weighting and deformations

In the next steps, you’ll learn how joints and skin weights influencedeformations at Jackie’s chest. In a subsequent section, you’ll improve unevendeformations.

To see how skin weights affect a skin’s deformation

1 Pose the left arm similar to the following figure. The left breast becomesirregularly shaped.

2 Select Jackie.

3 Select Skin > Edit Smooth Skin > Paint Skin Weights Tool > .

4 In the Influence list of the Tool Settings window, select any joint, forinstance, pelvis. The grayscale color of Jackie’s skin indicates how muchinfluence that joint has on the skin’s deformation.

White means the skin is maximally influenced by the joint. Black meansthe skin is not influenced by the joint. Gray means the influence is partial.The lighter the gray, the more the influence.

Each point on the surface is influenced by three joints, as specified bythe Max Influence setting in a prior step. However, one or two of thethree joints might have so little influence as to be insignificant.

Skin weighting and deformations | 323

Page 338: Autodesk Maya 2009

In general, a white region of skin is influenced nearly entirely by the jointselected in the Influence section of the Tool Settings window. A grayregion is influenced significantly by one or two additional joints.

The reason the left breast becomes irregularly shaped as you pose the armis that some joint is exerting too much or too little influence on thebreast.

5 Select each entry in the Influence list to determine which joints areinfluencing the irregular region of the breast. The region will be a shadeof gray (or white) when you select the appropriate joints. Theleft_arm_root is the main influence. The upper_back, mid_back, andleft_top_rib also have influence, though not exactly in the same region.

Modifying skin weights

You can modify the skin weights for any of the influencing joints to alter theirregular region. If you don’t get the desired results when you change the skinweights of one of the influencing joints, you can undo your changes and tryanother influencing joint.

In general, it’s best to modify the skin weights of the most influential jointfirst, then work with less influential joints if you don’t get the desired results.Modifying skin weights requires experimentation.

In the next steps, you’ll modify the skin weights for the left_arm_root joint.

To modify skin weights using the Paint Skin Weights Tool

1 Select left_arm_root in the Influence list.

2 In the Paint Weights Menu section of the window, set Value to 0.1 andturn on Add.

3 Drag the mouse pointer to paint the irregular region of the breast. Eachstroke adds 0.1 (10%) to the skin weight. The weight for a skin point hasa maximum value of 1 (fully white).

TIP Painting skin weights using a tablet with stylus allows you to takeadvantage of pressure sensitivity.

Repeat the strokes several times until the irregular region becomessmoother. The jagged, asymmetrical wireframe at the breast becomesmore symmetrical as the skin becomes smoother. The region whitens,which indicates increased influence from the left_arm_root joint. Note

324 | Chapter 7 Character Setup

Page 339: Autodesk Maya 2009

that increasing the influence of one joint lessens the influence of theother influencing joints.

4 To check the shape with full-color shading, click the Select Tool. (Youmight also prefer to cancel the selection of Jackie to eliminate the displayof the highlighted wireframe.)

5 To continue modifying the skin weights with the Paint Skin WeightsTool, select Jackie and once again select Skin > Edit Smooth Skin > PaintSkin Weights Tool.

There are several additional tool settings you might find useful as youmodify skin weights:

n The Smooth operation smooths the weights of points by averaging thestroked points with the weights of the surrounding region. This is usefulif you add to the weight values in some region but the points becomeunevenly weighted. Uneven weights are indicated by mottled gray skin.

n You can use the Scale operation with a Value less than 1 to scale down thepoint weights of a stroked region.

n As you stroke a region, the red circle icon displays the radius of the regionaffected by the stroke. The Radius(U) value changes the radius.

n You can select any of the Profile icons to specify the region affected bystrokes. The two leftmost icons are the most commonly used shapes.

1 After you eliminate the irregular region from the left breast, move thearm to different positions to see if the breast’s shape stays natural in

Modifying skin weights | 325

Page 340: Autodesk Maya 2009

various poses. It is common for a surface to look good in one pose butnot in another. Strive to make the surface look good in the poses thatyou are likely to use during animation.

2 If you want more practice, pose the right arm as you posed the left armand fix the corresponding irregular region in the right breast. This time,fix the region by modifying the weights for the upper_back joint ratherthan the right_arm_root. As mentioned previously, you can modify pointweights of alternative joints to get a similar effect.

Influence objects

You can create an object and use it to influence the shape of smooth skin.The object, called an influence object, acts like a surgical implant againstwhich the skin deforms. For example, you can create a sphere and use it tosimulate a muscle or bone that bulges as you pose the character in certainpositions. You can also use an influence object to smooth deformation andmaintain volume in regions that collapse while bending.

In the next steps, you’ll use a sphere as an influence object to simulate anelbow jutting out as Jackie’s arm bends. To use an influence object, the skeletonmust be in the bind pose—the original pose at which the skin was bound toJackie.

To return the skeleton to the bind pose

1 Click the Select Tool and cancel the selection of Jackie.

2 Turn off Modify > Evaluate Nodes.

After you use an IK handle to pose a character, you must do this stepbefore you can return the skeleton to the bind pose.

3 Select back_root, the root of the skeleton.

326 | Chapter 7 Character Setup

Page 341: Autodesk Maya 2009

4 Select Skin > Go To Bind Pose.

5 Select the ikHandleLeftArm in the Hypergraph. Use the Move Tool tomove the handle manipulator slightly in any direction. When you releasethe mouse, note that the arm does not move and that the IK handlemanipulator snaps back to the desired position at the end of the jointchain. Repeat this step for any other IK handles you posed previously.

6 Turn on Modify > Evaluate Nodes.

You must do this step to enable the IK solvers so you can manipulate IKhandles in the scene again.

To position a sphere to be used as an influence object

1 Right-click Jackie’s surface (anywhere but on the skeleton) and selectActions > Template from the marking menu.

By making Jackie a template, you won’t accidentally select Jackie insubsequent steps.

2 Select Create > Polygon Primitives > Sphere >, and name the sphereelbow_influence.

3 Scale the sphere to be slightly smaller than any of Jackie’s joints (seeillustration below).

4 Move the sphere so that its surface is positioned where the elbow wouldjut out, but still within the skin. You can optionally reshape the sphere’scurvature to resemble the tip of an elbow jutting out from a bent arm.For example, you can scale the sphere in one dimension to squash itsshape or you can move individual vertices. A top view of the sphere’sshape and position follows:

The exact position and scale of the sphere is unimportant. You can makeslight position and scale adjustments later to enhance the deformationsthat result from its use.

Influence objects | 327

Page 342: Autodesk Maya 2009

To make the sphere an influence object

1 In the Hypergraph, select Jackie and Shift-select elbow_influence.

2 Select Skin > Edit Smooth Skin > Add Influence > . In the Add InfluenceOptions, select Edit > Reset Settings, and then click the Add button.

Maya completes the operation within a few moments. To ensure theinfluence object stays in the correct position at the elbow, you will parentit to the left_shoulder joint.

3 In the Hypergraph, shift-select elbow_influence, elbow_influenceBase,and left_shoulder joint, in that order.

The order of selection is important. The parent object should be selectedlast.

4 Press p to parent the elbow nodes under the left_shoulder joint.

The elbow_influence nodes appear in the skeleton hierarchy below theleft_shoulder joint.

The elbow_influenceBase is known as a base object. It stores vertexposition information for the influence object. The reason for parentingthe base object to the left_shoulder joint is so that the influence object’svertices stay in the correct position at the elbow whenever the elbowmoves to a new position. Other than this step, you do not work with thebase object.

5 Right-click Jackie and select Actions > Untemplate. It is easier to seesubsequent skin deformations when Jackie is displayed with smoothshading rather than as a template.

6 From the menus at the top of the top view, turn off Show > Joints toavoid having the joints obstruct your view of the skin.

7 Use each arm’s IK handle (ikHandle1 and ikHandle2) to pose the armsin the following position.

328 | Chapter 7 Character Setup

Page 343: Autodesk Maya 2009

The left elbow looks more natural than the right elbow. To tune theelbow’s deformation during bending, change the position, scale, androtation of elbow_influence.

Do not be concerned if the influence object pokes through the skin. Itwon’t be displayed when you render the animation.

Beyond the lesson

In this lesson you learned how to:

n Bind a skeleton to a single surface.You can bind a skeleton to multiple surfaces or even to a selection ofpolygonal vertices or NURBS CVs or subdivision surfaces.

n Use the Paint Skin Weights Tool to prevent a region from collapsing upondeformation.To control skin weights with more precision than shown in the lesson,you can modify skin weights numerically with the Window > GeneralEditors > Component Editor. If you smooth skin multiple surfaces whichhave been seamed together, there are many tool settings for the Paint SkinWeights Tool that make the task easier.

n Use an influence object to make an elbow stick out upon bending.Another common use of an influence object is to simulate a muscle bulgingduring joint rotation. The technique requires use of Set Driven Key to linkthe bulging influence object’s scale values to the rotation of the appropriatejoint. A brief example of this technique is in the Maya Help for SmoothSkin.

Skin weights and influence objects cannot overcome all modeling problems.For instance, if you further separate Jackie’s legs sideways, you will see anundesirable fold at the hips. This occurs because of the asymmetricalarrangement of polygonal edges in the hip region of the original model. Tofix the problem, you would need to detach the skin, alter the original model,then smooth bind the model again.

Maya has an alternative skinning method, rigid skinning, which gives resultssimilar to smooth skinning but requires use of different enhancement tools:flexor and lattice deformers. In general, smooth skinning gives more naturaldeformations with less effort than rigid skinning. If you skin multiple seamedsurfaces, however, processing is faster with rigid skinning than with smoothskinning.

Beyond the lesson | 329

Page 344: Autodesk Maya 2009

Smooth skinning is just one of the techniques for perfecting a character’sdeformations during animation. You can use Maya’s other deformers aloneor in addition to smooth skinning to achieve the results you want.

For more information, please refer to Smooth skinning in the Maya Help.

Lesson 3: Cluster and blend shape deformers

Introduction

Facial animation is an integral component of character animation. The faceof a character can be animated to impart a range of emotions and expressions.Maya has two deformation tools that ease character setup for facial animation:cluster deformers and blend shape.

Cluster deformers enable you to control a set of an object's points (CVs,vertices, or lattice points) with varying amounts of influence to create a targetshape for an animation.

A Blend Shape deformer provides an interface for blending between varioustarget shapes, to control the range of movement for the cluster on an objector face.

In this lesson, you will be introduced to cluster deformers in order to shapea characters mouth into a smile pose. You will learn to use the Blend Shapefeature so you can animate the face from a neutral pose to a smile. In thislesson, you learn how to:

n Select CVs in a region and create a cluster deformer.

n Use the cluster deformer handle to adjust the position of a cluster deformer.

n Use the Paint Cluster Weights Tool to refine the cluster weight values.

n Create a Blend Shape deformer to control the blending between targetshapes.

Open the scene for the lesson

In this lesson, you’ll work with a scene we created for your use.

1 Make sure you’ve done the steps in Preparing for the lessons on page 304.

330 | Chapter 7 Character Setup

Page 345: Autodesk Maya 2009

2 Open the scene file named ClusterBS.ma.

This file can be found in the GettingStarted directory that you set asyour Maya project:

GettingStarted/CharSetup/ClusterBS.ma

3 Select Shading > Smooth Shade All and then Shading > HardwareTexturing, and Lighting > Use All Lights to view the head fully textured(Hotkey 7).

Creating a target object for a blend shape

In the next steps, you duplicate the face of the head to create a target objectfor the blend shape. Later in the lesson, you apply a cluster to the duplicatedface (target object) so you can create a smile. The facial expression on thetarget object is what the original base object will match.

1 Using the Outliner, select only the face. That is, select only the headsurface without the eyes.

In the Outliner, the face is named baseFace and is indented under head.

2 Select Edit > Duplicate Special > . In the options window, select Edit> Reset Settings, turn on World for the Group Under option, then clickthe Duplicate Special button. By grouping the duplicate under the world,you create an object independent of the original.

Creating a target object for a blend shape | 331

Page 346: Autodesk Maya 2009

3 Move the duplicate face to a position where both faces are visible forcomparison, for instance, to the right side of head.

4 Rename the duplicate face as smilingFace.

This duplicate face will be modified so it can be used to influence theoriginal.

Creating a cluster deformer on a target object

In the next steps, you create a cluster deformer on the duplicated face (targetobject) to reshape the expression into a smile. The cluster deformer on thetarget object will be used to change the unsmiling baseFace (base object) intoa smiling face.

A cluster deformer creates a set whose members consist of selected points (CVs,vertices, or lattice points). You assign a percentage weight to each point,indicating how much you want each point to be affected by any translation,rotation, or scale of the cluster set. When you transform the cluster, the pointsare transformed according to the percentages you have specified. A cluster isuseful for stretching, moving, or compressing part or all of a surface.

To create a cluster deformer

1 Position the mouse pointer over the face. Right-click to select Vertex,then select the smilingFace vertices shown in the following illustration,which are roughly the vertices at the chin, cheeks, and lips (but not thenose):

332 | Chapter 7 Character Setup

Page 347: Autodesk Maya 2009

The region of selected vertices does not need to be exact. The objectiveis to select all vertices where a smile might deform the face. You mightwant to look in a mirror to see which parts of a face move while smiling.It’s better to select too many vertices than too few. It’s easier to workwith too many vertices than too few.

TIP An easy way to select the vertices is to use the Paint Selection Tool. First,right-click smilingFace in the scene view and select Vertex from the markingmenu. Next, select the Paint Selection Tool by double-clicking the icon inthe Toolbox to display the Paint Selection Tool settings.

In the settings window, set Radius(U) to 0.2. Drag the mouse over thedesired vertices to select them. Ctrl-drag (Windows and Linux) orControl-drag (Mac OS X) to cancel the selection of unwanted vertices.Close the Tool Settings window when you are done.

Make sure you don’t select vertices at the back of the head inadvertently.Also make sure you don’t inadvertently miss a few vertices in the regionyou select.

Creating a cluster deformer on a target object | 333

Page 348: Autodesk Maya 2009

2 Select Create Deformers > Cluster.

This puts the vertices into a cluster—a set of points you can move assingle entity. The cluster’s handle appears in the view as a C icon.

3 In the Outliner, make sure the cluster2Handle is selected.

4 Use the Move tool to drag the cluster handle up along its Y-axis a smallamount until smilingFace is deformed as follows:

The cluster set on smilingFace should be slightly higher than the clusteron the original face. This will become the basis for the blend shapedeformer.

Editing cluster weights

In this section you will use the Paint Cluster Weights Tool to further refinethe smilingFace. As you saw in previous steps, the points in a cluster movewhen you move the cluster handle. The distance a particular point movesdepends on its weight. Lower weights cause less movement, while higherweights cause exaggerated movement. In the next steps, you create a smileby editing the weights.

To edit cluster weights using the Paint Cluster Weights Tool

1 Select smilingFace.

334 | Chapter 7 Character Setup

Page 349: Autodesk Maya 2009

2 Select Edit Deformers > Paint Cluster Weights Tool > . This displaysthe smilingFace in grayscale.

The white area shows the points that make up the cluster. The whitenessalso indicates the weights—how much the points move in response tothe movement of the cluster handle. White indicates a cluster weight of1—the points move the same distance as the handle. By default, eachpoint has a weight of 1.

Black indicates a cluster weight of 0. The points do not move in responseto cluster handle movement. Note that regions that are not part of thecluster are also black.

Although there are no gray regions currently, gray means the movementis partial. The lighter the gray, the more the movement. Gray regionsindicate a cluster weight between 0 and 1.

3 In the Paint Attribute Section of the Tool Settings window, set thefollowing:n Paint Operation: Replace

n Value: 0.5

4 Click the Flood button.

This gives all the cluster points a weight of 0.5. The white region is nowgray:

Editing cluster weights | 335

Page 350: Autodesk Maya 2009

The selected vertices move down a bit, as the weight of 0.5 lessens theeffect of the prior movement of the cluster by 50%.

5 To check the shape with full-color shading, click the Select Tool. (Youmight also prefer to cancel the selection of smilingFace to eliminate thedisplay of the highlighted wireframe.)

6 To return to the Paint Cluster Weights Tool, select smilingFace and Edit

Deformers > Paint Cluster Weights Tool > again.

7 In the Tool Settings window, make these settings:

Radius(U): 0.1Opacity: 0.3Paint Operation: Replace Value: 1 The settingshave this effect when painting:

A Radius(U) of 0.1 sets the radius of the region affected by the stroke.The red circle icon on the face displays the radius.

An Opacity of 0.3 scales down the effect of painting weight values so youcan build up values gradually with repeated strokes.

A Replace operation paints the Value specified on the points stroked.

A Value of 1 sets the weight value you paint on the points.

8 Paint the region at the corners of the mouth with repeated strokes untilthe face looks roughly like the following figure. If your results differ fromthe figure significantly, undo the strokes and try again.

336 | Chapter 7 Character Setup

Page 351: Autodesk Maya 2009

While painting weights, it’s useful to intermittently check the shape withwith full-color shading rather than with the grayscale shading. To dothis, click the Select Tool to turn off the Paint Cluster Weights Tool. (Youmight also prefer to cancel the selection of smilingFace to eliminate thedisplay of the highlighted wireframe.)

9 Enter a Value of 0.25 and paint the central region above and below thelips as follows:

Because the corners of the mouth have a high weight and the centralregion around the lips have a low weight, the corners move up more inresponse to the prior positioning of the cluster handle. This creates asmiling mouth. The cheeks and chin have a medium weight, so they also

Editing cluster weights | 337

Page 352: Autodesk Maya 2009

move up slightly also. (For many people, skin at the chin and neck movesduring smiling.)

10 In the tool settings editor for the Paint Cluster Weights Tool, set the PaintOperation to Smooth. Paint any region where the surface has becomeirregular. Irregular regions are typically indicated by jagged wireframecurves (isoparms) or where a grayscale color makes an abrupt change toa lighter or darker color. Smoothing averages the weights of the strokedpoints with the weights of the surrounding region. The Value setting hasno effect on smoothing.

11 Replace and smooth weights in other regions of the face until you aresatisfied with the smile. For example, you might want to reduce the weightvalues at the side of the nose and immediately below the nose.

Your smilingFace should now have a slight smile as a result of your clusterweight edits.

12 Hide the Paint Attributes Tool settings window.

Creating a blend shape

In this section, you create a blend shape deformer to control the smile onbaseFace (base object) using the smilingFace (target object). A blend shapedeformer is ideal for facial animation, where you need a number of facialpositions to be readily available for use in an animation sequence. With ablend shape deformer, you can set up a character’s face to blend between asmile, frown, smirk, and so on.

In the next steps, you create a blend shape deformer to change the baseFaceinto the smile of smilingFace.

To create a blend shape deformer

1 In the Outliner, select smilingFace and shift-select baseFace, specificallyin this order.

The smilingFace (the first selection) is called the target object, whilebaseFace (the second selection) is called the base object. The objective ofa blend shape operation is to morph the base shape into the target shape.

2 Select Create Deformers > Blend Shape > .

3 In the Blend Shape node text box, type blendShape, then click Create.

338 | Chapter 7 Character Setup

Page 353: Autodesk Maya 2009

4 Select Window > Animation Editors > Blend Shape. This displays theBlend Shape editor, which has a slider for changing the base into thetarget shape, and buttons for setting keys.

5 Cancel the selection of the faces so you can see the surfaces without theobscuring highlighted wireframe.

6 Drag the slider from 0 to 1 to morph the baseFace into the target,smilingFace.

Note that you can click the Key button below the slider to set ananimation key for the shape of the face at the current frame. By settinga few keys with different slider values at different points in the timeline,you can animate from the neutral expression to a full or partial smile orvice versa.

When you key the shape, Maya applies the key to the blendShape nodethat was created when you selected Create Deformers > Blend Shape >

. If you need to select the blendShape node, for instance, so you cansee or delete the keys in the Time Slider, click the Select button in theBlend Shape editor.

Creating a blend shape | 339

Page 354: Autodesk Maya 2009

Refining deformation effects

The combination of a cluster and blend shape is ideal for facial animationbecause it lets you tune various subtle deformations. A few common techniquesfollow.

n In the box below the slider of the Blend Shape editor, you can enter anumerical value below 0 to invert the deformations, or above 1 to amplifythe deformations. For example, -1 creates a frown, while 1.6 creates abrimming smile:

n With or without changing the Blend Shape slider, you can move, rotate,and scale the cluster handle to modify the blend shape. The followingfigure shows some examples. The face you created will be slightly differentbecause your original smile is different.

n You can use the Paint Cluster Weights tool again to change cluster weightswhen the cluster and blend shape editing deforms certain regions

340 | Chapter 7 Character Setup

Page 355: Autodesk Maya 2009

undesirably or doesn’t give the exact look you desire. You can also use Ctrl- Z (Windows and Linux) or Control-z (Mac OS X) to undo any undesiredchanges.

Adding target objects to an existing blend shape

In the next steps, you duplicate the face again and reshape the duplicate intoa new facial expression. You then add the new face to the blend shape nodeto create another slider in the Blend Shape Editor.

To create another facial expression

1 Set the Blend Shape editor slider value to 0 to return baseFace to theposition it had at the beginning of the lesson.

2 Make a duplicate of baseFace, name it raisedBrow, and move it to the leftof baseFace so that all three faces are visible for comparison.

3 Make sure raisedBrow is selected.

4 In the perspective view, select Show > Isolate Select > View Selected. Selectthis menu item again in the front view.

This displays only the selected object (raisedBrow) in the views. This isnecessary to avoid selecting unwanted vertices in the next steps. Theview’s label indicates isolate is turned on.

5 In the front view, position the pointer over the face, right-click and selectVertex. Drag a selection box around the vertices in the region of theeyebrows and forehead as shown below.

Adding target objects to an existing blend shape | 341

Page 356: Autodesk Maya 2009

For these vertices, you need to select the vertices by dragging a selectionbox rather than by using the Paint Selection Tool. The eyebrows havevertices that lie behind its outer surface. The Paint Selection Tool selectsonly vertices at the outer surface. Dragging a selection box selects allvertices in the boxed region, including vertices that lie behind the outersurface.

6 In the side view, hold down the Ctrl (Windows and Linux) or Control(Mac OS X) key and drag a selection box around the vertices at the sideof the head to turn off their selection (see the following figure).

7 Switch to wireframe display mode and dolly the camera from variousclose-up views to make sure you select all the vertices on and under theeyebrow. If you miss a few vertices, subsequent deformations will notwork correctly. Also, make sure you don’t select vertices at the side orback of the head.

342 | Chapter 7 Character Setup

Page 357: Autodesk Maya 2009

8 Select Create Deformers > Cluster.

9 In the perspective view, turn off the selection of Show > Isolate Select >View Selected. Do this again in the front view.

By turning off these menu selections, Maya displays all objects in theviews again.

10 In the perspective view, drag the cluster up along its Y-axis a small amountuntil raisedBrow looks like the face on the left:

To add the new target object to the blend shape

1 In the Outliner, select raisedBrow and ctrl-select baseFace (the order ofselection is important). The raisedBrow is the target, while baseFace isthe base object.

2 Select Edit Deformers > Blend Shape > Add > . In the options window,turn on Specify Node and enter blendShape in the BlendShape Node box.Click the Apply and Close button.

When you created the blend shape for the smile, Maya created a nodenamed blendShape that contains the slider attributes that adjust theblend into the smilingFace target. The Add operation creates a blendshape for the raisedBrow and adds it to the blendShape node. This addsa slider to the node’s Blend Shape editor for adjusting the raised browdeformations.

3 To display the Blend Shape editor, select Window > Animation Editors> Blend Shape.

Adding target objects to an existing blend shape | 343

Page 358: Autodesk Maya 2009

4 You can use the sliders alone or in combination to create a smile withraised eyebrows, a frown with lowered eyebrows, and so on.

5 You can optionally select raisedBrow and edit the cluster weights to tunethe deformation of the eyebrow region as desired. See Editing clusterweights on page 334 for details. An example weighting follows:

344 | Chapter 7 Character Setup

Page 359: Autodesk Maya 2009

TIP After you create a blend shape, you can optionally hide or delete a targetobject (in this lesson, smilingFace and raisedBrow). If you delete a target, youimprove Maya processing time but lose the capability to manipulate thecluster handle. For versatility, many animators hide the target rather thandelete it. Hiding the target is necessary when you render the scene. It is alsouseful when you want to unclutter the scene view.

Beyond the lesson

In this lesson, you learned how to:

n Use two clusters and a blend shape deformer to manipulate facialexpressions.In professional productions, it’s common to create several more clusterswith a blend shape deformer for finer control of facial expressions. Forexample, you can create clusters for a number of mouth positions that youcan use to simulate the phonemes of speech.

When you used certain blend shape slider values, you may have noticedthat the face looked good in all regions except for a few vertices. To fixsuch regions, delete the cluster, move the problem vertices of the targetface to a better position, then create a blend shape for the improved targetface.

As much as possible, use a target shape that’s not extremely different fromthe base shape. If you need to use an extremely different target shape,create a blend shape with multiple targets. Each of the multiple targetsmust have a shape that is progressively more like the extreme target shape.

Beyond the lesson | 345

Page 360: Autodesk Maya 2009

Before you create the blend shape, turn on In-Between in the Create BlendShape options window, and select the multiple targets in this order: leastextreme shape difference first, most extreme shape difference last.

Although the lesson showed how to blend individual objects, you can alsoblend hierarchies of objects. See the Maya Help for more information.

There are some additional notes on clusters which are not explained in thislesson:

n You can add or remove vertices from a cluster with Edit Deformers > PaintSet Membership Tool.

n You can use the Component Editor to edit weight values more preciselythan by painting.

n Avoid changing the number of vertices (or CVs) for a surface after youapply a cluster or other deformer. Unexpected deformations may occur.

346 | Chapter 7 Character Setup

Page 361: Autodesk Maya 2009

Polygon Texturing

Introduction

Texture maps let you modify the appearance of your 3D models and scenes inMaya. Texture maps are images you apply and accurately position onto yoursurfaces using a process called texture mapping. When an image is texture mappedonto a surface, it alters the appearance of the surface in some unique way.Texture maps let you create many interesting visual effects:

n You can apply labels and logos to your surfaces.

n You can apply surface relief details and features to a surface instead of havingto model the details on the surface directly.

8

347

Page 362: Autodesk Maya 2009

n You can use illustrations as texture maps to create interesting backdropsin your scenes.

Most shading attributes for a surface material can be altered by a texture map.For example, color, specular, transparency, and reflectivity are examples ofattributes that can be modified by a texture map.

Texture mapping is a key component in the 3D production workflow. Manyproduction environments employ texture artists whose only role is to createand apply the texture maps to 3D models.

Preparing for the lessonTo ensure the lesson works as described, do these steps before beginning:

1 Select File > New Scene to create a new scene.

2 Make sure the Construction History icon (below the menu bar) is on:

(If it is turned off, it has a large X across it.)

3 If you have not already done so, copy the GettingStarted folder fromits installation location to your projects directory. Then, set theGettingStarted directory as your Maya project. For more information,see Copying and setting the Maya project on page 25.

4 Select the Polygons menu set. Unless otherwise noted, the directions inthis chapter for making menu selections assume you’ve already selectedthe Polygons menu set.

5 Make sure Display > UI Elements > Help Line is turned on. You will usethe Help Line while modeling.

6 Ensure that the interactive creation option for primitives is turned off byselecting Create > Polygon Primitives > Interactive Creation. The optionis off when a check mark does not display beside the item’s name in themenu.

7 Make sure that Soft Selection is turned off by opening the Attribute Editorwith the Select Tool active and unchecking the box marked Soft Select.

348 | Chapter 8 Polygon Texturing

Page 363: Autodesk Maya 2009

Lesson 1: UV texture mapping

Introduction

There are several techniques for texture mapping 3D surfaces depending onthe surface type (NURBS, polygons, subdivision surfaces). Some techniquesinvolve preparing the surfaces for texture mapping. For example, when texturemapping polygonal and subdivision surface types you need to understandhow textures are applied using UV texture coordinates.

UV texture coordinates, or UVs as they are more commonly called, aretwo-dimensional coordinates that reside with the vertex componentinformation for a 3D surface. UVs control the placement of a texture map ona 3D model by correlating the pixel position of the 2D texture map to thevertex positions on the model, so that the texture gets positioned (mapped)correctly.

For NURBS surfaces which have an inherent rectangular topology, the UVtexture coordinates are implicit. That is, the UVs reside in the same locationas the control vertices, so have a natural correlation to a rectangular shapedtexture map.

For polygonal and subdivision surface type models, which have an arbitrarysurface topology, the UVs can be explicitly created and modified to suit therequirements of the texture map.

Lesson 1: UV texture mapping | 349

Page 364: Autodesk Maya 2009

In this lesson you’ll learn the basic principles of UVs by applying (mapping)an existing image (texture) to a simple polygonal model and creating andmodifying the UV texture coordinates so that the texture map appears correctlyon the surface.

In this lesson you learn how to:

n Assign a 2D texture map to a polygonal model.

n Map UV texture coordinates (UVs) to a polygonal surface.

n Correlate the UVs between the scene view and the UV Texture Editor.

n Use the UV Texture Editor to visualize how the UV texture coordinatesfrom a three-dimensional model relate to an assigned two-dimensionaltexture map.

n Determine basic UV layout requirements.

n Set preferences to let you visualize the texture borders in both the UVTexture Editor and the scene view to better understand how the texturemap is placed on the polygonal model.

n Select and reposition UV texture coordinates within the UV Texture Editorusing the transformation tools to make the UVs match a pre-defined texturemap.

n Sew UV texture coordinates to existing UV shells.

Creating a cracker box model

You begin the lesson by creating a model of a cracker box using a polygonalcube primitive. The dimensions you’ll use for the cracker box are based on atexture map you’ll apply to the model in this lesson.

To create a cracker box model using a cube primitive

1 Select Create > Polygon Primitives > Cube > .

2 In the Polygon Cube Options window, select Edit > Reset Settings, setthe following options, and then click Create:n Width: 8

n Height: 10

350 | Chapter 8 Polygon Texturing

Page 365: Autodesk Maya 2009

n Depth: 3

n Width divisions: 1

n Height divisions: 1

n Depth divisions: 1

n Axis: Y

n Create UVs: On

n Normalize: Off

A cube primitive in the shape of a rectangular box appears in the sceneview.

When the Create UVs option is on it ensures that the primitive object iscreated with a set of default UV texture coordinates. All polygon primitivesin Maya provide an option for creating UV texture coordinates at thetime of creation.

3 Using the Channel Box, set the Translate Y attribute to 5 so that thecracker box is repositioned to rest on the X axis.

4 Rename the pCube1 primitive to: cracker_box.

Applying a texture map to a polygon mesh

In Maya, surfaces appear in a rendered image based on the shading materialsyou apply to them. The default shading material that gets assigned to surfacesprovides basic attributes such as color, transparency, and incandescence.

Applying a texture map to a polygon mesh | 351

Page 366: Autodesk Maya 2009

Depending on your final image requirements, you can enhance the visualimpact of an object by adding one or more texture maps to the assignedshading material. One basic texture map you can apply is a bitmap image alsoreferred to as a file texture. In this lesson, you apply a texture map we’ve createdfor your use on the cracker box.

For more basic information on shading materials and texture maps see theRendering chapter of this guide and the Maya Help.

To assign a shading material to the cracker box

1 In the scene view, select Shading > Smooth Shade All from the panelmenu.

This displays the cracker box with a default gray, smooth shading material,lit using default lighting. Turning on Smooth Shade All displays theassigned shading material you apply to the cracker box in the stepsfollowing.

2 In the scene view, right-click on any region of the cracker box and selectAssign New Material > Lambert from the marking menu.

A new Lambert shading material is created and assigned to the crackerbox. The Attribute Editor appears and displays the various attributes forthe new Lambert shading material.

352 | Chapter 8 Polygon Texturing

Page 367: Autodesk Maya 2009

The new Lambert material is identical to the default gray material thatwas previously assigned to the cracker box. However, it’s always a goodpractice not to modify the default shading material in the scene andcreate a new shading material and modify it to suit your requirements.

3 In Attribute Editor, double-click in the lambert2 box and then type:box_material to rename the shading material.

Renaming the shading material lets you easily identify it later on whenyou need to edit it. Naming items uniquely in Maya is a useful habit.

4 In the Attribute Editor, move the Color slider fully to the right so that thecolor box appears white.

The shading material assigned to the box model also updates in the sceneview so it appears in a brighter tone.

Applying a texture map to a polygon mesh | 353

Page 368: Autodesk Maya 2009

5 Click the Map button located to the right of the Color slider.

The Create Render Node window appears and lists the various textureoptions you can apply (or connect) to the color channel of the boxmaterial.

6 Click PSD File from the list of 2D Textures.

Choosing this option specifies that you want to apply an Adobe®

Photoshop® format file as a texture. A PSD format file lets you keep thevarious components of your texture map on multiple layers. This is usefulwhen you need the ability to edit a component of the texture duringproduction.

The Attribute Editor updates to display the options for the PSD Filetexture.

TIP If the Attribute Editor suddenly appears empty, it indicates that no objectsare selected in the scene. Simply select the box model again in the scene todisplay the attributes for the box.

7 Click the Browse button (folder icon) to the right of the Image Nameattribute to specify the image file for the texture map.

354 | Chapter 8 Polygon Texturing

Page 369: Autodesk Maya 2009

A browser window appears with the path set to the default projectdirectory. By default, Maya looks for source images for texture maps ina sourceimages folder whenever the project folder is set. Maya can usefile texture images from anywhere on your workstation or local network.For example, you can have images on a central disk drive that is sharedamong users in a production environment.

8 Select the image file named UVLesson.psd.

This file can be found in the GettingStarted directory that you set asyour Maya project:

GettingStarted/UVMapping/sourceimages

The image contains 2D artwork for the front, back, top, bottom, and sidesof the cracker box that was generated in Adobe® Photoshop®.

Applying a texture map to a polygon mesh | 355

Page 370: Autodesk Maya 2009

A small preview of the image appears in the Texture Sample box in theAttribute Editor.

When a texture is applied to a shading material its attributes get addedto the existing attributes for shading material. That is, all of the existingshading attributes remain unchanged except for the attribute that getsmodified by the texture. In this case, the grey color is substituted by theimage of the cracker box artwork.

9 In the scene view, select Shading > Hardware Texturing from the panelmenu to display the texture map on the cracker box model.

356 | Chapter 8 Polygon Texturing

Page 371: Autodesk Maya 2009

The texture map does not appear correctly on the cracker box model.The texture map was designed so that specific sides of the box receivespecific regions of the image. Instead, the complete image is being placedon every side of the object.

To correct this problem you must modify the default UV texturecoordinates for the model so they match the layout of the texture image.To do this, you use the UV Texture Editor.

Viewing UVs in the UV Texture Editor

The UV Texture Editor lets you view and interactively edit the UV texturecoordinates for polygon and subdivision surface types. UVs appear laid flatwithin the UV Texture Editor’s 2D view. It also lets you display the 2D imagefor the texture map in relation to the UVs. These features are critical foraccurate and efficient placement of texture maps on polygon and subdivisionsurface types.

In this lesson, your goal is to ensure that the shape and placement of the UVsmatch the image as it appears in the 2D view of the UV Texture Editor. Thiswill ensure that the map appears correctly on the cracker box model in the3D scene view.

To open the UV Texture Editor in a two pane layout

1 In the scene view, right-click any of the Quick Layout buttons on theToolbox to display the pop-up menu of Quick Layout shortcuts and selectPersp/UV Texture Editor from the list.

Viewing UVs in the UV Texture Editor | 357

Page 372: Autodesk Maya 2009

The panel layouts update to display the Perspective view in the left paneand the UV Texture Editor in the right pane simultaneously. (You canclose the Attribute Editor if it is still displayed.)

This two pane layout is helpful for two reasons:

n The two view layout shows you how one item selected in the 3D viewrelates to the UVs displayed in the 2D view of the UV Texture Editorand vice versa, without having to open and close the views repeatedly.

358 | Chapter 8 Polygon Texturing

Page 373: Autodesk Maya 2009

n When you edit UVs for a surface mesh in the UV Texture Editor, youcan immediately see the effect of the texture map on the model inthe 3D scene view.

UVs do not initially appear in the 2D view of the UV Texture Editor until youselect an object or change the selection mode for an object in the scene view.

To view UVs in the UV Texture Editor

1 In the scene view, right-click any region of the cracker box model andselect Object Mode from the marking menu.

2 Select the cracker box model.

3 In the UV Texture Editor, dolly the view outwards so you can see the UVsfor the cracker box as shown below. (To dolly, press the Alt key and dragthe mouse to the left while holding down the right button on yourmouse.)

The UV texture coordinates for the cracker box model appear in the 2Dview of the UV Texture Editor as a flattened, two-dimensionalrepresentation. The UVs appear highlighted with lines connecting theUVs to indicate the region of the texture the UVs represent.

The image you specified as the texture map for the box also appears inthe 2D view of the UV Texture Editor in the upper right quadrant of the2D cartesian graph called the UV image range or UV Texture Space. Thecoordinates for this quadrant range from 0,0 to 1,1 and represent thetexture space for the surface. How the UVs appear in this quadrant in

Viewing UVs in the UV Texture Editor | 359

Page 374: Autodesk Maya 2009

relation to the displayed image has a direct bearing on how the texturegets mapped onto the surface.

TIP If the texture map for the cracker box doesn’t appear in the 2D view,select Image > Update PSD Networks in the UV Texture Editor to refresh the2D view of the UV Texture Editor. Update PSD Network is normally used torefresh a PSD texture in Maya after you have modified the PSD texture inAdobe® Photoshop®.

In this example, the UVs for the cracker box appear like a box where allsix sides have been cut open and then unfolded flat.

The texture map does not appear correctly on the cracker box for anumber of reasons:

n The UVs for the cracker box extend well beyond the default 0 to 1UV range for the texture map in the 2D view of the UV Texture Editor.As the texture map displays within the 0 to 1 range, the UVs shouldalso be positioned to fit within the 0 to 1 UV range, in most cases.Otherwise, the texture map repeats on the surface mesh, as it does inthis case.

n The position of the UVs do not match the specific regions of the imagewe’ve provided for the texture map. The regions of the image showthe front, back, top, bottom, and sides of the box. The UVs shouldspecifically match these regions to display the texture correctly. UVsdo not automatically align themselves to a texture, you must manuallyreposition them.

n The shape of the UVs don’t match the aspect ratio of the cracker boxmodel in the scene view: -10 (Height) X 8 (Width) X 3 (Depth). This

360 | Chapter 8 Polygon Texturing

Page 375: Autodesk Maya 2009

is because the default UVs for a Maya cube primitive are created basedon a predetermined default shape and do not get updated if the shapeor scale of the primitive is modified later on.

There are a number of things you can do to correct these issues depending onthe situation. For this lesson, you will correct the UV and texture mapmisalignment by doing the following:

n Map a new set of UVs for the cracker box model that better matches theindividual faces of the cracker box. (While the existing UVs could bemodified, you’ll learn how to create new UVs in this lesson that will bettermatch the size and scale of the 3D model.

n Ensure the new UVs fit within the 0 to 1 UV range in the UV TextureEditor.

n Reposition the UVs so that they correlate to specific locations on the 2Dimage using the UV Texture Editor. This will ensure that the various sidesof the box receive the correct regions of the texture map.

Mapping UV texture coordinates

It is often necessary to create new UVs for a surface mesh in order to texturemap it correctly. These situations include:

n Texture mapping a surface that doesn’t have existing UVs.This can occur when you import 3D models from other softwareapplications that don’t create UVs.

n When the UVs for a surface are badly jumbled or are missing some UVs.This can occur when a surface has been edited or modified in some wayand it becomes hard to determine what UVs may be missing as a result.

n When you need a unique set of UVs for a particular purpose.For example, if you want to paint a texture map directly onto a 3D surface,you may want to map UVs that allow you to paint using the 3D paint toolsin Maya. Alternatively, you may want to create a unique set of UVsspecifically for baking textures or light maps.

Maya lets you create UVs for polygonal and subdivision surfaces using a processcalled projection mapping, also referred to as mapping UVs. Maya provides severalprojection mapping types that map what gets viewed by a particular projection

Mapping UV texture coordinates | 361

Page 376: Autodesk Maya 2009

to a flat 2D view that can be subsequently correlated to your texture mapusing the UV Texture Editor.

In this lesson, you use a feature called Automatic Mapping to create new UVsfor the cracker box model. Automatic mapping lets you specify the numberof planes that will be used for the UV projection.

Automatic Mapping is normally used when mapping UVs that require multipleprojections of organic shaped models as it has the advantage of producingUVs that are proportional in scale to the world space area of the mesh facesof the surface.

Automatic mapping is useful when your mapping requirements are fornon-overlapping UVs which fit within the 0 to 1 texture space, but which donot have to be contiguous; for example, when using the 3D Paint tool, Maya®

Paint EffectsTM, Maya® FurTM or Maya® HairTM.

You use Automatic Mapping in this lesson because it can produce a UVprojection from three planar directions simultaneously which makes it a goodchoice for the shape of the cracker box model. That is, you can map UVs forthe front and back, top and bottom and the two sides in one operation. Thisprojection type is referred to as a triplanar projection.

To map UVs using Automatic Mapping

1 In the perspective view, select the cracker box as an Object.

2 From the Polygons menu set, select Create UVs > Automatic Mapping >

.

The Automatic Mapping Options window appears.

3 In the Automatic Mapping Options window, select Edit > Reset settings,set the following options, and then click Project:n Planes: 3

n Percentage Space: 2

362 | Chapter 8 Polygon Texturing

Page 377: Autodesk Maya 2009

Setting Planes to 3 creates UVs based on projections from three separatedirections. Setting the Percentage Space option to 2 sets the size of thespace that appears between each of the separate UV projections whenthey are laid out in the UV Texture Editor.

When the projection is complete the new projected UVs from the triplanarprojection appear in the UV Texture Editor.

NOTE Whenever a UV projection is performed on a surface, any existing UVsfor the surface get replaced by the UVs from the new projection. To avoidreplacing existing UVs you can explicitly save the UVs in a UV set. For moreinformation on UV Sets see the Modeling guide in the Maya Help.

4 In the UV Texture Editor, dolly the view so it shows only the 0 to 1 UVrange area that displays the image for the texture map and the new UVs(as shown below).

5 In the UV Texture Editor, select Image > Dim Image.

Mapping UV texture coordinates | 363

Page 378: Autodesk Maya 2009

The intensity of the image map is reduced so you can view the UV borderson the projected UVs more easily. The new UVs appear in the UV TextureEditor as shown below.

n The six rectangular UV shapes, referred to as UV shells or simply shells,now match the aspect ratio for each of the six sides of the cracker boxbetter than the earlier UVs.

n The UV shells fit within the 0 to 1 UV texture range. Automaticmapping fits the UVs to the 0 to 1 range by default.

The texture map still does not appear correctly on the cracker box becausethe UV shells need to be repositioned so they align with the correspondingcomponents of the image map.

While the shape of each UV shell is now recognizable as being associated withthe cracker box, it is not apparent which components in the UV Texture Editorcorrespond to a particular face on the cracker box.

In the next section you learn how to select and reposition the UV shells sothey better match the image for the texture map.

364 | Chapter 8 Polygon Texturing

Page 379: Autodesk Maya 2009

Working with UVs in the UV Texture Editor

When texture mapping a polygon or subdivision surface type model it is oftennecessary to modify the UV components for a model so they match the texturemap. The UV Texture Editor provides many tools for working with UVs. Inthis section you learn how to:

n Select UVs from either the scene view or the UV Texture Editor andaccurately correlate them. Selecting UV components is critical to modifyingthem accurately.

n Sew UV shells together to reduce the number of UV components you needto work with.

n Move and rotate UVs within the UV Texture Editor to make the UV shellsalign to the cracker box texture map.

Selecting UV components

You can select UV components from either the scene view or within the UVTexture Editor. Displaying both the 3D scene view and the 2D view of the UVTexture Editor lets you easily correlate which UV components are associatedwith a particular edge or vertex on the 3D model.

This is very helpful to understand the layout and orientation of your UVtexture coordinates in relation to the image used for a texture map and howthe map appears on the model in the 3D scene view.

To select UVs for a 3D model in the scene view

1 In the UV Texture Editor, select Image > Display Image to turn off thedisplay of the texture image.

Display Image works by turning the display of the assigned texture onor off in the 2D view of the UV Texture Editor. Turning the image offtemporarily aids in viewing only the UV components. This will be usefulin the steps that follow.

Working with UVs in the UV Texture Editor | 365

Page 380: Autodesk Maya 2009

2 In the scene view, right-click on the cracker box model and select UVfrom the marking menu that appears.

3 In the scene view, select one UV on any corner of the cracker box.

Selecting a UV is very similar to selecting a vertex on an object. That is,you select a point that resides in exactly the same position as the vertex.When you select a UV in the scene view, the corresponding UV is alsoselected in the UV Texture Editor.

NOTE If more than one UV gets selected in the UV Texture Editor when youselect a UV in the scene view it indicates that multiple UV components sharethe same UV on the 3D model (similar to how polygon faces share commonvertices). This is important to remember when you move one of these UVcomponents in the UV Texture Editor and other UVs also move.

4 In the scene view, right-click on the cracker box model and select Edgefrom the marking menu that appears.

5 In the perspective view, select the top front edge of the cracker box.

366 | Chapter 8 Polygon Texturing

Page 381: Autodesk Maya 2009

When you select this edge in the scene view, notice that twocorresponding shell edges also get selected in the UV Texture Editor. Thisindicates the following:

n The selected edge is shared by two faces; the front and the top.

n Selecting the top front edge in the scene view, identifies thecorresponding front and top UV shells for the box. (Indicated by theselection in the UV Texture Editor.)

This is useful when you need to understand how the various UV shellsrelate to each other, especially when you have many UV shells for a modelin the scene; for example, when you sew two UV shell edges together.

In the steps that follow you select edges in the UV Texture Editor so you cansew them together.

Sewing UVs

Sewing UV shells together merges the UV shells along a shared edge that youspecify. Sewing UVs is useful for the following reasons:

n You can move and modify the UV shells as larger contiguous texture units.This makes it more efficient to match the UVs to the texture in manysituations.

n Texture maps can appear more uniform across texture borders when thetexture is applied to one or more sewn UV shells compared to manyseparate UV shells. Sewing shells together reduces the chance that anunwanted texture mismatch occurs along the texture edge.

To sew shell edges together in the UV Texture Editor

1 In the scene view, ensure that only the top front edge of the cracker boxis still selected.

When the top front edge is selected in the scene view, the top edge ofone of the large UV shells is also selected as well as the left side of themiddle UV shell in the top row of the UV Texture Editor. For the crackerbox texture map, you need to sew these together so they correlate to themap correctly.

Working with UVs in the UV Texture Editor | 367

Page 382: Autodesk Maya 2009

2 In the UV Texture Editor, select Polygons > Move and Sew UV Edges.

The small rectangular UV shell is repositioned to match the top of thelarge UV shell and the two shells are combined into one. When you laterselect and move this sewn shell, it will move as one piece. When two UVshells are selected for sewing, the smallest UV shell is moved to the larger.

3 Repeat steps 1 and 2 for the remaining three edges on front face of thecracker box keeping in mind the following:n Select only one edge at a time in the scene view.

n When you’ve completed the move and sew operation, your UV TextureEditor should show the front UV shell with the corresponding top,bottom, and side shells sewn to it. When fully complete, you willhave only two UV shells to match to the texture image for the crackerbox.

368 | Chapter 8 Polygon Texturing

Page 383: Autodesk Maya 2009

4 To display the texture borders for the two shells, select Texture BorderEdges. (You can also launch this window by right-clicking the ToggleTexture Borders button on the UV Texture Editor’s toolbar.)

In the UV Texture Editor, the texture borders for two UV shells nowappear with a thicker line.

Displaying texture borders on the UV shells is useful for visualizing where thetexture borders exist on the 3D model in the scene view. That is, any portionof the texture image that appears outside of the texture border will not appearon the surface. It is particularly useful for troubleshooting texture mismatcheswhen they occur. Displaying the texture borders can also help to identify

Working with UVs in the UV Texture Editor | 369

Page 384: Autodesk Maya 2009

which UV shells are combined and which shells are not when you have manyUV shells displayed in the UV Texture Editor.

If you want to be able to view areas where UV shells overlap in the UV TextureEditor select Image > Shade UVs. When Shade UVs is turned on any selectedUV shells appear shaded in a semitransparent fashion. Areas where the shadingappears more opaque indicate the regions of shell overlap.

In the steps that follow, you reposition the two UV shells in the UV TextureEditor so they coincide with the texture image.

Moving UV components

You manually reposition UV components in the UV Texture Editor using thetools within the Toolbox. To reposition an individual UV component youmust first select it before selecting the Move Tool. To reposition an entire UVshell you must first select one individual UV from the shell it belongs to andthen convert the selection to a shell before using the Move Tool.

To move UVs in the UV Texture Editor

1 In the UV Texture Editor, select Image > Display Image.

The texture image displays in the 2D view of the UV Texture Editordimmed, as before. You need the image displayed so you can accuratelyreposition the two UV shells. Dimming the image aids in seeing theselected UVs.

2 In the UV Texture Editor, right-click and select UV from the markingmenu that appears.

3 In the UV Texture Editor, select one UV on the UV shell you sewed earlierin the lesson.

The UV coordinate appears highlighted in the 2D view.

4 Convert the selection to a UV shell by pressing the Ctrl key andright-clicking in the 2D view of the UV Texture Editor. Choose To Shellfrom the marking menu that appears.

The selection changes from a single selected UV to selecting the entireUV shell.

5 From the UV Texture Editor menu, select Tool > Move UV Shell Tool >

.

370 | Chapter 8 Polygon Texturing

Page 385: Autodesk Maya 2009

6 In the Move UV Shell Tool options window, turn off the Prevent overlapoption which prevents UV shells from being moved so they overlap andthen select Apply and Close.

The Move Tool manipulator icon appears over the selected UV shell.

7 Drag the green (Y axis) and red (X axis) Move Tool manipulator handlesto reposition the UV shell so it matches the displayed texture image.

The position of the texture updates on the cracker box model in the sceneview as you do this.

8 Select one UV on the other remaining UV shell.

The UV coordinate appears highlighted.

9 Convert the UV selection to a shell selection by pressing the Ctrl key andright-clicking in the UV Texture Editor. Choose To Shell from the markingmenu that appears.

The selection changes from a single selected UV to selecting the entireUV shell.

10 In the UV Texture Editor’s toolbar, click one of the Rotate UVs buttonsto rotate the UV shell so it appears in the same orientation as the textureimage. (Click the other Rotate UVs button to rotate it in the oppositedirection.)

Working with UVs in the UV Texture Editor | 371

Page 386: Autodesk Maya 2009

11 Confirm that the texture appears correctly on the cracker box model inthe scene view by tumbling the scene so you can view the back of thebox.

TIP If the texture appears upside down, you can continue to rotate it another180 degrees. If the texture appears reversed, that is, the letters are backwards,you can correct this by selecting Polygons > Flip from the UV Texture Editormenu and choosing the appropriate option setting.

12 From the UV Texture Editor menu, select Tool > Move UV Shell Tool.

A move manipulator icon appears over the selected UV shell.

13 Drag the green (Y axis) and red (X axis) manipulator handles to repositionthe UV shell so it matches the displayed texture image.

The texture map should now appear correct on all sides of the crackerbox when you’re finished.

TIP You can confirm that the UV shells are positioned accurately by dollyingin closer on the 2D view of the UV Texture Editor. If a minor correction isrequired, simply select and move the UVs or move the entire UV shell.

372 | Chapter 8 Polygon Texturing

Page 387: Autodesk Maya 2009

TIP The exact UV boundaries can be viewed more clearly when theanti-aliasing for the texture image is temporarily turned off. To do this, selectImage > Display Unfiltered to view the texture image without anti-aliasing.

If you need to move a single UV so it precisely matches a particularlocation on the texture map you can turn on Pixel Snap (Image > PixelSnap). When you select and move the UV using the Move Tool, it willreposition the UV coordinate based on pixel boundaries.

Beyond the lesson

In this lesson you were introduced to a few of the basic techniques requiredto assign and accurately position texture maps on polygonal models using UVtexture coordinates:

n UV coordinates are essential for applying and accurately positioning texturemaps on polygonal and subdivision surfaces.

n UVs can be explicitly created for a surface mesh using a variety of UVmapping techniques. (Planar mapping, spherical mapping, cylindricalmapping, and Automatic mapping.)

n UVs are represented as 2D coordinates and are viewed and edited withrespect to the 2D texture map using the UV Texture Editor. The UV TextureEditor provides many other tools for editing UVs.

n UVs are usually positioned to fit within the 0 to 1 UV coordinate spaceunless the texture map requirements are such that the map needs to repeatacross the surface mesh.

n It is useful to display both the 3D scene view and the 2D UV Texture Editorsimultaneously when texture mapping so that a correlation between the3D model and 2D UV coordinates can be made.

n You can visualize texture borders using Texture Border Edges.

n You can view the regions where UVs overlap each other in the UV TextureEditor by selecting the UV shells and selecting Image > Shade UVs.

You can open the PSD file you used in this lesson using Adobe® Photoshop®

to learn how layers were used for the texture map. You can edit one or moreof the layers to experiment with how the texture can be modified. After you

Beyond the lesson | 373

Page 388: Autodesk Maya 2009

modify and save the file in Photoshop®, remember to select Image > UpdatePSD Network in the UV Texture Editor so the texture map gets updated onthe model in the Maya scene.

If you would like to learn how to render an image of the cracker box modelsee the Rendering chapter of this guide as well as the Maya Help to learn moreabout lighting, shading, and rendering.

This lesson used a simple polygonal model to introduce the fundamentalconcepts. When you work with more complex polygonal and subdivisionsurface models, you can also:

n layout overlapping UV shells that occur as a result of UV projectionmapping to ensure they fit within the 0 to 1 texture space using Edit UVs> Layout.

n maximize the use of texture space by forcing the UV borders to be mappedto the full area of the 0 to 1 UV texture range using Edit UVs > Map UVBorder

n align UVs to one another or snap them to the grid in the 2D view

n untangle a UV mesh that contains overlapping UVs using Edit UVs > Relax.

n modify a group of selected UVs using UV Lattice and UV Smudge tools

In general, you should begin texturing a model only after the model is fullycomplete. Otherwise, changes to the model may affect the associated UVtexture coordinates which in turn will affect how the texture appears on themodel.

In this lesson you matched the UVs to an existing texture image. Many textureartists create good UV layouts for their models prior to creating the actual 2Dimages for their texture maps. This is done only after the model is fullycomplete.

You can export a bitmap image of the 2D view of the UV Texture Editor touse as a guide for painting a texture in your favorite image creation software.In the UV Texture Editor, select Polygons > UV Snapshot to export the image.

If you use Adobe® Photoshop® for image creation and editing you can createa UV snapshot in a .PSD file format that creates the UV image on a separatelayer. To create the .PSD format file while working in the UV Texture Editor,select Image > Create PSD Network.

If you want to learn more about a particular tool or feature that was used inthis lesson, please refer to the Maya Help.

374 | Chapter 8 Polygon Texturing

Page 389: Autodesk Maya 2009

Rendering

Introduction

In Maya, rendering refers to the process of creating bitmap images of your scenebased on the various shading, lighting, and camera attributes that you set.

When rendering, Maya takes into account all of the various objects and sceneattributes, and performs mathematical calculations to produce the final imageor image sequence. Once you render a sequence of images, you can then playthem back in sequence, producing an animation.

Rendering involves many components to produce an image:

n Shading materials and textures

9

375

Page 390: Autodesk Maya 2009

n Lighting and shadows

n Cameras and animation

n Rendering method

n Visual effects

In Maya, rendering can be accomplished using software (Maya SoftwareRenderer, mental ray® for Maya® Renderer, or the Maya® Vector Renderer) orhardware rendering methods. Each type has its distinct advantages. Whichrenderer you decide to use will be determined by your image requirements(that is, the look you require) and time constraints.

Software rendering generally allows you to create more precise results but cantake longer to produce each frame or image. The Maya software render typeuses a process for scene illumination that directly illuminates objects in thescene or simulates illumination by reflecting neighboring objects in the sceneor via texture mapping the effect on the object.

The mental ray® for Maya® software render type additionally provides a featurecalled Global Illumination: a process that simulates the effect of indirectlyilluminating objects that are not receiving direct illumination. It can alsosimulate light effects known as caustics. Hardware rendering is generally fasterbut is less capable of producing detailed results. In addition, some visual effectscan only be produced via one method; at times, a combination of more thanone type of rendering method may be required.

Rendering usually requires several iterations to achieve the final image thatmeets your requirements. The key is to strike the balance between producingthe image that meets your requirements and producing it in the time required.This is particularly important if you are using Maya in a production setting.

This chapter introduces you to some of the fundamental concepts and skillsrelated to rendering. This chapter includes the following lessons:

n Lesson 1 Rendering a scene: Introduction on page 377

n Lesson 2 Shading surfaces: Introduction on page 404

n Lesson 3 Lights, shadows, and cameras: Introduction on page 423

n Lesson 4 Global Illumination: Introduction on page 440

n Lesson 5 Caustics: Introduction on page 458

376 | Chapter 9 Rendering

Page 391: Autodesk Maya 2009

Preparing for the lessons1 If you have not already done so, copy the GettingStarted folder from

its installation location to your projects directory. Then, set theGettingStarted directory as your Maya project. For more information,see Copying and setting the Maya project on page 25.

2 To ensure the lessons work as described, select the Rendering menu set.Unless otherwise noted, the directions in this chapter for making menuselections assume you’ve already selected the Rendering menu set.

Lesson 1: Rendering a scene

Introduction

This lesson provides a brief introduction to rendering in Maya. In this lesson,you learn how to:

n Assign shading materials to surfaces in the scene.

n Edit the color of shading materials.

n Apply simple textures to shading materials.

n Render both a single image and a sequence of images for an animation.

n Use Interactive Photorealistic Rendering (IPR) to perform test renders ofthe scene.

n Edit the Render Settings attributes to change the quality of the final resultsof an image.

n View a sequence of rendered frames for an animation.

Preparing for the lessons | 377

Page 392: Autodesk Maya 2009

Open the scene for the lesson

In this lesson, you render a scene we’ve created for your use.

1 Make sure you’ve done the steps in Preparing for the lessons on page 377.

2 Open the scene file named apple.mb.

This file can be found in the GettingStarted directory that you set asyour Maya project:

GettingStarted\Rendering\apple.mb

The scene contains an apple sitting on a plane, with another plane as thebackground. A camera in the scene is animated to revolve around theapple at varying distances. (As an alternative to using the scene apple.mb,you can create a similar scene with your own objects.)

3 Select Window > Settings/Preferences > Preferences.

4 Click the Time Slider category and make sure the Playback Speed optionis set to Real-time (24 fps) so your animation will playback at the defaultrate of 24 frames per second.

5 Close the Preferences window.

You won’t use the animated camera until later in the lesson. In the nextsteps, you color the apple and the planes by creating shading materials.

378 | Chapter 9 Rendering

Page 393: Autodesk Maya 2009

Creating shading materials for objects

A shading material is a collection of attributes that you apply to a surface tocontrol how the surface appears when it is rendered. Shading materials includesuch attributes as color, shininess, and texture. The following table outlinesthe materials you’ll be working with:

DescriptionMaterial

Creates a matte surface without specularhighlights. Lambert is the default shadingmaterial.

Lambert

Creates a shiny surface with specularhighlights, often used to simulate metallicsurfaces.

Blinn

When you open the apple.mb file, it initially displays the apple and the planesas wireframes (Shading > Wireframe). This is the default display mode forobjects in a scene view.

To create materials for the apple stem

1 In the perspective view, select Shading > Smooth Shade All (hotkey: 5).

Creating shading materials for objects | 379

Page 394: Autodesk Maya 2009

The apple and the other surfaces appear with a default gray, smoothshading material, lit using default lighting. Default lighting occurs whenno other lights have been placed in the scene.

2 In the perspective view, select the apple stem by clicking its geometry.(Be sure that only the apple stem is selected.)

3 From the Rendering menu set, select Lighting/shading > Assign NewMaterial.

The Attribute Editor appears for the Lambert material.

A Lambert material creates a matte surface without shiny highlights. Youwill learn more about materials and their attributes in a later lesson.

380 | Chapter 9 Rendering

Page 395: Autodesk Maya 2009

4 Click the gray box to the right of Color.

The Color Chooser window appears.

5 Click inside the color wheel and drag to a brown color.

The color you select in the Color Chooser is applied to the apple stem.

6 Click Accept to close the window.

7 In the Attribute Editor, rename the lambert shading material toappleStem_lambert.

To create materials for the apple

1 Right-click the apple and select Assign New Material > Blinn from themarking menu.

The Attribute Editor updates to display the attributes for the Blinnmaterial.

A Blinn material gives the apple a shiny appearance.

2 Click the gray box to the right of Color.

The Color Chooser window appears.

3 Click inside the color wheel and drag to a red color.

Creating shading materials for objects | 381

Page 396: Autodesk Maya 2009

The apple’s surface updates to the same color you select in the ColorChooser.

4 Click Accept to close the window.

5 In the Attribute Editor, rename the Blinn shading material toappleSkin_blinn.

To create materials for the counter and wall

1 Right-click the background plane and select Assign New Material >Lambert from the marking menu.

The Attribute Editor displays the attributes for the Lambert material.

2 Click the gray box to the right of Color.

3 In the Color Chooser window, click inside the color wheel and drag toa light blue color.

The color you select in the Color Chooser is applied to the plane.

4 Click Accept to close the window.

5 In the Attribute Editor, rename the Lambert shading material towall_lambert.

6 Right-click the surface that the apple is resting on and select Assign NewMaterial > Lambert.

The Attribute Editor displays the attributes for the Lambert material.

7 Click the gray box to the right of Color.

8 In the Color Chooser window, click inside the color wheel and drag toa beige color.

The color you select in the Color Chooser is applied to the plane.

9 Click Accept to close the window.

10 In the Attribute Editor, rename the Lambert shading material tocounter_lambert.

382 | Chapter 9 Rendering

Page 397: Autodesk Maya 2009

The counter, wall, and apple stem all have a matte Lambert surface, whilethe apple has a shiny Blinn surface. There are many other attributes youcan set to change the appearance of these objects, which you’ll explorein the next section.

Refining shading materials for objects

You can refine the shading materials in the scene to make the objects appearmore realistic. In the next steps you connect (or apply) a procedural texture tothe counter, and a ramp texture to the apple. These textures are connected tothe color attribute of the shading material for each surface to provide naturalsurface variation. When you connect textures, you create shading networks.You’ll learn more about shading networks in a later lesson.

A procedural texture is a 2D or 3D texture calculated based on an algorithmor mathematical formula. It can be useful for creating random patterning. Aramp texture is a 2D texture or color gradient in which the color or grayscalevalue changes across the image.

To connect a procedural texture to the counter surface

1 In the perspective view, right-click the counter surface and select MaterialAttributes.

The Attribute Editor for the counter_lambert material appears.

Refining shading materials for objects | 383

Page 398: Autodesk Maya 2009

2 To the right of the Color slider, click the Map button

The Create Render Node window appears and lists the various texturesyou can connect to the color attribute of the Lambert material assignedto the counter surface.

3 In the Create Render Node window, scroll through the list of textures,and from the list of 3D Textures, click Granite.

The procedural texture gives the counter the look of a stone granitecounter top when it is rendered, and provides the context for the scene.

4 Press 6 to see a shaded and textured display of the granite texture on thecounter top surface.

5 In the Attribute Editor, under Granite Attributes change the Filler Colorfrom the default reddish-brown to a beige color as follows:n Click the color box to the right of Filler Color.

384 | Chapter 9 Rendering

Page 399: Autodesk Maya 2009

n In the Color Chooser window, select a beige color and click Accept.

NOTE Materials and textures displayed in the perspective view do notshow their true appearance. To see the accurate appearance of the textureyou must render the scene.

To connect a ramp texture to the apple surface

1 Right-click the apple and select Material Attributes from the markingmenu.

The Attribute Editor updates to display the appleSkin_blinn materialproperties.

2 To the right of the Color slider, click the Map button.

The Create Render Node window appears and lists the various texturepatterns you can connect to the Color attribute of the Blinn materialassigned to the apple.

3 From the list of 2D textures, click Ramp.

Refining shading materials for objects | 385

Page 400: Autodesk Maya 2009

This texture creates a gradation through a series of selected colors.Applying the ramp texture provides the apple with a realistic variationin surface color.

4 In the Attribute Editor, under Ramp Attributes, change the Type to URamp.

The Ramp Type indicates the direction of the color gradient. A U rampapplies the gradient in a linear, vertical direction across the object.

5 Add another color component by clicking within the ramp.

A new set of color handles appears in the ramp, for a total of four colorcomponents.

386 | Chapter 9 Rendering

Page 401: Autodesk Maya 2009

6 To change the ramp colors, click the top circular color handle (to indicatewhich color you want to modify), then click the color box to the rightof Selected Color to display the Color Chooser window.

7 Click inside the color wheel and drag to a very dark brown for the firstramp color. Click Accept to close the window.

8 Repeat steps 6 and 7 for the other three ramp colors. For the two middleramp colors, select a dark red. For the last ramp color, select a deep olivegreen.

9 Click Accept to close the window.

10 Use the circular color handles to reposition each component as shownbelow:

Refining shading materials for objects | 387

Page 402: Autodesk Maya 2009

The position of these handles and the corresponding colors affect thelocation and breadth of the color within the gradient on the apple’ssurface.

11 Save your work.

In the next section you render your scene to view the textures andmaterials you’ve assigned to the objects.

Maya renderers

So far, you’ve seen the results of shading the apple and other surfaces in thescene view. In this view, Maya uses your computer’s graphics hardware todisplay the shading and textures quickly but with low quality.

To view the shading results of the colors and textures in a more realisticfashion, you must use a renderer. In this lesson you use a process called softwarerendering.

Software rendering can take seconds or minutes to render a single frame ofanimation from your scene, depending on the complexity of surface geometry,shaders, lighting and other visual elements present in the scene.

The following table outlines the different types of renderers in Maya and whateach is used for:

UseRenderer

A general purpose renderer with broadcapabilities. You can produce high-quality

Maya’s Software renderer

images with complex shading networks,including procedural textures and ramps.Software rendering is computed throughyour machine’s processor.

388 | Chapter 9 Rendering

Page 403: Autodesk Maya 2009

UseRenderer

A feature of Maya’s software renderer, usedto make interactive adjustments to the final

Interactive Photorealistic Rendering (IPR)

rendered image. You can adjust shadingand lighting attributes in real-time, and IPRautomatically updates the rendered imageto show the effects of your changes. IPR isuseful for tweaking an image before render-ing to disk.

A general purpose renderer that includesexclusive, advanced rendering functional-

mental ray® for Maya® renderer

ity, such as host and network parallel ren-dering, area light sources for soft shadows,global illumination, and caustics (lightpatterns).

A specialized renderer used to producestylized renderings (for example, cartoon,

Maya Vector renderer

tonal art, line art, hidden line, wireframe)in various bitmap image formats (IFF, TIFF)or in 2D vector formats (SWF, AI, EPS,SVG). The Maya Vector renderer is oftenused to render web-ready images.

A general purpose renderer that uses yourmachine’s graphics card for computation.

Maya’s Hardware renderer

You can produce broadcast resolution im-ages in less time than with software render-ing, and in some cases, the quality may begood enough for final delivery.

The Render View window

When you render your scene the rendered image appears in its own windowcalled the Render View. By default, the Render View uses the same camera asthe Scene View (persp), but includes particular rendering capabilities.

Maya renderers | 389

Page 404: Autodesk Maya 2009

The following table shows the differences between the Render View and theScene View:

Render ViewScene View

2D rendered image3D object sceneDisplay

shaded surfaces onlymodeled surfaces, the grid,vertices, curves, and objectmanipulators

Surfaces

black background by de-fault because only objects

default gray backgroundBackground

with materials that are litcan be seen

high-quality, colors andtextures appear in their fi-nal rendered form

low-quality, colors and tex-tures do not appear in theirfinal display form

Quality

Rendering a single frame using IPR

In this section, you work with IPR (Interactive Photorealistic Rendering), atype of software rendering.

The advantage of rendering with IPR is that, after you render an image, youcan adjust the shading and lighting attributes of the scene and then quicklyupdate part or all of the rendered image to review the effect of your changes.IPR is useful for iterations when you need to fine-tune specific attributes.Updates to the image are not always instantaneous, but they are full quality.

To render the scene using IPR

1 In the perspective view, select View > Camera Attribute Editor to displaythe attributes for the camera.

You need to specify the exact region of the perspective view you want torender.

2 In the Attribute Editor, open the Display Options section and turn onDisplay Resolution.

390 | Chapter 9 Rendering

Page 405: Autodesk Maya 2009

A dark green rectangular border shows the region to be rendered. Thisregion defines the area of the final image, and allows you to decide whatappears or does not appear in the final image. (The left and right bordersof the rectangle may be positioned at the edge of the window.)

3 Select Render > IPR Render Current Frame (or select the IPR render currentframe button on the Status Line). (By default, Maya uses the Softwarerenderer as indicated on the Render View window’s toolbar.)

The Render View appears and displays the rendered image.

The rendered image shows the appearance of the apple based on thelighting, and shows the more realistic texture of the counter.

Rendering a single frame using IPR | 391

Page 406: Autodesk Maya 2009

The message displayed at the bottom of the IPR Render View windowstates “Select a region to begin tuning”. In the next step, you create asubregion of the image to render using IPR.

4 In the Render View, select View > Frame Image to resize the Render Viewwindow so it fits closely to the rendered image.

To select a subregion to render using IPR

1 In the Render View, drag a selection box around the small areasurrounding the apple, counter, and wall as shown:

When using IPR, this selected region updates as you alter any shading,texture, or lighting attributes. Selecting a smaller region quickens theupdate. You can select regions throughout the image to see those areasupdate.

2 In the scene view, right-click the wall and select Material Attributes todisplay the Attribute Editor for the Lambert shader you applied to thewall.

3 Click the Color box and change the color to green.

The area within the selected region of the Render View updatesimmediately as you alter the color; the wall turns green.

When you drag within the color wheel of the Color Chooser window,the selected region updates occur immediately.

392 | Chapter 9 Rendering

Page 407: Autodesk Maya 2009

NOTE If the region does not update, in the Render Settings window, turnthe Raytracing option off.

(You won’t alter any other attributes in this lesson. The purpose of thelesson is to learn the process of rendering, not to perfect the results atthis point.)

4 From the Render View menu, select View > Reset Region Marquee.

This resets the border of the tuning region to the full resolution of theimage. If you update an attribute, the entire image will be updated.

5 From the Render View menu, select IPR > Redo Previous IPR Render.

The rendered image updates to the full resolution.

By default, the resolution of the IPR window is 320 by 240 pixels. Theadvantage of this relatively small resolution is that it renders quickly. However,if you want a larger image, you can increase the image resolution.

To increase the size of the rendered image

1 In the Render View menu, select Options > Render Settings (or click theRender Settings button in the Render View window).

Rendering a single frame using IPR | 393

Page 408: Autodesk Maya 2009

The Render Settings window appears.

2 Click the Common tab, open the Image Size section, and select 640x480from the Presets drop-down list.

394 | Chapter 9 Rendering

Page 409: Autodesk Maya 2009

(An image size of 640 by 480 is four times as large as the 320 by 240 imagesize.)

3 Close the Render Settings window.

4 Close the Render View window.

Rendering a single frame using IPR | 395

Page 410: Autodesk Maya 2009

5 Select Render > IPR Render Current Frame (or select the IPR render currentframe button on the Status Line).

The Render View window opens and renders an image with an imagesize of 640 by 480 pixels.

NOTE If you are using Maya on Windows or Linux, rendering the scenedisplays another window called the Output window, typically behind otherwindows on your desktop. The Output window lists statistics about the imagejust rendered. For now, you can ignore and close the Output window. Itcontains information that you will appreciate more as you gain experienceusing Maya.

So far, you’ve used IPR to see changes you made to a shader. If you add lightsto the scene rather than using default lighting, you can also use IPR to helpadjust the lighting.

Rendering using the Maya software renderer

You are nearly ready to render the entire animation to disk. You must firstswitch camera views so you can render the scene from the point of view ofthe camera that was animated for this lesson. When animating a camera it’sa good practice to create a second camera to animate, rather than animatingthe default persp camera. In that way you can return to the default perspectiveview should it become necessary.

Rendering the entire animation can take a lot of time, so it is useful to firstuse Maya’s software renderer to test render a few frames to your monitor andexamine the results.

Once you are satisfied with the quality of a few rendered frames, you canrender the entire animation to disk.

To switch camera views and playback the animation

1 In the perspective view, select Panels > Perspective > apple_camera.

The view updates to display the scene as seen through the lens of theapple_camera.

2 Click the Play button in the Timeslider playback controls.

During playback, the animated camera tracks and tumbles about theapple.

396 | Chapter 9 Rendering

Page 411: Autodesk Maya 2009

3 Stop the animation at a frame you want to test render.

To test render the current frame of animation

1 In the Render View window, select Options > Render Settings.

2 In the Render Settings window, select Maya Software from the RenderUsing drop-down list.

3 In the Render Settings window, select the Maya Software tab.

4 In the Anti-aliasing Quality section, select Production quality from theQuality drop-down list.

This setting provides high quality results by smoothing any jagged surfaceedges in the rendered image.

5 Close the Render Settings window.

6 In the Render View window, select Render > Render > Current(apple_camera).

This menu item uses the software renderer to render a single frame ofthe scene that you rendered with IPR previously but from the point ofview of the animated apple_camera.

You might not see a big improvement in quality as compared to theIPR-rendered image. If you dolly the camera closer to the apple and renderonce with IPR and once with the software renderer, you will see animprovement at the edges of the apple as shown below:

Rendering using the Maya software renderer | 397

Page 412: Autodesk Maya 2009

7 Go to frame 120 of the animation, where the apple is viewed in a differentposition.

8 In the Render View, select Render > Render > Current (apple_camera).

Ensure that the rendered image looks good at this frame also.

Now that you’ve checked a pair of rendered frames that represent the entireanimation, you are ready to render the entire animation sequence. In yourown projects, you might want to test render several frames, particularly wherenew shading and lighting elements occur in the animation.

Batch rendering a sequence of animation frames

After you model, animate, and color your scene, you set several Render Settingsoptions and then use the software renderer to batch render part or all of theanimation’s range of frames to files on disk. Each file represents a single frame(image) of the animation.

To set the Render Settings for batch rendering

1 In the Render View window, select Options > Render Settings to displaythe Render Settings window.

2 In the Render Settings window, select the Common tab, and then openthe File Output section.

3 In the File Output section, set the following options:n File Name Prefix: Type the name Apple. This name will be the base

of the filenames created by batch rendering.

398 | Chapter 9 Rendering

Page 413: Autodesk Maya 2009

n Frame/Animation Ext: Select name.#.ext. This specifies that thefilenames will have the format prefix.frameNumber.fileFormat. Forexample, batch rendering the entire 200-frame animation will createApple.0001.iff, Apple.0002.iff, and so on through Apple.00200.iff.

n Image Format: Select Maya IFF (.iff), Maya’s standard image file format.You can use the .iff format for any further work you need to do,including previewing and compositing the animation. If you requirea different format, you can specify it instead of .iff in the RenderSettings.

n Start frame: Enter 1, the first frame of the animation sequence to bebatch rendered.

n End frame: Enter 60, the last frame to be batch rendered. (Renderingall 200 frames may be time-consuming.)

n Frame padding: Enter 4. This causes the frameNumber part of thefilenames to be four digits prefixed with 0s. For example, the filenameswill be Apple.0001.iff through Apple.0050.iff.

n Renderable Camera: Select apple_camera from the drop-down list toindicate which camera view to render.

The four-digit padded filename is compatible with many image playbackprograms, for example, Maya’s FCheck utility. Image playback programslet you view rendered animation sequences on your monitor at real-timespeed.

For the remaining options in the Render Settings window, you’ll use thedefault settings. Maya will render using the camera (persp), image size(640x480), and anti-aliasing quality (Production Quality) that youspecified earlier in the lesson.

After you set the Render Settings, the top portion of the Common tabshows the correct path and filenames for the files to be created duringbatch rendering. Check that this information is correct.

Batch rendering a sequence of animation frames | 399

Page 414: Autodesk Maya 2009

4 Close the Render Settings window.

To batch render animation frames

1 Save the scene.

It’s a good practice to save the scene before batch rendering. This is usefulif, after batch rendering, you need to change any display settings andrender again. By saving the scene prior to batch rendering, you canexamine the scene to learn which option settings were in effect at thetime you batch rendered.

2 From the Rendering menu set, select Render > Batch Render > .

The Batch Render Frame window appears.

3 Turn on Use all available processors, then click Batch Render and closeto start batch rendering.

(The Use all available processors option allows Maya to use all theprocessors available on the local machine to complete the render.)

400 | Chapter 9 Rendering

Page 415: Autodesk Maya 2009

NOTE For users of Maya Personal Learning Edition, the Use all AvailableProcessors option is disabled. Use the default settings.

Batch rendering 50 frames of a simple scene takes a few minutes. Acomplex scene may take hours per frame, depending on the speed ofyour computer.

To check the status of the batch render

1 While Maya is rendering, select Window > General Editors > Script Editor.Expand the size of the Script Editor window. The window shows acompletion log for the frames being rendered.

Maya puts the resulting files in a default images directory. The files havethe following names:

Apple.0001.iffApple.0002.iffApple.0003.iff......Apple.0050.iff

The images directory is located in the same path as the scenes directory.You can have Maya save to a different path by changing the projectsetting. See the Maya Help for further information on projects.

2 Close the Script Editor when the following message appears:// Result: Rendering Completed. See mayaRenderLog.txt for information. //

The mayaRenderLog.txt file contains rendering statistics for advancedusers.

Viewing a sequence of rendered frames

You can use Maya’s FCheck image viewing utility to view the batch-renderedimages at a speed that approximates video or film.

To use FCheck to view a sequence of rendered frames

1 Select File > View Sequence.

The File Browser window appears.

Viewing a sequence of rendered frames | 401

Page 416: Autodesk Maya 2009

2 Using the File Browser, navigate to the images directory for your currentproject (or wherever you saved the rendered sequence of images for theApple).

3 Click the image file Apple.0001.iff to select the first image in thesequence and then click Open.

The FCheck image viewing utility appears and the rendered sequence of60 frames plays back as an animated loop.

4 Close the window after viewing the animation.

NOTE The FCheck rendering utility has playback, display, and other optionsyou can select from your keyboard. Details are available from the FCheckHelp menu.

Beyond the lesson

In this lesson, you were introduced to some of the basic concepts for renderingan image. In this lesson you learned that:

n Surfaces are assigned shading materials to provide basic attributes such ascolor, shininess, reflectivity, and so on. Each shading material has uniquecharacteristics that can be modified to suit your requirements.

n You can additionally assign a texture map to some of the shading materialattributes so that your objects appear more realistic.

n Maya provides several methods for rendering an image. You can renderusing the Maya Software renderer, the Maya Hardware renderer, the MayaVector renderer or the mental ray® for Maya® renderer. Each type ofrenderer has specific advantages and uses.

n You can choose the size and quality for a rendered image prior to renderingbased on your specific needs and requirements.

n You can render a single image or a sequence of images from an animation.

n You can view one image, or a sequence of rendered frames using the FCheckutility.

As you render scenes, consider the following issues:

402 | Chapter 9 Rendering

Page 417: Autodesk Maya 2009

Using IPR

There are a few limitations to using IPR for fast visual feedback as you adjustshading and lighting. Besides being unable to provide production-qualityanti-aliasing, IPR cannot display several other advanced display characteristics,for example, true surface reflections (raytracing) and 3D motion blur. If anadvanced display characteristic seems to be missing from an IPR-renderedframe, try rendering the frame with the software renderer.

If you change the camera view, turn Depth Map Shadows on or off, orreposition shadows, IPR does not update the rendered image automatically.You must refresh the image. From the Render View window, select IPR >Refresh IPR Image.

Batch rendering

In this lesson, you used the Maya software renderer to check the image qualityof two frames before you started to batch render. When you create scenes withsophisticated animation, it’s useful to batch render with low-quality resolutionto check the animation accuracy before batch rendering withproduction-quality resolution. For instance, you might preview your animationwith the frames resulting from batch rendering at a small image size (320 by240) with Preview Quality anti-aliasing.

You don’t need to use the batch renderer to render single frames from yourscene to disk. From the Render View window, select File > Save Image.

Hardware rendering

Hardware rendering leverages the power provided by hardware graphics cardsto render your images. The benefits of hardware rendering include the abilityto batch render frames more quickly than with software rendering, andrendering specific particle effects not possible through software rendering. Insome cases, the image quality may be good enough for final use. You accessthe hardware renderer by selecting Render > Render Using > Maya Hardware.

Hardware rendering has its own limitations when compared to softwarerendering. For more information on hardware rendering, see the Maya Help.

Rendering in layers

It’s often useful to render objects in your scene in different layers and combinethem using compositing software. In some cases, you must render some opticaleffects and then composite them afterwards. Rendering in layers can end upbeing faster than rendering an entire scene, and it lets you replace individual

Beyond the lesson | 403

Page 418: Autodesk Maya 2009

objects quickly if the need arises. To set up layers, use the Layer Editor, whichappears below the Channel Box by default. For more information, see “Renderlayers” in the Maya Help.

Lesson 2: Shading surfaces

Introduction

In the real world, objects are seen in specific ways based on the following:

n The materials they are made of.

n Their surface textures.

n How they are lit and reflect light.

n The environment surrounding them.

In Maya, you provide your surfaces and objects with these characteristics byassigning shading materials to them.

404 | Chapter 9 Rendering

Page 419: Autodesk Maya 2009

Shading Materials provide instructions to the renderer so it can simulate howthe surfaces in your scene react to light and appear in the final image. Shadinginvolves such attributes as color, transparency, shininess, and many othersto create a realistic look.

Editing the material attributes associated with shading materials affects howthey appear in the rendered image. In this way, Maya provides the option ofallowing you to create images as they would appear in the real world or inyour imagination.

In this lesson, you learn to use basic shading features to render a sphere so itappears like an orange in the final image.

In this lesson you learn how to:

n Assign a shading material with specific color and surface attributes.

n Differentiate between shading material types (Lambert, Blinn, Phong, andso on) to achieve a specific material appearance.

n Assign a label texture map to a surface.

n Use the Hypershade editor to view and work with shading materials.

n Create a bump texture map to simulate the orange’s pebbled skin.

n Control the placement of a 3D texture using a 3D manipulator.

Open the scene for the lesson

In this lesson, you work with a scene we created for your use.

1 Make sure you’ve done the steps in Preparing for the lessons on page 377.

2 Open the scene file named ShadeOrange.mb.

This file can be found in the GettingStarted directory that you set asyour Maya project:

GettingStarted\Rendering\ShadeOrange.mb

This scene contains a sphere modeled to resemble an orange.

Open the scene for the lesson | 405

Page 420: Autodesk Maya 2009

The scene’s perspective view also has two settings turned on—Shading >Smooth Shade All and Shading > Hardware Texturing (Hotkey: 6)—whichlet you see the shading changes you are about to make.

Assigning a shading material

In the next steps, you create a material and assign it to the surface. A materialis a collection of attributes that define color, shininess, and other surfacecharacteristics.

To assign a material to an object

1 Before you create a new material, right-click the sphere and select MaterialAttributes.

The default material attributes appear in the Attribute Editor.

The default material assigned to the sphere (and all other surfaces) is atype of material called Lambert. The material displays the surface withgray shading. You should not edit the default shading material.

2 Right-click the sphere and select Assign New Material > Blinn to create anew material for the sphere.

The new material’s attributes appear in the Attribute Editor.

A Blinn material gives a surface a shinier look than a Lambert material.Blinn is a good choice for creating a variety of surface appearances.Knowing which material type to use for a particular surface comes withpractice. Fortunately, you can change the material type later on, so youdo not need to make a decision now. You will learn more about materialtypes later in the lesson.

3 In the Attribute Editor, click the gray box to the right of Color to openthe Color Chooser.

406 | Chapter 9 Rendering

Page 421: Autodesk Maya 2009

4 In the Color Chooser, click inside the color wheel (hexagon) and dragthe pointer to an orange-colored area, as illustrated.

The sphere becomes the same color you select in the Color Chooser. Alsodrag up the slider to the left of the hexagon to get a brighter shade.

5 Click Accept to close the Color Chooser.

If you compare the color in the Color attribute box with the sphere’scolor in the scene view, you’ll notice a difference.

The color you assigned is only one aspect of surface appearance. Theappearance also depends on how the surface reacts with light. The mainattributes that control the reaction to light are under the CommonMaterial Attributes heading. As an example of these attributes, you willchange the Diffuse setting.

6 In the Attribute Editor, drag the Diffuse slider to its right to increase thecolor brightness as viewed in the scene view.

This will help create the illusion of a bright orange.

Assigning a shading material | 407

Page 422: Autodesk Maya 2009

In practical usage, the Diffuse setting makes a surface appear brighter.The name diffuse comes from a property in physics that describes howlight spreads after it strikes a surface. A surface with a high diffuse propertyspreads the light that strikes it, making the object appear brighter.

Like the Diffuse attribute, the other Common Material Attributes alsorefer to general characteristics of light and the way a surface reacts tolight.

The next section in the Attribute Editor, Specular Shading, containsattributes that control the appearance of shiny highlights on the surface.

Next, you’ll alter the surface specularity—the amount of light that reflects offa surface, resulting in shiny highlights.

Modifying surface specularity

When light reflects in a concentrated manner off of a surface, a specularhighlight results. Specular highlights can be thought of as “pseudo” reflectionsof bright areas in the scene (sunlight, bright lights, and so on). Modifying thespecular attributes affects the perceived reflectivity for a surface. When youreduce the specularity, you in turn reduce the perceived reflectivity.

To modify the specularity of a material

1 In the Specular Shading section of the Attribute Editor, move theEccentricity slider back and forth to change the size of the shinyhighlights.

2 Move the Specular Roll Off slider to change the blend between highlightedand other areas of the surface.

Changes to this attribute do not alter the surface in the scene view, soyou need to check the Material Sample in the Attribute Editor (see the

408 | Chapter 9 Rendering

Page 423: Autodesk Maya 2009

following illustration). You can also render a test image (Render > IPRRender Current Frame).

As you work with shading, you’ll find many attributes that have no effectin the scene view, for instance, Ambient Color and Translucence.Generally, the scene view is a rough approximation of how the scene willrender.

The IPR renderer is ideal for testing shading. It shows the results of allchanges you make to shading and shows them immediately. There isonly one attribute change the IPR renderer does not show—reflectivity.See the next step for details.

Some attribute changes such as reflectivity and reflections are notdisplayed by the Material Sample.

Material types

A material type (also referred to as a shading model) defines how a particularshading material on a surface simulates a natural reaction to light. Blinn,Phong, and Lambert are a few examples of material types available in Maya.Each of these material types provide distinct shading characteristics based onthe mathematical algorithms that define them.

From the settings you’ve made so far, you may decide you want to give theorange a different look than possible with the Blinn material. You will nowchange to a different material for comparison.

To set the material type

1 Next to the Type attribute near the top of the Attribute Editor, pull downthe menu and select Phong E.

Phong and Phong E are variations of the Lambert material type, withspecular highlights added. The main difference between materials is the

Material types | 409

Page 424: Autodesk Maya 2009

way each handles specularity. By switching between the material types,you can compare which material gives you the specularity you need.

Your settings for the Color and Diffuse attributes are maintained becausethey are common to all material types. The Specular Shading and all otherattribute settings do not convert when you change the material, so it’sbest to choose your material before you make many changes.

2 In the Specular Shading section, you can leave Roughness and HighlightSize at the default settings. The default highlight settings give the orangea waxy look.

These attributes are similar to the Blinn attributes, Eccentricity andSpecular Roll Off. Unlike the Blinn counterparts, these highlights do notappear in the scene view. You can see the highlights only in a renderedimage and in the Material Sample.

3 The Phong E material type has a Whiteness attribute not available withBlinn. Change Whiteness to a light gray to accentuate the highlights.

This change is subtle, so drag the slider back and forth while watchingthe effect in the Material Sample or in an IPR region. Look for the entirehighlighted area to become whiter. Again, a strong highlight will createa waxy look.

Assigning textures

For an orange, one color may be all that you need. In this section, you willgo a step further by making a logo stamp appear on the orange skin. For thisand other color effects, you need to apply a texture to your material.

In visual arts, a texture is any kind of surface detail, both visual and tactile.In Maya, a texture is a collection of attributes that creates surface detail.

410 | Chapter 9 Rendering

Page 425: Autodesk Maya 2009

Textures have a more specialized display purpose than materials. For example,you can use textures to create the appearance of a marbled pattern, bumps,or a logo image on the side of a can.

In the Maya Help, a texture is also referred to as a texture node. A node is acollection of attributes (or actions) with a common purpose. A shader issometimes called a shader node or material node.

To display a texture on a surface, you apply a texture node to an attribute ofthe surface material. In the next steps, you apply a texture to the Color attributeof the Phong E material.

To apply a texture to a material

1 Click the Map button next to the Color slider. This is a quick way ofapplying a texture to an attribute. This is also called mapping a texture.

The Create Render Node window displays a list of the textures you canapply. The texture names and their icons help you to decide which textureis appropriate for the effect you want.

To create the logo stamp effect, you will use the File texture. A File textureuses an image file that you or someone else created separately, such as adrawing from a paint program. For this lesson, you’ll use an image wecreated for you.

Assigning textures | 411

Page 426: Autodesk Maya 2009

2 Before you create the texture, make sure Normal is selected in the optionsabove the texture swatches.

The Normal option means Maya will stretch the texture evenly aroundthe surface. The other settings—Projection and Stencil—are other waysyou can apply a texture. You will learn about these settings at the end ofthe lesson.

3 In the 2D Textures list, click the File button once.

At this point the system may prompt you with the warning that “TheIPR file does not have enough information to support your most recentchange”. Select “Close the IPR file and stop tuning”. The file1 nodeappears in the Attribute Editor.

The file texture also causes the sphere to turn white in the scene viewand black in a rendered view. This is a temporary color until you specifythe actual file name of the file texture.

4 Click the folder icon to the right of the Image Name attribute. A browserwindow opens with the path set to a default directory called sourceimages.

Maya looks for source images in a default sourceimages directory.However, Maya can use file texture images anywhere on your workstationor local network. For example, you could have them on a central diskdrive that is shared among your coworkers.

5 Navigate to the GettingStarted\Rendering\sourceimages directory andopen Render_Mayakist.iff.

6 In the Render View window select IPR > Redo Previous IPR Render.

The file texture with a Mayakist logo now appears on the sphere. Thelogo is somewhat jagged, which will simulate the look of an ink stampon rough orange skin.

7 In the Attribute Editor, click the place2dTexture1 tab.

412 | Chapter 9 Rendering

Page 427: Autodesk Maya 2009

The place2dTexture1 tab is a node with attributes that control the texture’sposition on the surface.

If you select another object and the Attribute Editor no longer displaysthe file texture attributes, it’s easy to restore the display. Right-click thesphere, select Material Attributes, and click the texture map icon next tothe Color attribute.

8 As an example of the place2dTexture1 placement controls, move theRotate UV slider slightly to the right, to a value about 5.9. This rotatesthe Mayakist logo on the surface.

In this case, the texture placement needs almost no adjustment. For theease of this lesson, we created a file texture that conforms to the sphere’sshape by default. In practice, placing file textures requires moreadjustment. For details, see Preparing for the lessons on page 377.

Using the Hypershade editor

After you create a texture node, you will often want to return to the associatedmaterial node to make changes. Because material and texture nodes do nothave icons that represent them in your scene view, you need a special editor,called Hypershade, to select them and edit their attributes. In this section,you learn how to work with Hypershade.

To view and edit material attributes using Hypershade

1 In the perspective view, select Panels > Saved Layouts > Hypershade/Persp.

This layout is convenient because it’s common practice to drag and dropitems from Hypershade (using the middle mouse button) onto objects inthe perspective view. You can also open Hypershade as a separate window(Window > Rendering Editors > Hypershade).

2 At the top of Hypershade, click the Materials tab to make sure the tab isdisplayed. If the material swatches are too small to see clearly, dolly intothe view using the same keyboard and mouse shortcuts you would usein the scene view.

Using the Hypershade editor | 413

Page 428: Autodesk Maya 2009

This tab shows all the materials currently in your scene. It is especiallyuseful when you have a complex scene and you need to locate a materialto edit it. The materials you will recognize are the default Lambert materialand the Phong E material. You can ignore the others. They exist in allscenes, by default, for use with other Maya features.

In addition to the Materials tab, Hypershade includes other tabs to helpyou keep track of textures, lights, and other nodes related to rendering.

3 With the middle mouse button, drag the lambert1 swatch into the sceneview and over the sphere. When you release the mouse, the Lambertmaterial appears on the sphere instead of the Phong E material youpreviously created.

4 Drag the phongE1 swatch onto the sphere to reapply that material.

Hypershade is designed for quick, drag-and-drop operations such as this.

5 Select the sphere.

414 | Chapter 9 Rendering

Page 429: Autodesk Maya 2009

6 From the menus in Hypershade, select Graph > Graph Materials onSelected Objects.

A graph appears in the Work Area tab in the bottom section.

This graph shows all material and texture nodes applied to this object.While the Materials tab shows a catalog of the materials in the scene, theWork Area tab shows whatever material, texture, or other node you arecurrently working on. The Graph menu has several menu items thatchange the contents of the Work Area display.

The Shader Library tab shown in the above illustration might not be apart of your Maya installation. It is an optional feature, discussed at theend of this lesson.

The Work Area shows connection lines between the nodes. The lineshave arrows that all point in one direction. For a closer look at thesearrows, dolly into the view using the same keyboard and mouse shortcutsyou would use in the scene view.

The arrows depict Maya’s internal information input and output, calleda stream. The next step shows the importance of this connection stream.

7 Click the line between the file1 and phongE1 nodes (it turns yellow) andpress the Delete key.

The sphere reverts to the default gray color because you have broken theconnection between these nodes and the texture is no longer assignedto it. This is a simple illustration of how the connection stream works.The file1 texture node is upstream from the connection you deleted, soit no longer inputs data into the material; Maya ignores it.

In practical terms, this is an example of how you can disconnect a texturefrom a material without actually deleting the texture. For example, youmay want to remove the file texture from this material and connect it to

Using the Hypershade editor | 415

Page 430: Autodesk Maya 2009

another material instead. In a later step, you will learn about usingHypershade to make connections between textures and materials.

8 Select Edit > Undo, Redo, Repeat to restore the file texture connectionyou deleted.

9 In Hypershade, right-click the center of the phongE1 swatch and selectRename.

10 Type: Orange.

Renaming is not as important in this scene as it would be in more complexscenes with several materials.

The Rename operation is one of several useful menu items that appearwhen you right-click a material swatch. Another handy menu item isAssign Material to Selection. You can use this operation to assign amaterial to multiple selected objects rather than assign it one object at atime.

Creating a texture within the Hypershade editor

To mimic the skin of an orange, you will add a bump map texture. A bumpmap creates the illusion that the surface has bumps or other types of surfacerelief. You will map the texture using the Create Bar in Hypershade.

The Create Bar is similar to the Create Render Node window you have usedalready. It is built into Hypershade for greater convenience.

Create Render Node appears at the top, by default. Next to the heading is anarrow icon. If you click this icon, you switch to the Create mental ray Nodesmode. In this case, leave the Create Maya Nodes selection turned on.

416 | Chapter 9 Rendering

Page 431: Autodesk Maya 2009

The Mayakist logo file texture is a 2D texture, which wraps evenly around thesurface. Next, you create a 3D texture. A 3D texture is for making objectsappear to have been carved out of a solid substance, such as marble or wood.

To create a bump texture within the Hypershade Editor

1 In the Create bar, scroll down to the 3D Textures heading.

For this bump effect, you use a Brownian 3D texture. Experience hasshown that a Brownian texture is the best texture for approximating thebumps on an orange skin. Becoming skillful with textures is a matter ofobservation, experimentation, and experience.

2 With the middle mouse button, drag the Brownian texture (under 3DTextures) onto the Orange material swatch in the Work Area tab andrelease the mouse button.

3 From the menu that appears, choose bump map.

Maya connects or applies Brownian to the Orange material’s bump mapattribute.

The pop-up menu shows a list of common material attributes. Althoughyou can map textures to any material attribute, these are the mostcommonly mapped attributes.

By default, you can assign only one texture per attribute. Attributes thatalready have an assigned texture appear in italics. (For a discussion aboutassigning multiple textures to an attribute, see Layered textures on page422.)

This drag-and-drop method of applying a texture is essentially the sameas clicking the map icon next to a material’s attribute slider. UsingHypershade offers a faster, more graphical alternative to using theAttribute Editor.

Creating a texture within the Hypershade editor | 417

Page 432: Autodesk Maya 2009

4 Select Graph > Input and Output Connections to view the nodeconnections for the new texture you created.

Also notice that bumps from the bump map appear in the Orangematerial’s swatch. The Orange material swatch is the same as the MaterialSample that appears in the Attribute Editor for the material node. (Thebumps also appear in a rendered image, but not in the scene view.)

5 Double-click the bump3d1 swatch (the checkered cube) to display itsattributes in the Attribute Editor.

This node is the link between the texture and the material. It convertsvisual information, such as the mottled Brownian pattern, into theappearance of surface relief.

The most important attribute in the bump3d1 node is Bump Depth,which controls the intensity of the bumps.

6 Change Bump Depth to 0.15. In the Orange swatch or a rendered image,you’ll see that this diminishes the bumps as compared to the defaultvalue 1.0.

NOTE If you select Render > IPR Render Current Frame while Hypershade isselected, a message appears: Please select the view you want to render. Eitherselect the perspective view before choosing IPR Render Current Frame, or,in the Render View window, select IPR > Redo Previous IPR Renderer.

7 In the Hypershade panel, click the brownian1 texture swatch to revealits attributes. Set the following:n Increment: 0.3

418 | Chapter 9 Rendering

Page 433: Autodesk Maya 2009

n Octaves: 4.0

These values produce a rendered image closer to real orange skin.

Our recommendation for these values is based on experimentation. ForBrownian and some other textures, it’s usually faster to get desirableresults by experimenting with the settings rather than trying tounderstand the definition of each attribute.

Modifying a bump texture

The bump texture is too crater-like to be a convincing orange. The bumps aretoo numerous and too deep. A quick way to fix this problem is to scale up theentire texture.

To interactively position a 3D texture

1 Double click the place3dTexture1 swatch, to the left of the Browniancolor swatch.

This node controls the 3D texture’s position, scale, and rotation. Thevisual display of this node is a large cube that surrounds the sphere inthe scene view. This is the texture placement cube.

Modifying a bump texture | 419

Page 434: Autodesk Maya 2009

2 Click the Interactive Placement button in the Attribute Editor. Amanipulator appears for the texture placement cube.

3 In the scene view, click on the center scale box to activate the centerscale option. Scale the whole texture placement cube to about twice theoriginal size (until the Scale attribute values are about 2).

Now when you render, the bumps on the surface appear wider andsmoother, like the bumps on an orange skin. For example, the bumps inthe area surrounding the highlight do not appear to be as deep as theywere before you scaled the texture.

Scaling a texture placement cube is a common way to tune the texture’sdisplay. Scaling does not actually change the pattern, but enlarges orshrinks it relative to the surface.

4 Now that you’ve changed the surface texture through scaling, move thetexture placement cube above the sphere (drag the green arrow up), tosee how that affects the texture.

420 | Chapter 9 Rendering

Page 435: Autodesk Maya 2009

NOTE If you have tumbled the camera for a different view of the orange orthe texture placement cube, ensure you reposition the camera so that theorange’s Mayakist logo is visible before rendering again. Otherwise, therendered image will appear incorrect.

In the rendered image, notice that the bumps still remain on the sphere.Objects do not need to be within the texture placement cube, because itrepresents an imaginary texture volume, which is infinite.

However, movement of the texture placement cube does shift the surfacetexture pattern. The difference is hard to notice on a uniform texture likeBrownian. Transforming the cube would be more noticeable with a texturesuch as Marble, where the veins within the pattern would be repositioned.

Movement of the object itself also shifts the surface texture. For example,if you were to animate the orange rolling and then render an imagesequence, the texture would shift each frame rather than roll with thesurface. To prevent this undesirable effect, you need to make sure thatthe texture moves in the same way the object moves. One way to do thisis to parent the texture placement cube (also called the place3dTexturenode) to the object. For more information on parenting, refer to the MayaHelp.

Beyond the lesson

In this lesson, you were introduced to some of the features available for shadingsurfaces. You learned that:

n Shading materials can employ a variety of material types that can be usedto achieve specific surface characteristics (Shininess, Matte, and so on).

Beyond the lesson | 421

Page 436: Autodesk Maya 2009

n Textures can be applied to a shading material to enhance the realism ofthe final image. For example, logo graphics, bumps, and so on, can beadded to enhance the detail on the surface.

n Textures can be 2D or 3D in nature. Each has its unique techniques forapplication and placement.

Placement of textures

When you put the Mayakist logo on the surface, the letters appeared straight.The letters are actually skewed in the texture. We skewed the logo for youruse in this lesson so that it looks straight when stretched onto the surface.

In your own work, skewing texture images is usually too difficult andimpractical. A more practical Maya technique for assigning and positioningfile textures is to use texture projection. With this feature, you project thetexture onto the surface as if you are projecting a slide image onto a screen.The texture is positioned where the projection strikes the surface. Instead ofa skewed Mayakist logo, you could use a straight logo and project it onto thesphere. You could tune the angle of projection so that the curvature of thesurface skews the logo just as in the lesson. To assign textures as projections,you turn on the As Projection option at the top of the 2D Textures section ofthe Create Render Node window.

The placement of texture projections is similar to the placement you performedfor the bump map (3D) texture. Like the bump map texture, you need toparent the texture projection (the place3dTexture node) to the object in orderto avoid the texture placement changing when the object moves.

Layered textures

Suppose you want to add a scarred pattern to the orange skin. Because youcan only have one texture assigned to the Color attribute you can use a LayeredTexture to combine two or more texture maps.

The Layered Texture is a texture node that lets you composite or layer severaltextures on top of each other. You assign it to a material’s attribute just likeother textures. Within the Layered Texture’s attribute controls, you can connect

422 | Chapter 9 Rendering

Page 437: Autodesk Maya 2009

other textures and control how they blend together. For example, the bottomlayer could be the logo image you used in the lesson, and a top layer couldbe an image of streaking lines that resemble scars. The combined logo andscars would give the orange the final aged look that you wanted.

Shader Library

As an option, you can install a Shader Library with Maya to help you quicklycreate common materials, such as bricks, fabrics, foods, and many other surfacetypes. When installed, a Shader Library tab appears in Hypershade. To use amaterial, find the type of shading you want, drag and drop it into Hypershade,then drag and drop it onto a surface in your scene using the middle mousebutton.

Lesson 3: Lights, shadows, and cameras

Introduction

Directors of live-action film use camera and lighting techniques to enhancethe visual impact of a scene. Wide, medium, and close up views of the subject,depth of field, high or low key lighting all communicate something about thesubject and the scene to the viewer.

Lesson 3: Lights, shadows, and cameras | 423

Page 438: Autodesk Maya 2009

Lighting and camera techniques are one of the most crucial aspects to considerwhen working with artificial characters and objects. The more realistic thelighting and shading appear, the more convincing the scene will appear tothe viewer.

A prerequisite to creating effective 3D rendered animation is to study thelighting and camera effects used in live-action film. Your goal is to create thedesired scene ambience while keeping the lights and camera view asunobtrusive as possible.

In Maya, it is possible to simulate both realistic and unrealistic lighting andshadow effects for your final images and animations. In this lesson, you learnbasic techniques for working with lights, shadows, and cameras. In this lesson,you learn how to:

n Create and position various types of lights in the scene.

n Edit the attributes of lights and experiment with their effect in the scene.

n Cast shadows on your surfaces using the lights and objects in the scene.

n Create and animate an additional camera in the scene.

Open the scene for the lesson

In this lesson, you work with a scene we created for your use. In the first steps,you open the scene, create a directional light, and compare the directionallight’s effect to the scene’s default lighting.

1 Make sure you’ve done the steps in Preparing for the lessons on page 377.

2 Open the scene file named Lights.mb.

This file can be found in the GettingStarted directory that you set asyour Maya project:

GettingStarted\Rendering\Lights.mb

The scene contains a room with two walls and a floor. Sitting in the roomis a drafting table and lamp, grouped under the name tableGroup. Allobjects have a default gray shading.

424 | Chapter 9 Rendering

Page 439: Autodesk Maya 2009

When you open the scene, Maya lights the scene with default lightingprovided by an imaginary light fixture. It emanates light infinitely froma point above and behind the active scene view camera. There is no iconthat represents the default light in the scene view.

Directional lights

Maya has many types of lights that simulate natural and artificial lighting. Inthe next steps, you create a light for the scene using a directional light. Adirectional light uses parallel rays of light, as if illuminating from a very fardistance, to illuminate the scene. A directional light is often used to simulatesunlight.

To create a directional light

1 Select Create > Lights > Directional light > .

2 Turn off Interactive Placement, then click Create.

A directional light is created at the center of the scene.

Because a directional light is similar to sunlight. Its parallel rays strike allobjects in the scene from a single direction as indicated by the arrow iconrepresenting the light. The position of the light is not so much importantas the direction that the arrow icon points.

Directional lights | 425

Page 440: Autodesk Maya 2009

When you create a light, the scene view does not display its effect, bydefault. The scene view instead uses default lighting.

3 Select Lighting > Use All Lights (Hotkey: 7). This lights up the scene viewonly with lights you’ve created, not with default lighting. If you laterwant to see the scene view with default lighting again, select Lighting >Use Default Lighting (Hotkey: 6).

When you render the scene, by default, Maya uses all lights you’ve created.If you don’t create any lights, Maya creates a temporary default directionallight for you and then deletes it when the render is complete.

Next, you aim the directional light and edit its attributes.

To edit the directional light

1 With the directional light selected, rotate the light in various directions.The shading of surfaces changes as you rotate the light. The more directlythe light points at a surface, the brighter the shading. A directional lightis affected by its rotation, not its position. As you’ll see later, the positionof other lights affects the lighting.

2 Rotate the light as follows:n Rotate X: -40

n Rotate Y: 25

n Rotate Z: -20

With this orientation, all object surfaces in the scene show the effect ofthe light in the current camera view.

3 With the light still selected, open the Attribute Editor (under the Windowmenu). Drag the Intensity slider to various values to see the effects ofintensity.

Higher values brighten the surfaces. For example, an Intensity of 1.6brightens the lighting so much that the gray default shading of somesurfaces are bleached to white.

NOTE Several of the following illustrations in this lesson are snapshots of thescene after rendering. To render the scene, select Render > Render CurrentFrame. Do not use IPR rendering for this lesson because it doesn’tautomatically update the image for some of the changes you make to thescene.

426 | Chapter 9 Rendering

Page 441: Autodesk Maya 2009

4 In the Attribute Editor, click the white Color box above the Intensitybox. This displays the Color Chooser.

5 Click inside the color wheel (hexagon) and drag the pointer to a red color.

The lighting imparts a red hue to the surfaces in the scene.

6 Change the color back to white and set the Intensity to 1.2 or so.

You’ll use these settings for the basic lighting of the scene.

Spotlights

In the next steps, you light part of the desk by creating a spotlight andpositioning it within the desk lamp. A spotlight emits light from a single pointwithin a limited cone angle. You can aim a spot light in the direction youwant the light to illuminate.

To create a spotlight

1 Select Create > Lights > Spot Light > .

2 Turn off Interactive Placement, then click Create.

This creates the spotlight’s icon at the center of the grid. The light pointstoward the back wall.

3 Move the spotlight above the lamp. (Drag the light up along its localY-axis.)

Spotlights | 427

Page 442: Autodesk Maya 2009

If you look at the spotlight icon from several angles, you’ll notice that itis shaped like a cone with an arrow pointing out of it.

The cone symbolizes that a spotlight emits a beam of light that graduallywidens with distance.

4 Select Modify > Transformation Tools > Move Tool, Rotate Tool, ScaleTool, Show Manipulator Tool.

With the spotlight selected, this tool provides two manipulators that youcan move to position and aim the light precisely.

The look-at point specifies where the light focuses. The eye point definesthe position of the light source. All types of lights have an eye point, butnot necessarily a look-at point.

5 Move the look-at point to the top of the table, and move the eye pointroughly to the center of the lamp housing.

428 | Chapter 9 Rendering

Page 443: Autodesk Maya 2009

You can also use the Rotate tool to center the eye-point more accuratelyin the lamp housing.

An alternative way to position a spotlight is to select the light and thenselect Panels > Look Through Selected. You can then dolly and pan theview to focus on the desired surface. The area of focus is where the lightstrikes the surface. To return to the perspective view select Panels >Perspective > persp.

6 If you render the scene, you’ll notice that the spotlight lights up a circularregion on both the desk and the floor.

By default, light passes through and lights up each surface in its path.The circular region of light is wider on the floor than the desk because aspotlight emits a beam of light that widens with distance.

Only the floor, not the desk, will be lit by the spotlight in the scene view.You’ll see the desk lit up only if you render the scene.

7 You can prevent the light from passing through the table. With the lightselected, display the Attribute Editor. Open its Shadows section and thenthe Depth Map Shadow Attributes section, then turn on Use Depth MapShadows. Rendering creates this result:

Spotlights | 429

Page 444: Autodesk Maya 2009

By turning on Use Depth Map Shadows, the spotlight’s lighting is blockedby the first surface it hits (the desk). The floor is in the shadow of thedesk so it receives no light. You’ll learn more about Depth Map Shadowslater in the lesson.

If you were to render the scene with IPR rather than the software renderer,the image would not automatically remove the lighting of the spotlightingfrom the floor when you turn on Use Depth Map Shadows. You wouldneed to refresh the image again in the Render View window by selectingIPR > Refresh IPR Image.)

Editing light attributes

Spot lights, directional lights, and other light types have several uniqueattributes (for example, Intensity, Dropoff, Color, etc.). In the next steps, youmodify some of the attributes for the spotlight.

To modify the attributes of a spotlight

1 The spotlight’s default Cone Angle is 40 degrees. In the Attribute Editor,open the Spotlight Attributes section and set Cone Angle to 20.

The circle of light narrows.

2 Set Cone Angle to 60.

The circle of light widens. Rendering creates this result:

430 | Chapter 9 Rendering

Page 445: Autodesk Maya 2009

3 Set Dropoff to 10.

This attribute sets how much the light intensity diminishes from thecenter of the circular region out to the edge. Finding the right value is amatter of experimentation. When you increase the Dropoff, the light’sintensity diminishes, so you need to increase the Intensity. For example,increase the Intensity to 1.6. Rendering creates this result:

To mimic the way a light source’s intensity naturally decreases withdistance, you might want to select a Decay Rate to diminish the light’sintensity. The Linear setting diminishes light with the least abruptness,Quadratic with the most abruptness. Cubic is between the two othersettings.

The default setting is No Decay, which means the light remains at fullintensity regardless of distance. If you use a setting other than No Decay,you likely will need to increase the Intensity. For this lesson, leave theDecay Rate set to No Decay.

4 Set the Penumbra Angle to 10.

This attribute controls the softness along the edge of the area ofillumination provided by the light. Again, finding the right value is amatter of experimentation. You can also use negative numbers to fade

Editing light attributes | 431

Page 446: Autodesk Maya 2009

inward from the circle’s edge. The viewing angle of the camera influencesthe appearance of the fading at the edge. Rendering creates this result:

5 In the Light Effects section of the Attribute Editor, click the map buttonto the right of the Light Fog box.

This gives the appearance of the light beams illuminating fog or dust inthe air. Rendering creates this result:

Fog is more noticeable when you view (render) the light beam from aside angle rather than from above the light fixture.

When you click the Light Fog map button, Maya creates a light fog nodeand displays its attributes in the Attribute Editor.

The Color and Density attributes are useful for altering the fog’s hue andtransparency. These attributes affect only the light on its way to thesurface, not the light on the surface.

In the scene view, you’ll also notice a Light Fog icon extending from thespotlight icon. When highlighted, it looks like this:

432 | Chapter 9 Rendering

Page 447: Autodesk Maya 2009

The icon displays the region of the potential illumination. You won’t seelight fog under the table. The table blocks the light fog because youpreviously turned on spotlight’s Depth Map Shadows attribute. You canuse the Scale tool on the icon to expand or contract the region of theillumination effect.

Shadows

Shadows are the darkened areas that appear on a surface when an object getsin the path of a light source. Shadows are cast onto the area of a surface thatdoesn’t directly receive light. Shadows ground the objects in your scene andaid in defining their three-dimensional appearance. Shadows can add dramato your scene.

Next, you create a shadow on the floor from the light cast by the spotlight.To do this, you must edit a few of the spotlight’s attributes.

To create shadows using a spotlight

1 Select the spotlight and click the spotLightShape1 tab in the AttributeEditor.

2 Set the Cone Angle to 105.

When you render the scene, you’ll see the spotlight has widened its beamto light up a small part of the back wall. The table and light fixture blocklight and create shadows.

The shadows occur because you turned on Use Depth Map Shadows forthe spotlight earlier in the lesson.

Shadows | 433

Page 448: Autodesk Maya 2009

Depth Map Shadows refers to the algorithm Maya uses to produce shadows.For basic shadowing, you don’t need to know about the algorithm, butyou do need to make sure you turn on Use Depth Map Shadows.

3 To sharpen the shadow’s edges, open the Attribute Editor’s Shadowssection and then the Depth Map Shadow Attributes section. Set theResolution to 1024.

Rendering creates this result:

Increasing the shadow’s resolution increases rendering time. Use a highervalue only if it makes a noticeable difference on the shadows. In this case,the difference is so subtle that you might prefer to use the default value512. In your future projects, keep in mind that higher shadow resolutionvalues can make a big difference in the quality, but also affect renderingtime.

A related attribute, Filter Size, is useful for blurring or softening shadowedges that seem too sharp. Increase the value to increase the blur. Again,higher values increase rendering time.

434 | Chapter 9 Rendering

Page 449: Autodesk Maya 2009

If you are intent on perfecting shadows in your future projects, try variouscombinations of values for Resolution and Filter Size. For this lesson, thedefault values are satisfactory because the shadow edge has minimalcontrast. If you create shadows with sharp contrast at the edges, alteringthe default values will be more desirable.

Creating additional cameras in a scene

Elsewhere in this book, you’ve used the default perspective camera to examineand render your modeling and animation work in progress. In some situations,it is convenient to create and use additional cameras.

For example, you might want to render the scene from two different cameraviews to compare the results. Alternatively, you might want to use the defaultcamera for interactive modeling and animation and the second camera strictlyfor rendering the scene. In the next steps, you create an additional cameraand manipulate its view of the scene.

To create a second camera for the scene

1 Select Create > Cameras > Camera. This creates a perspective camera withan icon representing it at the center of the grid.

2 In the Channel Box, change the name of the camera to myCamera.

Even though you’ve created a new camera, you are still looking at thescene through the default perspective camera named persp. You will viewthe scene through myCamera after you position it in the next step. Ifyou were to view the scene through myCamera now, you would see adisorienting view of the back wall and floor. The camera’s icon points inthe direction of the camera’s view.

The scene’s default persp camera has no icon. An icon is displayed onlyfor a camera you create.

3 Use the Show Manipulator Tool to position myCamera roughly in thisposition:

Creating additional cameras in a scene | 435

Page 450: Autodesk Maya 2009

With a camera selected, the Show Manipulator Tool provides the sametwo manipulators that you used to position the spotlight: eye point andlook-at point. The look-at point sets where the camera aims. The eyepoint sets the position of the camera.

You can select the current camera by selecting View > Select Camera.

4 Select Panels > Perspective > myCamera to view the scene from myCamera.

If your camera view is not similar to the above illustration, selecttableGroup in the Outliner and select View > Frame Selection. This centersthe view of myCamera on the table.

The dolly, track, and tumble movements work the same for myCameraas they do for the default persp camera.

You can return to the view of the persp camera by selecting Panels >Perspective > persp.

5 While working with a camera, it’s useful to know the exact region of themyCamera view that is displayed in rendered images. To see the borderof the render region, select View > Camera Attribute Editor. In theAttribute Editor, open the Display Options section and turn on DisplayResolution. A rectangular border shows the region that will be rendered.

6 In the Film Back section of the Attribute Editor, set the Fit ResolutionGate setting to Overscan.

By enabling the Overscan, the view displays more of the region outsidethe area that will be rendered.

436 | Chapter 9 Rendering

Page 451: Autodesk Maya 2009

By displaying a small part of the scene that lies outside the rendered area,you can plan future camera movement more easily, especially if the scenehas objects that move in and out of view.

Animating camera moves

In Maya, the camera can be animated. You can set keyframes for the cameramoves the same as for other objects in your scene. In the next steps, you setkeys to do a simple animation of the camera’s movement.

To animate the camera

1 Go to the start of the playback range.

2 Dolly, tumble, and track myCamera to create a view similar to this:

3 With myCamera selected, set a key for the camera’s current view at thefirst frame. To set a key, select the Animation menu set, and then selectAnimate > Set Key. (For details on setting keys and animation technique,see Lesson 1: Keyframes and the Graph Editor on page 186.)

Animating camera moves | 437

Page 452: Autodesk Maya 2009

TIP You can undo and redo view changes such as dolly, track, and tumbleby selecting either the [ or ] bracket respectively. You can press these keysrepeatedly to undo or return to a particular view orientation.

4 Go to frame 150.

5 Dolly myCamera to create a view similar to this:

6 Set another key.

7 Play the animation to see the camera dolly toward the table for the first150 frames.

At this point, feel free to experiment with keying changes in the viewresulting from tumbling and tracking the camera. Excessive animationof tumbling and tracking creates a dizzying effect that is a commonmistake of inexperienced artists. In general, it’s best to keep cameraanimation simple except when you are striving for an unusual effect.

Beyond the lesson

In this lesson, you were introduced to some basic techniques related to lightsand cameras in Maya. You learned how to:

n Place two types of lights in your scene and edit their attributes.In addition to the directional light and spotlight you created in this lesson,Maya has several other types of lights for creating nearly any type of naturalor artificial lighting. You might use as few as two lights or as many as 10to get the look you want. Generally, the more lights you create, the longerthe rendering will take.

438 | Chapter 9 Rendering

Page 453: Autodesk Maya 2009

In addition to the light fog effect you created in this lesson, you can alsocreate Glow, Halo, and Lens Flare light effects with a similar workflow. Tosee these effects, the light must point toward the camera view.

In some situations, you might want to prevent a light from striking asurface in its path. For example, your scene shows a person leaning againsta wall in an outdoor night setting. You might want to light the wall withdark, shadowy spotlights, and the person’s face only with a brighter, softspotlight. Because the face and the wall are near each other, all thespotlights currently strike both objects. You can use Maya’s light-linkingcapability to isolate the lighting.

n Create shadows in the scene by having the lights cast shadows.The Maya software renderer has two types of shadows: Depth Map Shadowsand Ray Traced Shadows. In this lesson, you created Depth Map Shadows,which are less realistic than Ray Trace shadows but much faster to render.

Ray Traced Shadows are mainly useful in scenes where the audience isfocusing on the shadow region, for instance, a close-up of a still setting.Ray Traced Shadows are also useful if you want to cast shadows moreaccurately for transparent objects. To reduce rendering time, use Ray TracedShadows only when necessary.

n Create and animate an additional camera from which to view the scene.If you have previous experience with photography, you’ll recognize thenames of various camera attributes displayed in the Attribute Editor whilea camera is selected. You can modify the attribute values to suit yourrequirements.

The values for certain camera attributes (for example, Film Aspect Ratio)might cause a rendered image to not match the region bounded by theResolution Gate. In such cases, you can display the Film Gate (View >Camera Settings > Film Gate) to see the region that will be rendered.

You can animate a camera along a path; for example, to create the illusionof flying through mountainous terrain. This type of animation involvesthe use of Animate > Motion Paths > Attach to Motion Path (from theAnimation menu set). If you additionally want the motion path-animatedcamera to focus on a stationary or moving object, you need to use Create> Cameras > Camera and Aim. If you want the camera to move in a loopingpath, (for example, a roller coaster) you need to use Create > Cameras >Camera, Aim, and Up.

Before you batch render a scene, you must select the camera you want touse for rendering. Select Window > Rendering Editors > Render Settingsto display the Render Settings window. In the File Output section, selectthe camera from the Camera option.

Beyond the lesson | 439

Page 454: Autodesk Maya 2009

Lesson 4: Global Illumination

Introduction

The mental ray® for Maya® renderer can render using a feature called GlobalIllumination. Global Illumination simulates the effect of all lighting andinter-reflection in the scene, whether the items are lit directly by a light sourceor indirectly illuminated by other objects (and diffuse sources of illuminationin the scene).

For example, when a photographer lights an object in a studio, some of thelighting for the object in the final image comes directly from the lights thatare used, while additional illumination comes from objects that are placednear the subject to act as light reflectors. These are referred to as fill cards.Light bounces off the fill cards, indirectly lighting nearby objects with asecondary source of diffuse light. The color of the fill card colors the light thatgets reflected onto the object. The final illumination of the object comes fromthis combination of multiple sources (direct light, specular reflections, anddiffuse light).

440 | Chapter 9 Rendering

Page 455: Autodesk Maya 2009

The Global Illumination feature in the mental ray® for Maya® renderersimulates this effect and provides for a realistic illumination simulation inyour Maya scenes.

In this lesson you learn how to:

n Differentiate between images made with Global Illumination comparedto other lighting types.

n Render an image using Global Illumination by performing repeated testrenders to achieve a final result which includes:n Lighting a scene using the mental ray Global Illumination attributes.

n Adjusting the Global Illumination attributes and quality settings in asystematic manner to achieve a high quality image.

n Visualize photon maps for the scene.

Open the scene for the lesson

In this lesson, you work with a scene we created for your use.

1 Make sure you’ve done the steps in Preparing for the lessons on page 377.

2 Open the scene file named GlobalIllum.ma.

This file can be found in the GettingStarted directory that you set asyour Maya project:

GettingStarted\Rendering\GlobalIllum.ma

Open the scene for the lesson | 441

Page 456: Autodesk Maya 2009

The scene contains a still life with a fruit bowl. Other surfaces act as the floorand walls for the scene. The primary light source is a spotlight. The spotlightcasts light through a vertical opening in the wall. Some areas in the scene aredirectly lit and other areas are not.

Shading materials have already been assigned to the bowl, fruit, and othersurfaces. The apple and orange models are from the previous lessons. If youwant to see what other shaders and textures are in the scene, you can viewthem by opening the Hypershade editor.

When you render this scene using Global Illumination, the effect you wantto achieve is to have the upper and lower regions of the scene receive indirectlight: you want to be able to view more detail in the shadow areas as a resultof the Global Illumination.

Render the scene using raytracing

To better understand the differences in a rendering performed using directlighting methods vs. global illumination, you begin by rendering the sceneusing the mental ray for Maya renderer without using Global Illumination.

You start by performing some preparatory setup and then render the scene.In this section you:

n Select the mental ray for Maya renderer.

n Set the quality setting for your rendering.

n Set the image size for your rendering using the Image Size settings.When performing repeated test renders, a good practice is to render smallimages so the tests render quickly.

n Turn on shadows for the spotlight in the scene.

n Render an image using the mental ray for Maya renderer using raytracing.

Using the mental ray for Maya renderer

To use the Global Illumination feature in Maya you must render using themental ray for Maya renderer.

To render using the mental ray for Maya renderer you need to change therendering type from Maya to mental ray for Maya. You initially render thescene without using Global Illumination.

442 | Chapter 9 Rendering

Page 457: Autodesk Maya 2009

To change the renderer to mental ray for Maya

1 In the main menu, select Window > Rendering Editors > Render Settings(or click the Render Settings icon on the Status Line) to display the RenderSettings window.

2 In the Render Settings window, set the Render Using setting to mentalray.

When you render an image it will now use the mental ray for Mayarenderer.

NOTE When you switch between renderers in Maya (for example, MayaSoftware, Maya Hardware, and mental ray for Maya), the common RenderSettings do not require re-setting.

When you perform repeated test renderings for a particular scene, considerthe time it takes for each render to complete. If you reduce the time it takesto render each test image, the testing process proceeds much faster.

Setting render settings for raytracing

For the first rendering test, you render the scene to see how the scene appearswithout Global Illumination. The testing process proceeds faster if the qualitylevel for the image is initially set low.

To set presets for rendering

1 At the top of the Render Settings window, select mental ray as yourrenderer. Click on the Quality tab and set the Quality Presets setting toDraft.

Render the scene using raytracing | 443

Page 458: Autodesk Maya 2009

The Draft setting ensures low anti-aliasing settings are used and reducesthe rendering time compared to other preset settings. This is a goodpractice when evaluating the lighting and basic material properties inyour test renderings.

Setting the image size for rendering

You set the size that an image is rendered in the Render Settings window. Forthis lesson, you render the image at a size that allows you to evaluate theGlobal Illumination effect.

To set the image size for rendering

1 At the top of the Render Settings window, select the Common tab andopen the Image Size settings.

2 Set the Preset to 320 X 240.

This sets a small image size for your rendering tests. The smaller imagesize renders in less time when compared to a larger image size.

3 Close the Render Settings window.

444 | Chapter 9 Rendering

Page 459: Autodesk Maya 2009

Turning on shadows

Shadows add realism to a scene, and in this lesson, help to demonstrate howa scene rendered using Global Illumination differs from a scene rendered usingdirect illumination.

To turn on shadows for the spotlight

1 Open the Hypershade window (Window > Rendering Editors >Hypershade) and click on the Lights tab to display the lights in the scene.

The scene is lit with one spotlight named spotLightShape1.

2 In the Hypershade window, double-click the icon for spotLightShape1to display the attributes for the spotlight.

3 In the Attribute Editor, click the spotLightShape1 tab to display thelighting attributes for the spotlight. (You may need to minimize theHypershade window to see all of the Attribute Editor.)

4 In the Shadows section, open the Raytrace Shadow Attributes turn onUse RayTrace Shadows. This turns on shadows for the spotlight.

5 Close the Attribute Editor and Hypershade window.

Rendering the image

When you render an image, all of the objects, lighting, shading materials, andimage quality settings are used to calculate the image, based on the particularcamera view that is set.

Render the scene using raytracing | 445

Page 460: Autodesk Maya 2009

To render an image using mental ray for Maya

1 Click in the perspective window. This indicates which camera view youwant Maya to render.

2 On the Status Line, click the Render Current Frame icon to launch therenderer to produce an image.

The Render View window appears and the fruit bowl scene renders usingthe mental ray for Maya renderer.

3 Once the render is complete, click the Keep Image icon in the RenderView window to save this image.

Keeping the image allows you to compare it to any subsequent test rendersyou produce. In this lesson you compare each rendered image to theprevious ones to understand how the changes you make in various settingsaffect the rendered image.

The rendered image shows the fruit bowl lit from the right of the frame.The upper and lower portions of the image are in shadow where the edgesof the wall prevented the spotlight from lighting those portions of thescene. The shadow areas appear dark and do not show any detail of thefloor or walls. This illumination effect is typical of an image producedwith a single light source and direct illumination.

446 | Chapter 9 Rendering

Page 461: Autodesk Maya 2009

Render the scene using Global Illumination

To render using Global Illumination you need to turn on specific settings orattributes. There are two areas that you must initially set.

n Turn on the Global Illumination rendering attributes using the RenderSettings Window.

n Turn on the Global Illumination lighting attributes using the AttributeEditor.

You initially render the scene using the attributes at their default settings tosee how they affect the rendered image and then compare it to the previousraytrace rendering. As you gain more experience rendering with GlobalIllumination you will better understand what settings to initially use.

To turn on Global Illumination rendering attributes

1 Open the Render Settings window.

2 In the Render Settings window, click on the Quality tab and set theQuality Presets setting to Preview: Global Illumination.

This turns on preset attribute settings that enable and control the qualityof the Global Illumination. You initially render the scene using the defaultsettings. Once you’ve rendered an image and observed their effect, youreturn to the Render Settings window and modify the settings accordingly.

3 Close the Render Settings window.

Global Illumination uses photons to simulate the light inter-reflection effectsin a scene. Photons are small packets of energy emitted from a light sourceinto the scene that bounce off surfaces to determine the intensity of light forthose areas not receiving direct illumination. The renderer keeps track of theillumination that results from this photon emission in a file called a photonmap.

In addition to having the spotlight emit light you need to set the spotlight toalso emit photons for the Global Illumination simulation to occur. The overallillumination for the scene will be determined from a combination of the light’sintensity and photon illumination from this single spotlight.

Render the scene using Global Illumination | 447

Page 462: Autodesk Maya 2009

To turn on Global Illumination lighting attributes

1 Open the Hypershade window (Window > Rendering Editors >Hypershade) and click on the Lights tab to display the lights in the scene.

2 In the Hypershade, double-click on the icon for spotLightShape1 todisplay the attributes for the spotlight.

3 In the Attribute Editor, click the spotLightShape1 tab to display thelighting attributes for the spotlight.

4 Open the mental ray section, and in the Caustic and Global Illuminationattributes set the following settings:

n Emit Photons: On

n Photon Intensity: 8000

n Global Illum Photons: 10000

The spotlight emits photons into the scene when you next render animage. Photon Intensity sets the brightness of the Global Illumination.Global Illum Photons sets the number of photons that get emitted intothe scene.

Setting a panel layout for rendering

The process of producing a rendered image usually involves rendering andevaluating successive test images to achieve the desired final image. Thisprocess involves adjusting many render quality, shading, and lighting settingsin specific windows and panels. Opening and closing the various windowscan become tedious.

Displaying the most frequently used windows and panels for rendering allowsyou to work more efficiently without having to open and close themrepeatedly.

To set a panel layout for rendering

1 Close the Render View window.

448 | Chapter 9 Rendering

Page 463: Autodesk Maya 2009

2 From the perspective view’s panel menu, select Panels > Saved Layouts> Hypershade/Render/Persp.

The panel layouts update to display the Hypershade window, RenderView window, and Perspective view simultaneously. This allows you toeasily work with these windows without having to open and close themrepeatedly.

If the image in the Render View window appears pixelated as a result ofthe new panel layout, do the following:

n In the Render View window menu, select View > Real Size. This resizes therendered image to its actual size.

TIP You can resize the panels in a preset layout by dragging the borderbetween neighboring panels using your left mouse button.

Rendering the scene with Global Illumination

Now that the lights are set to emit photons and the Global Illumination presetis selected, you’re ready to render an a test image using Global Illumination.

To render the scene using Global Illumination

1 In the Render View window, click the Redo Previous Render icon to renderthe image with the default Global Illumination settings.

2 When the image has completed rendering, click the Keep Image icon tosave the image.

Render the scene using Global Illumination | 449

Page 464: Autodesk Maya 2009

3 Visually compare this rendered image with the previously renderedimages.

In this rendering, the shadow areas of the scene appear less dark as aresult of Global Illumination. The bowl also appears more transparentthan in the previous rendering.

The effect you want to achieve is to have the shadow regions receiveindirect light; that is, you want to be able to view more detail in theshadow areas as a result of the Global Illumination. To do this, you mustadjust the Global Illumination photon attributes. After you change anattribute, test render the scene to see the effect of this change in therendered image. These repeated test renderings or iterations allow you towork systematically towards the goal of creating the desired final image.

In the next steps you use the Attribute Editor to increase the Photon Intensityto increase the overall Global Illumination for the scene.

Increasing the brightness of Global Illumination

Increasing the Photon Intensity setting increases the brightness of GlobalIllumination. The goal is to provide more visible detail and brightness in theshadow areas of the scene in the next test image.

To increase the Global Illumination lighting

1 In the Hypershade window, double-click on the icon for spotLightShape1to display the attributes for the spotlight.

2 In the Attribute Editor, click the spotLightShape1 tab to display thelighting attributes for the spotlight.

450 | Chapter 9 Rendering

Page 465: Autodesk Maya 2009

3 In the Caustic and Global Illumination attributes adjust the settings tothe following:n Photon Intensity: 120000

Increasing the Photon Intensity increases the illumination in the areasaffected by Global Illumination.

To render the scene

1 In the Render View window, click the Redo Previous Render icon to renderthe image.

2 When the image has completed rendering, click the Keep Image icon tosave the image.

3 Compare this rendered image with the previously rendered images.

The brightness of the illumination in this image has increased as a resultof increasing the Photon Intensity. This is indicated by the increasedbrightness and details seen in the shadow areas of the scene. However,some circular spots have also appeared in the image along the dark wallbehind the bowl. These spots are the result of low photon quality settings.

Adjusting the quality of Global Illumination

The quality of Global Illumination is primarily affected by three attributes:

n The accuracy of sampling (Accuracy)

n The radius size that determines the size of the region surrounding aparticular sampling point (Radius).

n The number of photons (Global Illum Photons).

Render the scene using Global Illumination | 451

Page 466: Autodesk Maya 2009

In the next steps, you return to the Render Settings window and the AttributeEditor to increase the quality attributes that affect the Global Illuminationeffect.

To increase the Global Illumination quality settings

1 In the Render Settings window, click on the Indirect Lighting tab andexpand the Global Illumination section. Change the following GlobalIllumination attributes to:n Accuracy: 900

n Radius: 2.5

The Accuracy setting determines how many photons will be evaluated todetermine the Global Illumination intensity at a given sampling point.Radius determines the size of the region surrounding the particularsampling point. The more photons that get sampled, the more even theGlobal Illumination will appear in the final image.

NOTE As you increase the Global Illumination related quality and photonsettings, the time to render the image also increases. Your goal should be toincrease these settings just enough to achieve the desired image quality,without increasing them beyond what is required so that your renderingtimes are not adversely affected.

2 In the Render View window, click the Redo Previous Render icon to renderthe image.

3 When the image has completed rendering, click the Keep Image icon tosave the image and then compare this rendered image with the previouslyrendered images.

452 | Chapter 9 Rendering

Page 467: Autodesk Maya 2009

When the Accuracy and Radius values are increased, the resulting renderedimage shows the circular spots have almost fully disappeared and theGlobal Illumination is much more uniform when compared to theprevious rendering. Increasing the number of Global Illumination photonsshould aid in making the Global Illumination more uniform.

In the next steps, you increase the number of photons to provide a moreuniform Global Illumination in the scene.

To increase the Global Illumination photons

1 In the Hypershade, double-click on the icon for spotLightShape1 todisplay the attributes for the spotlight.

2 In the Attribute Editor, click the spotLightShape1 tab to display thelighting attributes for the spotlight.

3 In the Caustic and Global Illumination attributes adjust the settings tothe following:n Global Illum Photons: 80000

When you increase the number of Global Illumination Photons you areincreasing the resulting density of the photon map that gets producedat the beginning of the render process. The more photons, the smootherthe resulting Global Illumination. Increasing the number of photons alsoincreases the rendering time.

To render the image

1 In the Render View window, click the Redo Previous Render icon to renderthe image.

Render the scene using Global Illumination | 453

Page 468: Autodesk Maya 2009

2 When the image has completed rendering, click the Keep Image icon tosave the image and compare this rendered image with the previouslyrendered images.

In this image, the circular spots that were seen in the previous renderingshave disappeared. You can observe other Global Illumination effectscompared to the original raytrace rendering:

n Many of the objects have received some additional color fromneighboring objects in the scene as a result of the Global Illumination,an effect known as color bleeding. When color bleeding occurs, objectstake on some of the color from neighboring objects as a result of thereflected and transmitted light.

Now that you’ve tested and refined the Global Illumination for a small imageyou can render a final image for the scene at a larger image size and increasethe rendering quality settings.

To increase the image size and antialiasing

1 In the Render Settings window, select the Common tab and open theImage Size settings.

2 Set the preset to 640 X 480 to render a larger sized image.

3 In the Render Settings window, select the Quality tab.

4 Open the Anti-Aliasing Quality attributes. Leave the Sampling Mode asthe default (Adaptive Sampling) and set the following:

454 | Chapter 9 Rendering

Page 469: Autodesk Maya 2009

n Number of Samples - Max sample level: 1

Sampling is the process for determining the amount of anti-aliasing thatoccurs. The Sample Level attribute sets minimum and maximum limitsfor the amount of sampling that will occur for a given pixel area in theimage. Modifying the anti-aliasing Sample Level settings will ensure thatthe surfaces in the rendered image appear smooth.

A Max value of 1 should provide the correct amount of anti-aliasingsampling for this particular image at this image size.

To render a final image of the scene

1 In the Render View window, click the Redo Previous Render icon to renderthe image.

Render the scene using Global Illumination | 455

Page 470: Autodesk Maya 2009

Beyond the Lesson

In this lesson you were introduced to the Global Illumination features providedby the mental ray® for Maya® renderer. You learned that:

n The mental ray for Maya renderer provides a feature that simulates indirectillumination in the Maya scene called Global Illumination.

n Global Illumination allows you to achieve realistic lighting effects forobjects and areas of the scene that do not receive direct lighting.

n Photons are used to measure the Global Illumination of the scene via thecreation of a photon map.

n The brightness of the Global Illumination in a scene is controlled by thePhoton Intensity.

n The quality of the Global Illumination effect is dependent on the numberof photons emitted into the scene, the Accuracy, and the Radius attributesettings.

n Multiple test renders are often required to achieve the desired final image.

Light sources for Global Illumination

Point, spot, and mental ray area lights can be used as light types for GlobalIllumination with the mental ray for Maya renderer. A Directional light doesnot work as a source for Global Illumination because this light type does nothave a defined point of origin (that is, the rays emit in a parallel manner).

Photon maps

You can visualize the photon mapping that occurs at the beginning of therendering process provided you turn on the Enable Map Visualizer option inthe Caustics and Global Illumination > Photon Tracing section of the RenderSettings window. To view a visualization of the photon mapping, selectWindow > Rendering Editors > mental ray > Map Visualizer.

456 | Chapter 9 Rendering

Page 471: Autodesk Maya 2009

Visualizing the photon mapping can aid in determining whether the coverageand density of photons for the scene is appropriate for the resulting finalimage.

By default, the mental ray for Maya renderer rebuilds the photon map eachtime you render a scene using Global Illumination. If you are rendering ascene containing camera animation in which the objects and lights remainstatic, or rendering several iterations of a single image, you may considerturning off the Rebuild Photon Map setting in order to reduce the renderingtimes for each frame.

Beyond the Lesson | 457

Page 472: Autodesk Maya 2009

Lesson 5: Caustics

Introduction

Caustics are the light effects and specular patterns that are cast on surfaces asa result of focused light reflecting off highly reflective surfaces or refractingthrough translucent surfaces.

The light patterns that occur on the bottom of a swimming pool on a sunnyday, or the bright areas that occur in the shadow of a glass object as lightshines through it are examples of caustics.

The Caustic feature in the mental ray® for Maya® renderer simulates causticeffects in your Maya scenes. Caustics are similar to Global Illumination in thatthey are an indirect illumination effect.

In this lesson you learn how to:

n Create the shadow effect that results from the refraction and concentrationof light through a transparent object, using the Caustic feature providedin the mental ray for Maya renderer.

458 | Chapter 9 Rendering

Page 473: Autodesk Maya 2009

n Adjust refraction level limits in order to achieve desired refractive effectswith transparent objects.

n Systematically perform test renders and adjust the render and causticquality settings in order to achieve a high quality image.

Open the scene for the lesson

In this lesson, you work with a scene we created for your use. In the first stepsof this lesson, you open the scene and view the various elements that havebeen preset for your use.

1 Make sure you’ve done the steps in Preparing for the lessons on page 377.

2 Open the scene file named CausticStart.ma.

This file can be found in the GettingStarted directory that you set asyour Maya project:

GettingStarted\Rendering\CausticStart.ma

The scene contains a still life with a translucent bottle and apples. Othersurfaces act as the floor and walls for the scene. (The bottle appears opaquewhen viewed in shaded and textured display mode.)

Two lights illuminate the scene: a spotlight and a point light.

Shading materials have already been assigned to the models and surfaces.You can view the shaders and textures by opening the Hypershade editor.

When you initially render this scene, the objects cast shadows onto thefloor surface. Caustics are added to the lighting of the scene to create amore realistic shadow for the translucent bottle.

Open the scene for the lesson | 459

Page 474: Autodesk Maya 2009

Render the scene using raytracing

To better understand the differences between caustics versus other lighting,you begin by rendering the scene using the mental ray for Maya rendererwithout using Caustics.

You start by preparing the scene and then rendering. In this section you:

n Set a panel layout for rendering

n Turn on shadows for the spotlight

n Turn on the mental ray for Maya renderer

n Set the image size for your rendering

n Set the image quality preset

n Render the image using raytracing

Setting a panel layout for rendering

Producing a rendered image usually requires that you render test images toachieve the final result. This may involve adjusting many render quality,shading, and lighting settings. Opening and closing the various windows canbecome tedious.

Keeping the most frequently used windows and panels open allows you towork more efficiently.

In the following steps, you select a panel layout to work more efficiently withthe various panels and windows.

To set a panel layout for rendering

1 From the perspective view’s panel menu, select Panels > Saved Layouts> Hypershade/Render/Persp.

460 | Chapter 9 Rendering

Page 475: Autodesk Maya 2009

The panel layouts update to display the Hypershade window, RenderView window, and Perspective view simultaneously.

When you render an image, it appears in the Render View window.

TIP You can resize the panels in a preset layout by dragging the borderbetween neighboring panels using your left mouse button.

Turning on shadows

In this lesson, you learn how the bottle’s shadow can be made to appear morerealistic as a result of the caustics.

To turn on shadows for the spotlight

1 In the Hypershade window, click the Lights tab.

The Hypershade displays icons for the two lights in the scene.

2 In the Hypershade window, double-click the icon for spotLightShape1.

The Attribute Editor appears.

Render the scene using raytracing | 461

Page 476: Autodesk Maya 2009

3 In the Attribute Editor, click the spotLightShape1 tab to display thelighting attributes for the spotlight.

4 In the Shadows section, open the Raytrace Shadow Attributes and turnon Use RayTrace Shadows.

When you render the scene, shadows are cast by the spotlight.

5 Hide the Attribute Editor by clicking the Show/Hide Attribute Editor iconon the Status Line.

Using the mental ray for Maya renderer

To use the Caustics feature in Maya you must render using the mental ray forMaya renderer.

To turn on the mental ray for Maya renderer

1 In the main menu, select Window > Rendering Editors > Render Settings(or click the Render Settings icon in the Render View window).

2 In the Render Settings window, set the Render Using setting to mentalray.

462 | Chapter 9 Rendering

Page 477: Autodesk Maya 2009

Setting the image size for rendering

You set the size that an image will be rendered in the Render Settings window.For this lesson, you render the image at a size that allows you to evaluate thecaustic effect.

To set the image size for rendering

1 At the top of the Render Settings window, select the Common tab andopen the Image Size settings.

2 Choose the 640 X 480 preset from the Presets drop-down list.

Setting render presets for raytracing

For the first rendering, you render the scene to see how the shadows appearwithout using caustics.

To set Render options for raytracing

1 In the Render Settings window, select the Quality tab and set the QualityPresets setting to Production.

The Production preset ensures that the refraction level settings (found inRaytracing Quality section) are at a level high enough to render objectswith translucency (for example, the bottle). The Production preset alsosets the anti-aliasing level for the image.

2 Close the Render Settings Window.

Render the scene using raytracing | 463

Page 478: Autodesk Maya 2009

Rendering the image

When you render an image, all of the objects, lighting, shading materials, andimage quality settings are used to calculate the image, from the camera’s view.

To render an image using mental ray for Maya

1 Click in the perspective window to indicate which view you want torender.

2 In the Render View window, click the Render Current Frame icon.

The bottle scene renders using the mental ray for Maya renderer and theimage appears in the Render View window.

.

TIP If the rendered image appears either too small or too large in the RenderView window, select View > Frame Image from the Render View menu to fitthe image to the Render View.

3 Once the render is complete, click the Keep Image icon in the RenderView window.

Keeping the image allows you to compare it to any subsequent testrenders. In this lesson you compare each successive rendered image tothe previous one to observe how the changes you make to render settingsaffect the rendered image.

464 | Chapter 9 Rendering

Page 479: Autodesk Maya 2009

The rendered image shows the following:

n A translucent bottle with apples beside it casting shadows towardsthe rear of the scene. Notice how the shadows appear when raytracerendered.

n The distortion of the table surface in the translucent glass effect basedon the refractions and reflections.

n A dark region on the surface of the bottle. This results from the bottlereflecting the empty black area of the scene in front of it.

In the next section, you turn on the caustics rendering attributes and renderthe scene.

Render the scene using caustics

To render using caustics you need to turn on specific settings or attributes.There are two sets of caustic-related attributes that you must initially set.

n Turn on the caustics-related rendering attributes using the Render Settingswindow.

n Turn on the caustics-related lighting attributes using the Attribute Editor.

You initially render the scene using these attributes at their default settingsto see how they affect the rendered image and then compare it to the previousraytrace rendering. As you gain more experience rendering with Caustics youwill better understand what settings to initially use.

Render the scene using caustics | 465

Page 480: Autodesk Maya 2009

To turn on the caustics preset settings

1 In the Render Settings window, select the Quality tab and set the Qualitypresets setting to PreviewCaustics.

This turns on the presets that control the quality of the caustics.

2 Close the Render Settings window.

Mental ray for Maya uses photons to simulate the caustic effects in a scene.Photons are small packets of energy emitted from a light source into the scene.The photons travel throughout the scene, refracting through transparentobjects or reflecting off reflective surfaces. The renderer keeps track of theillumination that results from this photon emission in a file called a photonmap. The overall caustic simulation is determined from the photon calculationsthat result.

In addition to having the spotlight emit light into the scene you set the lightto also emit caustic photons. The overall caustic effect is determined from thephoton calculations that result.

To turn on the caustics lighting settings

1 In the Hypershade, double-click on the icon for spotLightShape1.

2 In the Attribute Editor, click the spotLightShape1 tab to display thelighting attributes for the spotlight.

3 Open the mental ray section, and in the Caustic and Global Illuminationattributes set:n Emit Photons: On

n Photon Intensity: 8000

466 | Chapter 9 Rendering

Page 481: Autodesk Maya 2009

n Caustic Photons: 10000

4 Hide the Attribute Editor.

Rendering the scene with caustics

Now that the lights are set to emit caustic photons and the caustics preset isturned on, you’re ready to render an image using caustics.

To render the scene using caustics

1 In the Render View window, click the Redo Previous Render icon.

2 When the image has completed rendering, click the Keep Image icon.

3 Compare this rendered image with the previously rendered image bydragging the scroll bar at the bottom of the Render View window left andright.

This image differs from the previous one in the following ways:

n The bottle appears more opaque. This indicates that the correctnumber of refractions may not be occurring. The Raytracing Refraction

Render the scene using caustics | 467

Page 482: Autodesk Maya 2009

Level setting may need to be increased. When a different preset wasselected (Production to Preview), the refraction levels changed.

n There are spotted areas on the table surface directly in front of thebottle. This can be corrected by adjusting the photon quality settings.

n The desired caustic effect in the shadow has appeared but is not verypronounced. You want to achieve an effect where the shadow hasbrighter regions as a result of light being refracted through the surfacesof the bottle.

Adjusting the refraction levels

When the refraction levels are set too low, light rays do not refract throughall of the surfaces enough to provide a realistic indication of a translucentsurface when raytraced. This results in the object appearing opaque when itshould appear translucent.

Increasing the Refractions setting allows the renderer to calculate what is seenthrough the surfaces of the glass by allowing the light rays to refract the correctnumber of times.

In the next step, you change the Refraction settings so that the bottle willappear translucent when rendered.

To increase the refraction levels

1 In the Render Settings window, select the Quality tab and then open theRaytracing attributes.

2 In the Raytracing section set the following:n Refractions: 6

n Max trace depth: 8

The Refractions setting sets the number of times a light ray can be refracted.When the setting is too low the ray does not penetrate through all of thesurfaces. The Max Trace Depth setting limits the total Refraction andReflection settings. By setting it to 8, you ensure that two reflection andsix refraction calculations can occur.

Photons refract in a manner similar to light rays when rendering. Increasingthe Refractions setting for the Caustic Photons ensures that the renderer cancorrectly calculate the caustics that should occur with the bottle. In this case,

468 | Chapter 9 Rendering

Page 483: Autodesk Maya 2009

matching the Caustic Photon refraction settings with the Raytracing refractionsis a good practice.

To increase the photon refraction settings

1 In the Render Settings window, select the Indirect Lighting tab.

2 In the Photon Tracing section set the following:n Max Photon Depth: 6

n Photon Refractions: 6

The Max Photon Depth setting limits the Refraction and Reflectioncalculations for the Caustic Photons to the limit set. The Photon Refractionssetting is similar to the Refractions setting for raytracing but sets therefractions for the Caustic photons. Close the Render Settings window.

Increasing the brightness of caustics

Increasing the Photon Intensity setting increases the brightness of the refractedcaustic that appears in the shadow of the bottle.

To increase the Photon Intensity

1 In the Hypershade window, double-click the icon for spotLightShape1to display the attributes for the spotlight.

2 In the Caustic and Global Illumination attributes for the light adjust thesettings to the following:n Photon Intensity: 36000

To render the scene

1 In the Render View window, click the Redo Previous Render icon to renderthe image.

2 Once the render is complete, click the Keep Image icon in the RenderView window to save this image.

3 Compare this rendered image with the previously rendered images.

Render the scene using caustics | 469

Page 484: Autodesk Maya 2009

The translucency of the glass now appears more realistic. The causticeffect is more evident in the shadow of the bottle. However, the spottedeffect, that appeared on the surface in front of the bottle, is morepronounced. These spots are the result of a low caustics quality setting.

Adjusting the quality of caustics

The quality of the caustic effects in a scene is primarily affected by the numberof photons, the accuracy of sampling, and the radius surrounding the sampledarea of illumination. (If you have previously completed the Global Illuminationtutorial, you may notice similarities in this area.)

In the next steps, you return to the Render Settings window and the Attributeeditor to increase the quality attributes that affect the caustics effect.

To increase the caustics quality settings

1 In the Render Settings window, open the Caustics and Global Illuminationattributes and change the following Caustics attributes to:n Accuracy: 900

n Radius: 1.5

470 | Chapter 9 Rendering

Page 485: Autodesk Maya 2009

The Accuracy determines how many photons will be evaluated todetermine the Caustic intensity at a given sampling point. Radiusdetermines the size of the region surrounding the particular samplingpoint. The more photons that get sampled, the more realistic the causticeffect appears in the final image.

2 Close the Render Settings window.

Increasing the number of caustic photons that get emitted into the scene alsoincreases the quality of the caustic effect. When you increase the number ofcaustic photons you increase the density of the resulting photon map thatgets produced at the beginning of the render process. The more photons, thesmoother the resulting caustics effect.

NOTE As you increase the caustic quality and photon settings so will the rendertime. Your goal should be to increase these settings just enough to achieve thedesired image quality, without increasing them beyond what is required so thatyour rendering times are not adversely affected. Performing test renderings is thebest method to determine these settings.

To increase the number of caustic photons

1 In the Hypershade window, double-click the icon for spotLightShape1.

2 In the Caustic and Global Illumination attributes, adjust the followingsettings:n Caustic Photons: 50000

3 In the Render View window, click the Redo Previous Render icon.

4 When the image has completed rendering, click the Keep Image icon andcompare this rendered image with the previously rendered images.

Render the scene using caustics | 471

Page 486: Autodesk Maya 2009

In this image the bright spots in front of the bottle should be reducedwhen compared to the previous images. The caustic in the bottle’s shadowshould also appear more pronounced and more evenly illuminated.

Beyond the Lesson

In this lesson you were introduced to the caustic features provided by themental ray® for Maya® renderer. You learned that:

n Caustics provide additional realism in a rendered image by simulating thefocusing of light on diffuse surfaces as a result of the light reflecting offspecular surfaces or via the refraction of light through translucent surfaces.

n Photons are used to determine the caustic effect in a scene via the creationof a photon map.

n The brightness of the caustic is controlled by the Photon Intensity attribute.

n The quality of the caustic effect is controlled by the number of photonsemitted into the scene, the Accuracy, and the Radius attributes.

n Multiple test renders are often required to achieve the desired final image.

472 | Chapter 9 Rendering

Page 487: Autodesk Maya 2009

Light sources for caustics

Point, spot, and mental ray area lights can be used as light types for causticswith the mental ray for Maya renderer. A Directional light does not work asa source for Caustics because this light type does not have a defined point oforigin (that is, the rays emit in a parallel manner).

Photon maps

You can visualize the photon mapping that occurs at the beginning of therendering process provided you turn on the Enable Map Visualizer option inthe Caustics and Global Illumination section of the Render Settings window.To view a visualization of the photon mapping, select Window > RenderingEditors > mental ray > Map Visualizer.

Visualizing the photon mapping can aid in determining whether the coverageand density of photons for the scene is appropriate for the resulting finalimage.

By default, the mental ray for Maya renderer rebuilds the photon map eachtime you render a scene using Caustics. If you are rendering a scene containingcamera animation in which the objects and lights remain static, or renderingseveral iterations of a single image, you may consider turning off the RebuildPhoton Map setting in order to reduce the rendering times for each frame.

Beyond the Lesson | 473

Page 488: Autodesk Maya 2009

474

Page 489: Autodesk Maya 2009

Dynamics

IntroductionDynamics is a branch of physics that describes how objects move using physicalrules to simulate the natural forces that act upon them. Dynamic simulationsare difficult to achieve with traditional keyframe animation techniques.

Maya provides a means to do this type of computer animation where you setup the conditions that you want to occur, then let the software solve how toanimate the objects in the scene. Maya® Dynamics™ provides the tools forcreating effects that will enhance your final images and animations.

With Particle Effects, you can create the illusions of smoke, fireworks, rain, fire,and explosions.

With Rigid Body Dynamics, you can simulate real-world physical interactionsbetween objects, such as collisions between surfaces. For example, you cansimulate a bowling ball crashing through pins or simulate the effects of gravitywhen a ball falls to the ground. You can also simulate natural forces, such aswind.

This chapter contains the following lessons:

n Lesson 1 Particles, emitters, and fields: Introduction on page 476

n Lesson 2 Rigid bodies and constraints: Introduction on page 494

10

475

Page 490: Autodesk Maya 2009

Preparing for the lessonsDo these steps to ensure the lessons in this chapter work as described:

1 Select File > New Scene to create a new scene before you start each lesson.

2 If you have not already done so, copy the GettingStarted folder fromits installation location to your projects directory. Then, set theGettingStarted directory as your Maya project. For more information,see Copying and setting the Maya project on page 25.

3 Select Window > Settings/Preferences > Preferences. Click Timeline underCategories and make sure the Playback Speed is set to Play every frame.Dynamic animation plays more accurately with this setting.

4 Select the Dynamics menu set. Unless otherwise noted, the directions inthis chapter for making menu selections assume you’ve already selectedthe Dynamics menu set.

NOTE Before you perform the lessons in this book, ensure that the InteractiveCreation option for primitives is turned off by selecting Create > NURBSPrimitives > Interactive Creation. That is, ensure a check mark does not appearbeside the menu item.

Lesson 1: Particles, emitters, and fields

Introduction

Particles are points that display as dots, streaks, spheres, or other shapes.Particles can have attributes applied to them so they animate and render tosimulate natural phenomena.

You can create particles by clicking positions in the scene view, or you cancreate them with an emitter that shoots particles into view.

To animate particles, you typically apply fields such as gravity or wind. Bycombining emitters, particles, and fields, you can create natural phenomenasuch as smoke, fireworks, or rain.

476 | Chapter 10 Dynamics

Page 491: Autodesk Maya 2009

In this lesson, you will be introduced to some of the basic concepts of particlesand use particles, emitters, and volume fields to create a fountain-like effect.In this lesson, you learn how to:

n Create a particle emitter in your scene.

n Create a field to direct the movement of particles.

n Use a volume shape to control the movement of particles.

n Work with particle attributes.

n Color particles.

n Use a color ramp to add colors to the particles.

n Render the particles using hardware rendering.

Creating an emitter

Emitters create particles as an animation plays. The emitter controls theposition, direction, quantity, and initial velocity of the emitted particles whenthey are born. After particles are born, the attributes of the particle objectcontrol their appearance.

You can make a standalone emitter, or you can make a surface, curve, andeven another particle an emitter. You move an emitter the same way youmove any geometry, such as setting keys or parenting it to a moving object.

In the next steps, you create a circle and emit particles from it.

To create a particle emitter

1 Make sure you’ve done the steps in Preparing for the lessons on page 476.

2 Set the start frame to 1 and end frame to 120.

Creating an emitter | 477

Page 492: Autodesk Maya 2009

3 Select Create > NURBS Primitives > Circle > . In the options window,set the following options and click Create:n Radius: 4

n Number of Sections: 25

With Radius set to 4, the circle will be wide enough to see the particleemission clearly. With Number of Sections set to 25, the emission willbe distributed evenly from points around the circle.

Note that the illustrations in this chapter show the grid with a customblue color and numbered lines so that the shape and size of the objectsyou create are easier to distinguish. (If you want to change the grid color

in your scene, select Display > Grid > .)

4 With the circle selected, select Particles > Emit from Object.

By default, this creates an Omni emitter. If you dolly toward the centerof the grid, you can see a tiny icon that represents the emitter. Whenyou create an Omni emitter on a NURBS object, for instance, a circle,each control vertex (CV) of the object emits particles in all directions.

5 Play the animation for a few seconds to see the emission.

The particles begin to emit from the object. When you create any typeof emitter, a particle object is automatically created and connected to it.

The connected particle object originally has no particles and is thereforeinvisible. As the animation plays and the emitter generates particles, the

478 | Chapter 10 Dynamics

Page 493: Autodesk Maya 2009

particle count of the connected particle object increases. When you goto the start of the animation, the particle count returns to 0.

Note that if you had created the circle with a smaller Number of Sections,there would be fewer CVs for the circle and therefore bigger gaps betweenthe emission points on the circles.

6 Display the Outliner (Window > Outliner).

7 In the Outliner, select particle1.

This is the particle object. A particle object is a collection of particles thatshare the same attributes. You can create particle objects containing asingle particle or millions of particles. Each particle in a scene belongs tosome particle object.

The particle object’s attributes define the appearance and othercharacteristics of the emitted particles. The emitter’s attributes controlthe initial position, direction, quantity, and velocity of the emittedparticles.

Creating volume axis fields

Fields are forces that you use to animate the motion of particles. With a VolumeAxis field, you can move particles in various directions within the volume ofa cube, sphere, cylinder, cone, or torus. With clever use of this type of field,you can create effects such as particles flowing around obstacles, solar flares,explosions, tornadoes, and rocket exhaust.

In the next steps, you’ll use a volume axis field to move the particles up aconical path. When the particles exit the top of a conical region, you’ll useanother volume axis field to give them a downward arcing motion within atorus. The result resembles a fountain of light.

To create a cone volume axis field

1 With the particle object still selected, select Fields > Volume Axis > .

2 Set the following Volume Axis Options and click Create:n Magnitude: 50

n Volume Shape: Cone

n Away From Axis: 0

n Along Axis: -1

Creating volume axis fields | 479

Page 494: Autodesk Maya 2009

NOTE If any of these options are not visible, enlarge the Volume AxisOptions window.

This creates a conical Volume Axis field that affects the motion of particlesthat enter or exist within its volume. Particles move in relation to a centralaxis within the volume. For a Cone Volume Shape, the central axis is thepositive Y axis:

Using the axis attributes, you can specify that the particles:

n move in a direction roughly parallel to the axis toward or away from thepoint of the cone (Along Axis)

n radiate outward or inward relative to the axis (Away From Axis)

n swirl around the axis (Around Axis)

n move in a direction based on a combination of these directionsBy setting Along Axis to -1, the particles move toward the point of thecone. (A positive value would move particles in the opposite direction.)In the next step, you’ll flip the cone 180 degrees so the aim of the coneand particles is upward.

By using 0 for the Away From Axis value rather than the default value of1, the particles will not radiate away from the axis.

480 | Chapter 10 Dynamics

Page 495: Autodesk Maya 2009

Note that you can use larger or smaller values for the Axis attributes tointensify or diminish movement.

Magnitude specifies the strength of the volume axis field. The greater thevalue, the more force is exerted on the particles.

You’ll typically need to experiment with various Volume Axis field attributevalues to achieve a desirable motion for particles. Be aware that smallarrow-shaped icons within the Axis Field icon show which direction theparticles will go.

1 With the Volume Axis field still selected, set the following values in theChannel Box:n TranslateY: 13

n RotateZ: 180

n ScaleX: 5

n ScaleY: 13

n ScaleZ: 5

This positions, rotates, and scales the volume axis field so that its baselies on the same plane as the circle emitter. Even though the circle emitsparticles in random directions, the volume axis field will redirect theirmotion up the cone.

2 Go to the start of the playback range and play the animation for a fewseconds.

Creating volume axis fields | 481

Page 496: Autodesk Maya 2009

When the particles move out of the conical region, they continue in thesame direction, mirroring the pattern of movement within the conicalregion. The volume axis field no longer controls the motion, but theparticles continue with the same speed and direction they had at themoment they exit.

To create a torus volume axis field

1 In the Outliner, select the particle object

2 From the main menu, select Fields > Volume Axis > .

3 Set the following Volume Axis Options and click Create:n Magnitude: 25

n Volume Shape: Torus

n Section Radius: 1.5

n Away From Axis: - 0.7

n Along Axis : 0.0

n Around Axis: 2

The Torus Volume Shape creates a volume shaped like a doughnut.

482 | Chapter 10 Dynamics

Page 497: Autodesk Maya 2009

Section Radius defines the thickness of the torus.

A value of 2 for Around Axis causes the particles to swirl around thecentral axis. For a torus, the central axis is the ring in the center of thesolid part of the torus.

A value of -0.7 for Away From Axis causes the particles to move radiallytoward the central axis.

When you later play the animation, the combination of these valuescause the particles to loop up then down as if guided along the innerwalls of a torus.

Again, achieving the desired motion for particles within a volume axisfield requires experimentation with attribute values. Examine the arrows

Creating volume axis fields | 483

Page 498: Autodesk Maya 2009

and other small icons within the axis volume field to help get the desiredresults.

Note that the field’s effect is pervasive enough that all particles passingthrough the hole of the torus are influenced by the field. You can causeparticles to pass through the hole by altering the Max Distance andAttenuation.

4 With the torus volume field still selected, enter the following values inthe Channel Box:n TranslateY: 15

n ScaleX: 3.6

n ScaleY: 3.6

n ScaleZ: 3.6

This moves the torus volume field up 15 units and scales it larger. Findingthe appropriate position for the volume axis field is a matter ofexperimentation.

5 Go to the start of the playback range and play the animation.

When the particles move through the top of the cone region, they spreadoutward somewhat but do not follow the shape of the torus volume fieldas specified in the prior steps. You’ll correct this situation in the nextsteps.

484 | Chapter 10 Dynamics

Page 499: Autodesk Maya 2009

Adjusting the velocity of moving particles

The torus volume axis field doesn’t guide the motion of the particles asexpected because the initial emission velocity of the particles dominates themotion of the particles rather than the field. You can use a particle object’sConserve attribute to scale down the emission velocity’s influence and increasethe field’s influence.

To adjust the velocity of moving particles

1 Select the particle object and set the Conserve attribute to 0.8 in theChannel Box.

By changing the Conserve value from the default value, 1, to 0.8, theemission velocity’s influence on the particle motion decreases and thefield’s influence increases.

2 Go to the start of the playback range and play the animation. Notice howthe particle movement now conforms to the shape of the torus volumefield.

Setting the particle render type

The particle render type of a particle object determines how the particles lookwhen rendered. For example, you can display particles as small spheres, streaks,or 2D images (known as sprites) of your favorite snapshot. Once you select

Adjusting the velocity of moving particles | 485

Page 500: Autodesk Maya 2009

the particle render type, you can add attributes specific to the render type toadjust the appearance.

To set the particle render type

1 With the particle object still selected, display the Attribute Editor, andselect the particleShape1 tab.

2 Scroll down to the Render Attributes section, and set the Particle RenderType to Streak.

3 Go to the start of the playback range and play the animation.

The Streak render type displays moving particles with an elongated tail.This render type enhances the display of objects such as meteors, and it’soften used to create rain. The streak length is based on the velocity ofthe particle, so if the particles are stationary or moving slowly and therender type is set to streak, you won’t see the particles.

Adding dynamic attributes

To maximize the display versatility of particle render types, you need to addbuilt-in dynamic attributes to the particle object. When you add a dynamicattribute to an object, the attribute appears in the Attribute Editor for theselected object.

486 | Chapter 10 Dynamics

Page 501: Autodesk Maya 2009

To add dynamic attributes

1 In the Attribute Editor, under the Render Attributes section, click theCurrent Render Type button next to Add Attributes.

2 Observe the attributes that are added.

3 Set the following attributes:

2Line Width This sets the width of eachstreak.

This sets the opacity of thetail fade; it can range from

0.5Tail Fade

0 to 1. A value of 1 makesthe tail completely opaque;a value of 0 makes the tailtransparent.

This scales the length of thetail. A value of 1 is the de-

2Tail Size

fault length. Values lessthan 1 shorten the tail; val-ues greater than 1 lengthenthe tail.

You can experiment with these settings to change the look of the particles.

Adding dynamic attributes | 487

Page 502: Autodesk Maya 2009

Adding per particle attributes

Particle objects have two different kinds of attributes: per object and perparticle.

A per object attribute lets you set the attribute value for all particles of theobject collectively with a single value. For instance, the per object colorattribute lets you set a single color for all the particles in the object.

A per particle attribute lets you set the value of the attribute individually foreach particle of the object. For example, the per particle rgbPP attribute letsyou set a unique color for each particle. Though there is only one rgbPPattribute in a particle object, the attribute holds the value for each particle’scolor value. The attribute holds the values in an array. An array is similar toa list. Arrays are appropriate for storing data which must be accessed in anunpredictable order, in contrast to lists which are best when accessedsequentially.

Although per particle attributes are best for creating complex effects, you can’tkeyframe them. You can keyframe per object attributes. In this lesson, youadd a per particle color attribute so you can give different particles differentcolors.

To add a per particle color attribute

1 In the Attribute Editor, expand the Add Dynamic Attributes section, ifnecessary.

2 Click the Color button. The Particle Color box is displayed,

3 Turn on the Add Per Particle Attribute and click Add Attribute. Noticethe rgbPP attribute that is added to the Per Particle (Array) Attributessection of the Attribute Editor.

488 | Chapter 10 Dynamics

Page 503: Autodesk Maya 2009

Adding color to particles with a color ramp

A ramp texture is a patterned 2D image in which the color blends from oneshade to another. In the next steps, you use a color ramp to color the particlesas they age.

To add color to particles using a color ramp

1 In the Attribute Editor, right-click the rgbPP data box and select CreateRamp from the drop-down menu.

This causes a default color ramp to color the particles as follows:

As each particle ages from its time of birth (emission), its color changesaccording to the ramp’s color in an upward vertical (V) direction. Thehorizontal (U) direction of the ramp’s color is unused in this lesson.

When you create the ramp, Maya adds a lifespan attribute and sets it to1 second, by default. Each particle changes from red to green to blue overits lifespan of 1 second. The particle then disappears (dies).

2 From the perspective window menu, select Shading > Smooth Shade All.

This enables you to see the colors of the particles the next time you playthe animation.

3 Go to the start of the playback range and play the animation. Notice theparticles never reach the end of the cone volume.

Adding color to particles with a color ramp | 489

Page 504: Autodesk Maya 2009

This is because the Lifespan is set to the default of 1, which is the numberof seconds the particles exist in the animation.

4 In the Channel Box, set Lifespan to 3. Go to the start of the playbackrange and play the animation.

Because the particles live longer, they pass all the way through the coneand part of the way through the torus. The particles change from red togreen to blue and disappear as they are born, age, and die.

490 | Chapter 10 Dynamics

Page 505: Autodesk Maya 2009

Hardware rendering particles

In 3D animation, rendering typically refers to the act of creating a sequenceof high-quality image snapshots for each frame of an animation sequence.After rendering the images, you play them in sequence to create a film orvideo clip. If the concept of 3D animation rendering is new to you, considerdoing the lesson Lesson 1: Rendering a scene on page 377 before completingthis section.

You cannot render most particle render types, including streaks, with Maya’ssoftware renderer. You must hardware render the particles.

Hardware rendering uses your computer’s graphics hardware to render a sceneto disk and monitor faster than software rendering. Hardware renderinggenerally displays surface shading and textures less accurately than softwarerendering, so most people use it only to render particle effects.

In the following steps, you test render the last frame of the scene to make surethe particles look satisfactory. Next, you render the entire frame sequence todisk and then play the rendered images with the flipbook feature.

To test render the scene

1 Select Window > Rendering Editors > Hardware Render Buffer. Thisdisplays a window from which you hardware render the scene.

2 In the Hardware Render Buffer, go to the start frame and click the playbutton. Stop the animation at frame 75.

You must play the particle animation from the beginning in order forparticle effects to be displayed correctly at each frame. You cannot godirectly to an arbitrary frame in the Time Slider and see correct results.Maya calculates particle animation sequentially frame-by-frame.

3 In the Hardware Render Buffer, select Render > Test Render.

Hardware rendering particles | 491

Page 506: Autodesk Maya 2009

The streaks look smoother than they do in the scene view. You canimprove the streaks even more as shown in the next steps.

4 In the Hardware Render Buffer window, select Render > Attributes.

The Attribute Editor appears.

5 In the Attribute Editor, under the Render Modes section, turn on LineSmoothing. This softens jagged edges when you hardware render Streakor MultiStreak render types.

6 To see the softened edges, select Render > Test Render.

If you click in the Hardware Render Buffer window, the rendered imagedisappears. If this occurs, select Render > Test Render again to redisplaythe image.

To render the sequence and playback the results

1 In the Hardware Render Buffer window, select Render > Attributes todisplay the Attribute Editor.

2 Set the Hardware Render Buffer settings as follows:

EmitFilename This name will be the baseof the filenames createdwhen you render all framesto images on disk.

This specifies the first frameof the animation sequenceto be hardware rendered.

1Start Frame

This specifies the last frameto be hardware rendered.

75End Frame

Other attributes in the Attribute Editor specify the image resolution, fileformat, lighting, and other display characteristics.

3 Make sure that no other windows overlap the Hardware Render Bufferor that your screensaver may accidentally launch while you use thisfeature. When you hardware render a frame sequence to disk, Mayarenders whatever exists within the borders of the Hardware Render Bufferwindow.

4 In the Hardware Render Buffer window, select Render > Render Sequence.

492 | Chapter 10 Dynamics

Page 507: Autodesk Maya 2009

This creates a series of files named Emit.0001, Emit.0002, and so on,through Emit.0075. These files are the rendered frames 1 through 75.Maya puts the files in your current project’s images directory.

5 To play the hardware-rendered sequence, select Flipbooks > Emit.1-75.

6 Close the FCheck image viewing window when you are finishedexamining the animation.

Beyond the lesson

In this lesson you were introduced to a few of the basic concepts when usingparticles. You learned how to:

n Create particles from a source object called an emitter.When you create any type of emitter, a particle object is also automaticallycreated and connected to it. Emitters can be points (CVs, vertices), surfaces(NURBS, polygons), curves (NURBS curves) or volumes (spheres, cylinders).

n Control particles using fields, and volume objects.With volume axis fields, you can funnel or swirl particles within theboundaries of common volumetric shapes. Although this lesson showedhow to use a pair of volume axis fields to control the motion of particles,Maya has several other types of fields such as Gravity and Turbulence forsimulating natural phenomena. You can use the fields to animate themotion of curves and surfaces in addition to particles.

n Change the color of particles using a ramp texture.You can also change ramp colors by editing other ramp attributes, such asNoise and Noise Frequency. To do so, right-click the attribute box for rgbPP,then select arrayMapper1.outColorPP > Edit Ramp. See the Maya Help fordetails on ramp attributes. You can also control other particle attributeswith ramps; for example, opacity. See the Maya Help for more information.

n Render particles using the hardware renderer.The majority of particle rendering types are visible only when using thehardware render. Software rendering does not display them. However, ifyou use a particle render type of Blobby Surface, Cloud, or Tube, you mustrender the particles using the software renderer as hardware rendering doesnot display those types.

If you create a scene that includes both particles and geometric surfaces,you may need to render the scene twice, once with hardware rendering

Beyond the lesson | 493

Page 508: Autodesk Maya 2009

and once with software rendering. In such cases, you’ll need to compositethe two sets of rendered images using a compositing software package.

Lesson 2: Rigid bodies and constraints

Introduction

In Maya, a rigid body is a surface which has the attributes of an unyieldingshape. Unlike conventional computer surfaces, rigid bodies collide rather thanpass through each other during animation and are used for creating dynamicsimulations. As well, rigid surfaces do not deform when they collide withother objects in Maya.

Rigid bodies can be created from polygonal or NURBS surfaces. Rigid bodyattributes can be assigned to the surfaces so they act and react in a simulationin specific ways. Examples of rigid body attributes are velocity, mass, andbounce.

To animate rigid body motion, you can use fields, keyframes, expressions,rigid body constraints, or collisions with particles or other rigid bodies.

Rigid body constraints restrict the motion of rigid bodies. The constraintssimulate the behavior of real-world items you’re familiar with, such as pins,nails, barriers, hinges, and springs.

In this lesson, you create a rigid body dynamic simulation in which you dropa ball on some planks and watch the simulation in action. In this lesson youlearn how to:

n Create objects with physical properties.

n Apply hinge constraints to objects so they react in specific ways.

n Set attributes for the rigid bodies to be either active or passive for thesimulation.

n Play back a rigid body dynamic simulation.

494 | Chapter 10 Dynamics

Page 509: Autodesk Maya 2009

Lesson setup

You can create rigid bodies from NURBS surfaces and polygonal surfaces. Inthe following steps, you create some polygonal surfaces to be used for therigid bodies.

To create polygonal objects for the rigid body simulation

1 Make sure you’ve done the steps in Preparing for the lessons on page 476.

2 In the Time and Range Slider, set the start frame to 1 and end frame to200.

3 Select Create > Polygon Primitives > Cube > .

4 In the Polygon Cube Options window, select Edit > Reset Settings (tomake sure the tool is set to its default, and then set the following optionsand click Create:n Width : 2

n Height: 4

n Depth: 0.25

n Axis: Z

5 With the polygon still selected, select Edit > Duplicate Special > .

6 In the Duplicate Special Options window, select Edit Reset Settings. Setthe following options and then click Duplicate Special:n Translate: 0 3 0

n Number of copies: 5

This creates five copies of the polygon, each one placed 3 units abovethe lower one.

Lesson setup | 495

Page 510: Autodesk Maya 2009

To position the objects for the rigid body simulation

1 Position the objects as shown in the side view in the following illustration.To position the planks precisely, select each plank individually and usethe Channel Box to enter the appropriate value from this list:n pCube1 - Translate Z: 0

n pCube2 - Translate Z: 2

n pCube3 - Translate Z: 0

n pCube4 - Translate Z: 2

n pCube5 - Translate Z: -1

n pCube6 - Translate Z: 1

496 | Chapter 10 Dynamics

Page 511: Autodesk Maya 2009

Creating hinge constraints

A Hinge constraint constrains rigid bodies along a specified axis. You can usea Hinge constraint to create effects such as a door on a hinge, a link connectingtrain cars, or a pendulum of a clock. In this example, the Hinge constraintconstrains the plank to a position in the scene view.

In the following steps, you’ll add Hinge constraints to the center of the planks,which automatically turns the plank into a rigid body. You will do this foreach plank. By default, Maya automatically creates a rigid body when you usea field or rigid body constraint to control its motion.

To create a hinge constraint

1 Select Soft/Rigid Bodies > Create Hinge Constraint > .

2 In the Constraint Options window, set the following options:n Initial Orientation X, Y, Z: 0 90 0

n Leave the options window open.

By default, the initial orientation is set to 0, 0, 0, which orients the hingeconstraint to lie parallel to the Z-axis in world space. By setting theorientation to 90 in the Y-axis, the hinge constraint is rotated 90 degreesaround the Y-axis, which orients the constraint parallel to the X-axis.

By leaving the Set Initial Position at its default setting, the hingeconstraint is created at the rigid body’s center of mass.

3 Select pCube1 and click Apply in the Constraint Options.

4 Select pCube2 and click Apply in the Constraint Options.

5 Repeat this until each of the six planks has a constraint applied to it.

6 Close the Constraint options window.

Creating hinge constraints | 497

Page 512: Autodesk Maya 2009

Running a dynamics simulation

In the next steps, you create a ball and add gravity to make the ball drop andhit the planks and then playback the simulation.

To create a ball for the simulation

1 Select Create > Polygon Primitives > Sphere > .

2 Set Radius to 0.2 and click Create.

3 In the Channel Box, set the Sphere’s Translate Y value to 18.

To add gravity attributes to the ball

1 With the sphere still selected, select Fields > Gravity.

When you connect Gravity to the sphere, it automatically makes thesphere an active rigid body. Gravity affects only the object that wasselected when you add the Gravity field.

To run the dynamics simulation

1 In the Time and Range slider, play the animation.

The ball falls and collides with the planks, which rotate about the hingeconstraint.

Changing an active rigid body to passive

Maya has two kinds of rigid bodies—active and passive. An active rigid bodyis animated by dynamics—fields, collisions, and springs—not by keys.

Because the ball and planks are all active rigid bodies, gravity pushes it downand it rebounds after colliding with the planks.

A passive rigid body can have active rigid bodies collide with it. You can keyits Translate and Rotate attributes, but dynamics have no effect on it.

In the previous steps, all the planks were active rigid bodies and reacted tothe collision of the ball. In the following steps, you’ll change the bottom plankto be a passive rigid body so the ball bounces off the plank but the plankdoesn’t react to the collision.

498 | Chapter 10 Dynamics

Page 513: Autodesk Maya 2009

To change an active rigid body to a passive rigid body

1 Select pCube1 and display the Attribute Editor.

2 Click the rigidBody1 tab to display the rigid body attributes.

3 In the Rigid Body Attributes section, turn off Active to make pCube1 apassive rigid body. Hide the Attribute Editor.

4 Go to the start of the playback range and play the animation.

Observe how pCube1 no longer reacts to the impact of the ball, but theball continues to bounce off it.

Beyond the lesson

In this lesson you learned some fundamental concepts with respect to rigidbody dynamics.

n There are differences between active and passive rigid bodies.When a rigid body is passive, active rigid bodies can collide with it butwill not move it. You can control its movement by setting keys.

When a rigid body is active, you control its movement using dynamicforces, specifically fields and collisions. You can change the active andpassive state of the rigid body to achieve various effects. For example, youcan roll a ball off a table using keys (passive rigid body) then cause the ballto fall using gravity (active rigid body).

n A hinge constraint can be used between an active rigid body and a positionin the scene view.

Beyond the lesson | 499

Page 514: Autodesk Maya 2009

You can also create a hinge constraint between a passive rigid body and aposition in the scene view, two rigid bodies, and an active and passiverigid body.

Other types of constraints include pin, nail, spring and barrier constraints.For additional information on the types of constraints and their usage,please refer to the Maya Help.

500 | Chapter 10 Dynamics

Page 515: Autodesk Maya 2009

Painting

Introduction

Maya provides painting tools that go above and beyond what many 3D creativeartists might normally envision. These tools allow you to accomplish a widerange of modeling, animation, texturing, and effects work.

The painting tools are separated into three categories: Maya® Artisan™ brushtools, Maya® Paint Effects™ tools, and 3D Paint. If you completed the previouslessons in Getting Started with Maya, you already have experience with a fewof these tools.

11

501

Page 516: Autodesk Maya 2009

The Artisan brush tools have a variety of applications and allow you to directlymodify attribute values interactively:

n In the NURBS modeling lesson, you used the brush tools to sculpt a simpleface from a sphere.

n In the Character Setup chapter, you used Artisan brush tools to modifythe skin weights on a surface mesh to ensure the character’s joint deformedproperly.

n In the Character Setup chapter, you used the Artisan brush tools to modifythe cluster weights for Control Vertices to ensure a blend shape deformerworked predictably.

As you have seen, Artisan brush tools can also be used to select surfacecomponents. This selection method can dramatically improve the speed ofyour workflow.

Maya Paint Effects allows the user to create natural and fantastic effects eitheron a 2D canvas or as actual 3D objects in the scene.

n Paint Effects enables you to create a 2D backdrop for your scene, or adynamic 3D paint effect such as a field of grass, with flowers and awind-blown tree—all at the drag of your mouse or tablet pen.

n Paint Effects comes with a suite of preset brushes to enable you to createmany types of 2D and 3D effects.

With 3D paint, you can paint and modify textures directly onto 3D surfacesusing both the Artisan and Paint Effects tools. You can paint texture attributessuch as color, transparency, and bump, to name but a few.

As you have already gained some experience with the Artisan brush tools, thischapter focuses on Paint Effects and 3D Paint. It includes the following lessons:

n Lesson 1 Painting in 2D using Paint Effects: Introduction on page 503

n Lesson 2 Painting in 3D using Paint Effects: Introduction on page 516

n Lesson 3 Painting textures on surfaces: Introduction on page 548

502 | Chapter 11 Painting

Page 517: Autodesk Maya 2009

Preparing for the lessonsTo ensure the lessons work as described, do the following:

1 Consider doing the lessons in the Rendering section of this guide.Familiarity with Maya rendering concepts is important to understandingthe following lessons.

2 If you have not already done so, copy the GettingStarted folder fromits installation location to your projects directory. Then, set theGettingStarted directory as your Maya project. For more information,see Copying and setting the Maya project on page 25.

3 Select File > New Scene to create a new scene.

4 To use all available screen space, maximize the Maya window.

5 From a panel menu bar, select Panels > Layouts > Single Pane.

6 Select the Rendering menu set. Unless otherwise noted, the directions inthis chapter assume the Rendering menu set is selected.

Lesson 1: Painting in 2D using Paint Effects

Introduction

One of the features of the Paint Effects Tool is the ability to paint colors,patterns, and textures on a 2D canvas image. You can use the image as anindependent piece of art, a background image in your scene, or a texture tobe applied to a 3D surface.

In this lesson, you learn how to:

n Display the 2D canvas.

n Paint strokes on the canvas, and modify your paint brush.

n Use the Visor to access the many pre-defined paint brushes.

n Modify brush settings such as brush size, color, and transparency.

n Modify the canvas size.

n Smear, blur, and erase brush strokes from the 2D canvas.

Preparing for the lessons | 503

Page 518: Autodesk Maya 2009

n Use the pre-defined Paint Effects brushes to paint flowers and foliage.

n Save modified brush settings to the Shelf.

n View the alpha channel for your 2D image.

Painting strokes

In the following steps, you display the 2D canvas and use preset brushes topaint a few strokes.

Although not covered in this lesson, you can use a tablet and stylus to paintwith pressure sensitivity. The harder you press down, the more paint is applied.

To paint strokes on the 2D canvas

1 Do the steps in Preparing for the lessons on page 503.

2 If you want to create maximum space in the Maya window, turn offDisplay > UI Elements > Channel Box/Layer Editor, Tool Settings, andAttribute Editor.

3 On the panel menu bar, select Panels > Panel > Paint Effects (hotkey 8).

The panel displays a Paint Effects toolbar and menus.

4 From the Paint Effects menus, select Paint > Paint Canvas to display the2D canvas.

You’re ready to start painting. It is not possible to display a grid on thecanvas.

5 Paint a stroke by dragging across the canvas.

504 | Chapter 11 Painting

Page 519: Autodesk Maya 2009

When you first display the Paint Effects panel, your strokes use the defaultbrush—a solid black stroke similar to an airbrush.

TIP You can dolly and track the canvas using Maya’s standard mouse andkeyboard conventions.

6 Now paint with various preset brushes. To select a preset brush, selectBrush > Get Brush or click the following button in the toolbar:

The Visor window opens.

The Visor organizes the hundreds of Paint Effects brushes into category folders.In the Visor, click a folder, then click a brush icon in the area to the right ofthe folders. (The name of each preset brush has the extension .mel becauseeach is a MEL script that establishes the brush’s operation characteristics.) Youcan dolly within the Visor window to enlarge the viewable size of the brushicons and read the names more clearly.

You can copy a brush or all brushes within a folder to the Shelf. Use the middlemouse button to drag the brush or folder to the Shelf. Use the shelf editor(available from the arrow menu at the left of the shelf) to remove items fromthe shelf.

Painting strokes | 505

Page 520: Autodesk Maya 2009

Some brushes apply paint directly along the paint path, while others produceadded effects. For example, the pens folder includes brushes such asballpointRed.mel that work like pens, while the flowers folder includes brushessuch as dahliaPink.mel that grow flowers as you drag the mouse. Brushes likedahliaPink.mel use Paint Effects tubes.

1 Select the dahliaPink.mel brush and drag the mouse slowly for one stroke,then quickly for the next stroke.

When you paint a stroke slowly, the density of flowers is higher thanwhen you paint quickly. The effect of stroke speed on density works thesame for all brushes that use tubes.

2 To erase your last stroke, select Canvas > Canvas Undo.

When displaying the 2D canvas, you can undo only a single stroke. Edit> Undo, Redo, Repeat (on the main menu) doesn’t undo strokes.

3 To erase the entire canvas, select Canvas > Clear or click the Canvas Clear

button on the toolbar:

Modifying the default brush settings

When you select a preset brush, Maya copies its brush settings to a templatebrush. A template brush is a holder for the attribute settings of the next strokesyou paint. When you change the settings of the template brush, they affectonly the next strokes, not previous strokes.

To edit the template brush settings

1 Select Brush > Reset Template Brush to select the default brush, thenpaint on the canvas so you remember the brush effect.

506 | Chapter 11 Painting

Page 521: Autodesk Maya 2009

2 Select Brush > Edit Template Brush or click the following button in the

toolbar:

You can edit various brush settings, for example, the brush width, in thewindow that appears.

3 To resize the brush, change the Global Scale value. Alternatively, you canmove the brush over the canvas, press and hold the b Hotkey and dragleft or right. The circle on the canvas represents the size of your brush.

4 Paint on the canvas to try out a new size.

5 Close the Paint Effects Brush Settings window.

6 On the toolbar, click the swatch to the right of C (color) to display theColor Chooser.

7 Select a color from the Color Chooser and paint on the canvas.

8 On the toolbar, slide the T (transparency) slider to the right until the Tbox is a light gray. Paint on the canvas.

When you paint over existing paint strokes you will notice that yourpaint is transparent allowing the previous strokes to show through.

Modifying the default brush settings | 507

Page 522: Autodesk Maya 2009

NOTE The Toolbar color boxes, for example, C and T, are also available inthe Paint Effects Brush Settings window. (Select Brush > Edit Template Brush> Shading.)

Modifying the canvas

In the next steps you change a few canvas options, including color and size.

To modify canvas settings

1 Clear the canvas (Canvas > Clear).

2 Select Canvas > Set Size and set the canvas size to 512 x 512—the widthand height in pixels. When you are prompted to save, click No, thenclose the Set Canvas size window.

Although you’ll often use the default maximum canvas size to takeadvantage of the available screen space, you might need to use a smalleror larger size in many circumstances. For instance, if you plan to use theimage as a background in a computer game, you might need to use asmall canvas size such as 256 by 256.

3 Turn on the wrap buttons on the toolbar:

4 Paint strokes past the edges of the canvas.

508 | Chapter 11 Painting

Page 523: Autodesk Maya 2009

The strokes wrap around to the opposing side. This feature is useful forcreating patterned texture images to be applied to surfaces. When youtile or repeat the image on the surface, the wrapped strokes help makethe borders between the images unnoticeable.

If you want to display the area of the canvas where the edges join, youcan do this using the roll feature (Canvas > Roll).

5 Select Canvas > Clear > . In the options window, slide the Clear Colorslider all the way to the left. Click Apply.

This clears existing strokes and turns the canvas black. Before you paintstrokes on the black canvas, you may notice that some brushes seem tohave no effect. If this occurs, it’s because the paint is black or because itis transparent enough to prevent the color from showing.

Modifying the colors of a preset brush

In the following steps, you alter leaf and bud colors of a preset brush; fern.mel.

TIP When using the fern.mel brush, if any of the sliders do not appear, or appearcut off on the right, you need to increase the screen display resolution setting onyour monitor to 1280 X 1024.

To change the color of a brush

1 In the Visor (Brush > Get Brush), click the fern.mel preset brush in theplants folder.

2 Paint on the canvas to see the default display.

Because fern.mel uses tubes, ferns grow along the path of your stroke.

3 Resize the brush to a Global Scale of about 0.5 (Brush > Edit TemplateBrush) and paint on the canvas.

4 On the toolbar, click the L1 color box (Leaf Color 1), select a shade ofblue from the Color Chooser, and leave the Color Chooser open.

L1 sets the color of the tips of the leaves.

5 Click the L2 color box (Leaf Color 2) and select a shade of red from theColor Chooser.

L2 sets the color of the base of the leaves.

Modifying the colors of a preset brush | 509

Page 524: Autodesk Maya 2009

6 Click the B color box (Bud Color) and select a shade of yellow from theColor Chooser. B sets the color of the flower buds.

7 Paint on the canvas and observe how the changes you’ve made to thesettings affect the final paint effect.

TIP You can change the path width of fern.mel without changing the widthof the leaves and stems. Select Brush > Edit Template Brush to display theBrush Settings window, then in the Brush Profile section, change the valueof Brush Width. Similarly, you can alter the path width for any other presetstrokes with tubes.

8 Clear the canvas (Canvas > Clear).

Editing strokes with tubes attributes

Now you’ll edit the attributes that specify the foliage that grows along thepath with fern.mel.

To edit tube attributes

1 To edit brush settings, select Brush > Edit Template Brush.

2 Open the Tubes section, then open Growth.

510 | Chapter 11 Painting

Page 525: Autodesk Maya 2009

By default, only Leaves and Buds are created as you paint. You can alsocreate Branches, Twigs, and Flowers to simulate a fern in various stagesof its natural life cycle.

3 Turn on Flowers. Paint on the canvas to see the result.

4 Open the Leaves section, change Leaves in Cluster to 4, then paint onthe canvas.

Leaves are created in radial clusters around a branch or twig. This settingdefines how many leaves are in each cluster. The higher the number, thedenser the foliage.

5 To make the flowers point in a different direction, open the Behaviorsection and then the Forces section. Set Path Follow to 0.1.

6 Paint to see the result.

Saving brush settings for future use

When you first selected the preset brush fern.mel previously, Maya copied itto the template brush. You then edited the color and various other attributesof the template brush to create a unique ferns brush. The next steps show howto save the current settings of the template brush for future use.

Saving brush settings for future use | 511

Page 526: Autodesk Maya 2009

To save a brush to the Shelf

1 On the main menu bar, select Paint Effects > Save Brush Preset. This isthe menu item you use to save the template brush as a preset brush.

2 Type the name blueFern in the Label box as well as the Overlay Labelbox.

This name appears in icons on the Shelf or Visor after you save the brush.

3 For the Save Preset option, turn on To Shelf. This means you’ll put thebrush on the Shelf but not in the Visor.

4 Click Grab Icon and drag a selection box around a part of the image thatis representative of the brush’s result.

A swatch appears in the window for the selected region. Repeat this stepuntil you are satisfied with the icon.

5 Click Save Brush Preset. An icon for the new preset brush appears on theShelf.

6 To check that the blueFern brush works, select a different preset brushand paint on the canvas, then select the blueFern from the Shelf andpaint on the canvas.

7 Clear the canvas and close the Save Brush Preset window.

Blending brushes

You can blend brushes. Before beginning, display the Visor, click gold.mel inthe metal folder, and paint on the canvas so you know gold’s effect. Do thesame for grassOrnament.mel from the grasses folder.

To blend brushes

1 Click grassOrnament.mel in the grasses folder.

2 From the menu, select Paint Effects > Preset Blending > .

The Preset Blending options window appears.

The brush preset blending is toggled on and the options in this windowset how much the template brush is influenced by the next preset brushyou select. This affects only the subsequent painting, not the presetbrushes in the Visor.

3 Change the Shading value to 80 and the Shape value to 0.

512 | Chapter 11 Painting

Page 527: Autodesk Maya 2009

When you select the next brush (gold.mel), Maya uses 80% of its shadingand 0% of its shape. Conversely, the stroke uses 20% of thegrassOrnament.mel brush’s shading and 100% of its shape.

4 To confirm the effect, select gold.mel (in the metal folder), then painton the canvas.

5 Repeat the preceding steps, experimenting with different preset brushes,Shading, and Shape values. As a first try, blend flameCoarse.mel fromthe fire folder with the existing template brush. Set Shading to 60 andShape to 30.

If the Brush Preset Blend window is open, each time you select a presetbrush, its Shading and Shape values will be blended with the templatebrush.

6 Close the Brush Preset Blend window when you are done blendingbrushes.

7 Do not clear the canvas. You’ll use your existing strokes in the next steps.

Smearing, blurring, and erasing paint

Now you’ll work with brush types that smear, blur, and erase paint.

Smearing, blurring, and erasing paint | 513

Page 528: Autodesk Maya 2009

To smear, blur, and erase paint

1 Select Brush > Reset Template Brush to select the default brush.

2 On the Brush menu, try the Smear, Blur, and Erase menu items and painton the strokes already on the canvas. You can also change these settingsusing the Brush Type setting in the Paint Effects Brush Settings window(Brush > Edit Template Brush).

3 If you need to perform compositing work, you can view the image’s alpha

channel by clicking this button: .

White regions represent full opacity. Black represents full transparency.

4 If you turned on the alpha channel (Display > Alpha Channel), returnto the display of full color by selecting Display > All Channels.

5 Clear the canvas and restore the canvas color to white (Canvas > Clear >

).

6 To quit the canvas display and return to a scene view, select Panels >Perspective > persp (Hotkey 8).

7 In the Toolbox, click the Select Tool.

Clicking the Select Tool quits the Paint Effects Tool, and the mouse cursordisplays as an arrow.

514 | Chapter 11 Painting

Page 529: Autodesk Maya 2009

8 Select Paint Effects > Preset Blending to turn off Preset Blending beforeyou proceed to the next lesson.

Beyond the lesson

In this lesson, you learned how to:

n Use Paint Effects to paint on the 2D canvas.

n Use the preset Paint Effects brushes from the Visor.

n Edit, blend, and save preset brushes for later use.Painting on the 2D canvas is useful when you need to create a texture tobe applied to a surface. For example, suppose you paint a repeating brickpattern on the canvas and save the canvas as an image file. You can createa material, for instance, a Blinn material, then apply the image file as afile texture to the color of the Blinn material. You can then apply the Blinnmaterial to a 3D wall you’ve modeled, which creates the illusion of a brickwall.

Painting a 2D canvas is also useful for creating a background image for a scene.For instance, you might create lush foliage on the canvas, put it on a camera’simage plane, then use it as the backdrop for animated jungle animals in theforeground.

Although not covered in this lesson, you can use a tablet and stylus to paintwith pressure sensitivity. Pressure sensitivity allows you to more realisticallysimulate the effects of traditional drawing media (pens, pencils, markers, etc.)

Beyond the lesson | 515

Page 530: Autodesk Maya 2009

Lesson 2: Painting in 3D using Paint Effects

Introduction

The Paint Effects Tool goes beyond traditional paint software by allowing youto paint directly in 3D space, either on the ground plane or on an object’ssurface. When you use Paint Effects for 3D work, the paint strokes arethree-dimensional and editable.

With Paint Effects, all of the hundreds of preset brushes found in the Visorunder the Paint Effects tab (airbrushes, pens, markers, watercolors, plants, fire,metal, flowers, trees, and underwater etc.) can be used to create 3D objects inyour scene. For example, you can use the preset plant brushes to paint a 3Dtropical fern garden around a walking character in your scene.

You can animate brush strokes to create dynamic effects. For example, youcan animate the ferns to shake in the wind or have them move when acharacter walks near them.

An electronic tablet with stylus is an ideal tool for painting with Paint Effects.With a real paint brush, pressing harder makes the brush wider and appliesthe paint more thickly. You can achieve the same effect with Paint Effects byspecifying the effect of pressure on the stylus for each stroke and the thresholdof response to pressure. You can map up to three attribute values to styluspressure and edit them as you work.

When you use Paint Effects to paint 3D strokes, you can edit the brush andstroke attributes to create a variety of effects.

516 | Chapter 11 Painting

Page 531: Autodesk Maya 2009

In this lesson, you begin to explore what is possible with painting in 3D usingthe Paint Effects Tool by learning how to:

n Paint directly in the 3D scene view.

n Choose brushes from the Visor and the Shelf and modify their brushattributes.

n Paint in 3D using the Paint Effects panel.

n Differentiate between paint brushes and paint strokes.

n Make surfaces paintable so paint strokes can be applied to them.

n Select brush strokes and modify their attributes.

n View strokes in wireframe and rendered mode.

n Apply various effects to stroke attributes.

Preparing for the lessons

To ensure the lessons work as described, do these steps before beginning:

1 If you have not done so already, consider doing the lessons in theRendering section of this guide. Familiarity with Maya rendering conceptsis important to understanding the lessons.

2 Select File > New Scene to create a new scene.

If you just finished Lesson 1 in this chapter you may be presented witha window asking if you wish to Save previous paint effects. Select No.

3 To use all available screen space, maximize the Maya window.

4 From a panel menu bar, select Panels > Layouts > Single Pane.

5 Select the Rendering menu set. Unless otherwise noted, the directions inthis chapter assume the Rendering menu set is selected.

6 From the Shelf, select the Paint Effects tab to display the various presetbrushes.

If the Paint Effects Shelf tab does not appear as part of the shelf set, seethe Maya Help for Shelves. (For Linux users, any new shelves do not loadby default.)

Preparing for the lessons | 517

Page 532: Autodesk Maya 2009

Regardless of your operating system, the Paint Effects preset brushes areaccessible from the Visor panel. (From a view panel, select Panels > Panel> Visor.)

Brushes and strokes

Like a traditional paint program, Paint Effects allows you to use a brush andpaint strokes. In Paint Effects, the brush and stroke have unique qualities andcharacteristics.

A brush contains the various attributes that define the appearance and behaviorof the paint. The template brush settings define the initial settings for a brush.

When you drag the Paint Effects brush, you create a path for the brush calledthe paint stroke.

A stroke is a 3D curve (or collection of curves) with attributes that define howthe paint is applied along the stroke path. You can paint strokes directly inthe 3D scene or on objects.

When you select a brush preset from the shelf or from the Visor, that brushis copied to the template brush. Any changes you make to the template brushsettings affect what the next stroke looks like, but they do not affect anypreviously painted strokes.

To select a Paint Effects preset brush from the Shelf

1 From the Toolbox panel layout shortcuts, select the Single PerspectiveView.

2 From the Shelf, select the Paint Effects tab to display the Paint Effectspreset brushes.

3 From the Paint Effects shelf, select the Daisy Large Brush.

518 | Chapter 11 Painting

Page 533: Autodesk Maya 2009

In the scene view, the cursor changes to a red circle with a vertical lineindicating it is set to paint a stroke. The circle indicates the width of thebrush path. With some types of strokes, this path will appear as the widthof the actual paint; with other stroke types, it indicates the width of thetube seeding path, for example, plants, trees, etc.

The settings of the preset brush you select are copied to the templatebrush. The template brush settings are used when a paint stroke is drawn.If you want to modify the brush presets before you begin to paint, youmust edit the template brush after you’ve chosen the preset brush (PaintEffects > Template Brush Settings).

By default, the brush cursor moves along the ground plane. The groundplane lies in the X, Z dimension. This is the default behavior for the brushcursor. If you draw a paint stroke, it is applied to the ground plane (X,Z).

To paint 3D strokes in the scene view

1 With the Daisy Brush selected, draw one short paint stroke on the groundplane using one of the following methods:n Drag the stylus across the tablet while exerting slight pressure on the

stylus as you move it.

Brushes and strokes | 519

Page 534: Autodesk Maya 2009

n Drag the mouse while pressing the left mouse button.

One or more wireframe daisy stalks appear in the scene view along thepath of the paint stroke. When you paint a stroke in the scene view itinitially appears as a wireframe. Paint is not applied to the stroke until itis rendered.

The stalks that extend out of the curve or stroke are called tubes. In PaintEffects, strokes are either simple strokes or strokes with tubes.

Because the stroke has a curve associated with it, you can move, scale, orrotate the stroke like other objects in the scene. You can edit the curveto modify the shape of the stroke path.

2 Dolly and tumble the scene to better view these strokes with tubes in 3D.

3 Select the Move Tool from the Toolbox.

A move manipulator icon appears at the X, Y, Z origin. (If the movemanipulator does not appear, you can click on the stroke to reselect itwith the Move Tool.)

520 | Chapter 11 Painting

Page 535: Autodesk Maya 2009

4 In the scene view, drag any of the Move Tool manipulator arrows toreposition the stroke.

Each time you paint a stroke, Paint Effects creates a new brush and strokenode and attaches them to the stroke that is created. You can modify thesebrush and stroke nodes once they’ve been created. To edit these brush orstroke attributes, you use the Attribute Editor.

To modify the attributes of an existing paint stroke

1 To view the Attribute Editor, click the Show/Hide icon on the Status Line.

The Attribute Editor displays.

2 In the scene view, select the paint stroke associated with the daisies. Youcan select a stroke by one of the following methods:n Select the curve associated with the stroke path.

n Select the tubes associated with the stroke path.

The Attribute Editor updates to display the nodes associated with theselected daisy stroke. The various attributes for the stroke appear underdifferent tabs. Each tab represents a node associated with a specific set ofattributes.

Brushes and strokes | 521

Page 536: Autodesk Maya 2009

3 Click on the strokeDaisyLarge1 tab to see its attributes.

This tab contains information related to the transform node, because themost important attributes on this tab control the stroke’s curvetransformation.

4 Under Transform Attributes, set Rotate to be 0, 90, 0.

The stroke is rotated 90 degrees about the Y axis.

522 | Chapter 11 Painting

Page 537: Autodesk Maya 2009

5 Click the strokeShapeDaisyLarge1 tab to see its attributes.

This tab is called the stroke attribute node because the attributes establishthe paint stroke’s properties when the stroke is first created.

6 Expand the End Bounds section by clicking the arrow to see the Min andMax Clip attributes.

Min Clip specifies the start of the stroke along the path. Max Clip specifiesthe end of the stroke along the path.

7 Drag the Max Clip slider from its present value of 1.0 to a value of 0.1.

The stroke path is shortened.

Min and Max Clip can be animated to create the effect of the paintadvancing along a path.

8 Drag the Max Clip slider back to its original value of 1.0.

9 Click the daisyLarge1 attribute tab to see its attributes.

This is the node that contains attributes related to the paint brushassociated with the stroke.

10 Set the Global Scale attribute to 6.0.

The daisies scale larger along the stroke’s path.

Brushes and strokes | 523

Page 538: Autodesk Maya 2009

11 In the daisyLarge1 node, expand the Tubes attributes, then Behavior andForces.

12 Drag the Gravity slider to the right so that the value of gravity increasesto a value of 1.0.

The daisies lay on the ground plane, as if wilting, with the increasedgravity.

524 | Chapter 11 Painting

Page 539: Autodesk Maya 2009

Drag the Gravity slider back to its original position approximately so thatthe stalks appear upright.

The last tab in the Attribute Editor is the time node. The time node isused for animation and dynamics. You do not use this node in this lesson.

Rendering Paint Effects strokes

The paint strokes display in wireframe mode when you paint in the sceneview. Working in wireframe mode is very efficient in terms of interactiveperformance but you don’t see how the paint actually appears. To view thepaint strokes in a rendered mode you can either:

n Render the scene view using the software renderer.

n Switch to painting in the scene painting view using the Paint Effects panel.

To render the paint strokes in the scene view

1 Dolly or tumble the scene so the view of the daisies appears roughlysimilar to the image below.

2 From the Status Line, click the Render Current Frame button.

Rendering Paint Effects strokes | 525

Page 540: Autodesk Maya 2009

The Render View window opens, renders the image, and then displaysit.

The daisies may initially appear a bit dark in the image.

The Maya renderer creates a temporary light with a default brightnesslevel in order to render the image when no lights are present in the scene.This ensures that you don’t produce an image that is totally black;however it may not produce the correct illumination for your scene. Ifyou want to obtain more control over the illumination of the daisies,you can create a light for the scene and adjust its brightness.

3 From the main menu, select Create > Lights > Directional Light.

A directional light is created at the X,Y,Z origin of the scene.

526 | Chapter 11 Painting

Page 541: Autodesk Maya 2009

The Attribute Editor updates to display the attributes for the activedirectional light.

4 In the Attribute Editor, set the Intensity for the directional light to be1.5.

5 From the Status Line, click the Render Current Frame button to renderthe scene again.

The image renders and the Render View window image is refreshed.

The daisies appear brighter in this version of the rendered image.

6 Close the Render View window.

Sometimes you may want to view your painted strokes as you paint. To dothis, you can paint in the Paint Effects panel view and use the scene paintingview mode.

To display rendered paint strokes as you paint

1 Press 8 to switch to the Paint Effects panel.

NOTE If the 2D Paint Canvas appears instead (i.e.: panel appears white),select Paint > Paint Scene, from the panel menu.

The Paint Effects panel menu and toolbar displays as well as the scenepainting view. This panel allows you to paint in scene painting viewmode.

Rendering Paint Effects strokes | 527

Page 542: Autodesk Maya 2009

The scene painting view is a snapshot of the modeling view. In this viewyou can both paint and view your strokes in a rendered fashion to seewhat they will really look like as you work.

You can dolly, track, and tumble in the scene painting view. You canselect objects by pressing the Ctrl key and clicking on them. If you wantto move, or otherwise manipulate 3D objects in the scene view, you mustexit the Paint Effects panel by pressing the 8 key again.

2 With the Daisy Brush selected, paint a stroke in the scene painting view.

The new stroke displays in rendered mode. If you dolly or track the scenepainting view, any rendered strokes will revert back to wireframe displayuntil you refresh the rendered display.

3 To automatically update the paint strokes so they display in renderedmode, select Stroke Refresh > Rendered.

It will take a few moments for the rendering of all of the paint strokes tobe calculated and then displayed.

Each time you adjust the camera view while working in scene paintingmode with Refresh > Rendered turned on, the system will automaticallyupdate the rendering based on the new view.

Automatically refreshing the rendering can be time-consuming dependingon the complexity of paint strokes in your scene. Alternatively, you canset the rendering to refresh only when you manually choose to do so.

4 From the Paint Effects panel menu, select Stroke Refresh > Off.

528 | Chapter 11 Painting

Page 543: Autodesk Maya 2009

Now you must manually refresh the Paint Effects rendered view usingthe Redraw Paint Effects view button in order to see the paint strokesrendered.

5 Dolly the view to obtain a closer view of the daisies.

6 Manually refresh the rendering of the daisies by clicking the Redraw PaintEffects view button.

7 Exit the scene painting view mode by pressing the 8 key.

Paint Effects on 3D objects

With Paint Effects, you can paint 3D strokes directly on 3D objects in a Mayascene.

Paint Effects on 3D objects | 529

Page 544: Autodesk Maya 2009

In this section, you create a surface for an underwater terrain and sculpt it tothe desired form using the Sculpt Geometry tool. You use the underwaterpreset Paint Effects brushes found in the Visor to begin the underwater scene.

Creating a surface to paint on

In Paint Effects, NURBS surfaces are the only surface type you can paint on.You will create a NURBS plane, and sculpt it to make its surface appear likean underwater terrain.

To create a surface terrain for the underwater scene

1 Select File > New Scene.

A new empty scene is created.

2 From the main menu, select Create > NURBS Primitives > Plane > .

The NURBS plane options window appears.

3 In the NURBS Plane Options window, select Edit > Reset settings andthen set the following options:n Width: 15

n Length: 15

n U Patches: 10

n V Patches: 10

4 In the NURBS Plane Options window, click Create.

Maya creates a plane primitive and positions it at the origin. The planeis 15 units by 15 units in dimension with 10 subdivisions along each side.

530 | Chapter 11 Painting

Page 545: Autodesk Maya 2009

This surface will become the seabed terrain for your scene.

To sculpt a terrain using the Sculpt Geometry Tool

1 Select the plane surface.

2 On the Status line, select Surfaces from the drop-down menu.

The Main Menu changes to display Surfaces menu set.

3 From the Main menu, select Edit NURBS > Sculpt Geometry Tool.

The cursor display changes to the brush cursor for the Sculpt Geometrytool.

4 On the Status Line, click the Show/Hide Tool Settings button to displaythe tool settings for the Sculpt Geometry tool.

5 In the Brush section, set the Radius (U) to 2. and set the sculpt Operationto Pull.

Creating a surface to paint on | 531

Page 546: Autodesk Maya 2009

6 Drag the cursor along the back right edge of the plane to pull it upwardsas shown.

7 Drag the cursor along the back left edge of the plane to pull it upwards.

8 Dolly and track the view as required so you can easily view the areas youneed to sculpt.

9 Sculpt along the front and middle of the plane to make some bumpyareas.

10 Repeat steps 7 through 10 until you have your 3D terrain looking roughlyas shown in the image below.

TIP If you want to undo a particular sculpt operation, click Ctrl + z to undothe sculpt stroke. You can click Ctrl + z repeatedly to undo a number of sculptoperations.

532 | Chapter 11 Painting

Page 547: Autodesk Maya 2009

11 When you complete your terrain, return to the Rendering Menu set byselecting Rendering from the drop-down menu on the Status Line.

12 Hide the Sculpt Geometry Tool settings window before proceeding.

To select preset brushes from the Visor

1 From the main menu, select Paint Effects > Get Brush.

The Visor panel appears.

2 In the Visor, click the Paint Effects tab to display the various brush folders.

3 Scroll down the brush folders list to the underwater folder, and click itto view its contents.

Painting on objects

To paint on a 3D object, you must first make the object paintable. When youpaint directly on a paintable object, Paint Effects creates a curve on the surfacealong the stroke path and attaches the stroke and new brush to it.

Painting on objects | 533

Page 548: Autodesk Maya 2009

If you make an object paintable and then try to paint on one that is notpaintable, no stroke occurs. If you don’t make any objects in your scenepaintable, your strokes are placed on the ground plane.

To paint on a 3D object

1 With the terrain surface selected, select Paint Effects > Make Paintable.

2 From the Visor, select the brush named kelp.mel.

3 Paint a short stroke onto your 3D terrain surface.

When you paint directly on a paintable object, Paint Effects creates acurve on the surface along the stroke path and attaches the stroke andnew brush to it. If you move the plane, the paint stroke moves with it.

4 Paint a few more kelp strands throughout the scene as shown.

The kelp brush orients the tubes to point along the normal of the surfaceyou paint on. In the ocean, kelp grows towards the surface of the waterin a vertical manner. If you want your kelp to appear realistic, it shouldpoint vertically upwards. If you paint the kelp on an angled part of thesurface, the kelp tube will not point in a vertical direction.

TIP If you want to change the scale of the Paint Effects stroke to obtain largerplants or animals, press the b key and drag your stylus or mouse to the leftor right to make the global scale for the current brush smaller or larger.

If you want to change the width of the brush stroke, to paint a narroweror wider tube path, for example, a wider swath of kelp plants, press theshift and b key and drag to the left or right.

534 | Chapter 11 Painting

Page 549: Autodesk Maya 2009

Using turbulence with brush stroke tubes

In the ocean, kelp would react to the turbulence created by ocean currents.The tube attributes associated with many preset brushes have turbulenceattributes turned on for interesting visual effects. Turbulence attributes canbe increased from their default settings to make the kelp sway back and forth,providing additional realism when used in an animation.

To increase the turbulence on the kelp brush tube

1 In the scene view, select the kelp stroke.

2 Open the Attribute Editor, select the Kelp tab, and expand the Tubes >Behavior > Turbulence section.

3 In the Turbulence section, set the options as follows:n Turbulence Type: World Force

n Interpolation: Smooth over Time and Space

n Turbulence: 0.5

n Frequency: 0.5

4 Click the Play Forward button on the Animation Time Slider to see theturbulence effect on the kelp (You don’t need to set specific keyframes).

The kelp animates as if it were affected by ocean currents.

5 Press the Stop button to cancel the animation playback.

Using turbulence with brush stroke tubes | 535

Page 550: Autodesk Maya 2009

You can adjust the turbulence settings while viewing the playback. If theframe range is too short, you can modify it to suit your needs.

Using additional preset brushes

1 From the Visor, select the brush named fanCoral.mel.

2 Paint a few fan coral strokes in your scene near the back edges of theplane.

TIP If you paint a stroke in your scene and want to delete it you can do soby one of the following methods:n Press Ctrl + z to immediately undo the stroke.

n Click on the stroke to select it and then press the Delete key.

n Marquee-select a tube associated with the stroke and then press theDelete key.

n Marquee-select multiple tubes and strokes and then press the Deletekey.

If you want to delete all the paint strokes in your scene you can selectEdit > Delete All by Type.

3 Paint additional strokes in your underwater scene using a few using thefollowing brushes found in the underwater folder in the Visor:n sea urchins, starfish, seashells, and anemones

4 Dolly and track the scene for a closer view so it appears approximatelyas shown.

536 | Chapter 11 Painting

Page 551: Autodesk Maya 2009

5 From the Status Line, click the Render Current Frame button.

6 The renderer executes, renders the image, and then displays it in theRender View window.

You can create a seabed texture for the plane primitive, a few rocks, and someanimated fish swimming to complete your scene.

You can spend additional time to further refine this scene, but this examplegives you an idea of how a scene with various 3D props can be quicklyestablished using Paint Effects and the various preset brushes found in theVisor.

Using additional preset brushes | 537

Page 552: Autodesk Maya 2009

Mesh brushes

Mesh brushes are a brush type that provide special features not available withother Paint Effect brush types. Mesh brushes render using polygonal trianglesrather than brush stamps. As a result, mesh strokes can be more accuratelytexture-mapped for realistic results. They also appear more realistic comparedto other brush types whether they are viewed close-up or from a distance.

The mesh brush stroke can also be converted to a polygonal surface in theMaya scene. Once the stroke is converted to polygons, the resulting polygonscan be modified using any of the Maya polygonal modification tools andutilized like any other polygonal surface (animation, rendering, and so on)

In this section, you are introduced to mesh brushes and learn additionaltechniques related to the various brush and stroke attributes. You learn howto:

n Understand the structure of strokes with tubes.

n Modify a variety brush tube attributes.

n Convert the mesh brush stroke to polygons.

n Modify the converted mesh using construction history.

n Render the polygonal meshes.

To select a mesh brush preset from the Shelf

1 Select File > New Scene.

A new empty scene is created.

2 From the Toolbox panel layout shortcuts, select the Single PerspectiveView.

538 | Chapter 11 Painting

Page 553: Autodesk Maya 2009

3 From the Shelf, select the Paint Effects tab to display the Paint Effectspreset brushes.

4 From the Paint Effects shelf, select the Teapot Brush.

In the scene view, the cursor changes to a sphere icon indicating it is setto paint a stroke. The Teapot Brush is a mesh brush type.

5 In the scene view, drag your mouse or stylus along the ground plane tocreate one short stroke.

6 Dolly and tumble the view to see the wireframe version of the stroke.

The teapot stroke displays three wireframe tubes to represent the teapot.These tubes represent the body, spout, and handle for the teapot.

Paint Effects uses a plant or tree archetype to represent the various tubeattributes. If you envision how a plant or tree has a trunk, out from whichbranches, leaves, flowers, and buds grow, you understand how eachattribute is controlled in the attribute editor.

The center vertical line represents the main tube, whose attributes arefound in the Creation tab of the attribute editor. The diagonal andsemicircular lines represent the Leaves and Flowers tube attributes for thespout and handle of the teapot.

Mesh brushes | 539

Page 554: Autodesk Maya 2009

To render the paint effects stroke

1 From the Status Line, click the Render Current Frame button.

The renderer executes, renders the paint stroke, and then displays theimage in a Render View window.

2 Close the Render View window.

Mesh brush types are useful for representing hard surfaces compared to otherbrush types (the teapot is one example).

Converting mesh strokes to polygons

Mesh strokes can be converted to polygons. Converting the mesh stroke topolygons allows you to visualize any brush modifications you make in theAttribute Editor without having to render the stroke. It is possible to edit,animate, and render the converted polygon mesh the same way you wouldany other polygonal surface types.

To convert a mesh stroke to polygons

1 Press the q key (Hotkey) to choose the Select Tool.

The cursor changes to an arrow icon indicating the change to selectionmode.

540 | Chapter 11 Painting

Page 555: Autodesk Maya 2009

2 Select the teapot stroke, if it is not already selected.

3 Select Modify > Convert > Paint Effects to Polygons > .

4 In the Convert Paint Effects to Polygons Options window, ensure thatthe Hide Strokes option is set to On.

Setting the Hide Strokes option to On ensures that after the conversion,only the converted polygon mesh will be displayed.

5 In the Convert Paint Effects to Polygons Options window, click Convert.

The mesh brush stroke is converted to a polygonal surface. A teapot modelmade of polygons results.

The original mesh brush stroke still remains but is now hidden.

6 Click anywhere in the scene view away from the teapot surface to de-selectthe teapot surface.

7 In the scene view, press 5 to smooth shade the display of the polygonalteapot.

Converting mesh strokes to polygons | 541

Page 556: Autodesk Maya 2009

Modifying a converted polygonal mesh

By default the original brush stroke is linked to the new polygonal surface viaconstruction history. If you modify the original brush stroke attributes, thepolygonal surface will update so long as the construction history link exists.This construction history link allows you to easily modify the polygonal meshsurfaces in a variety of ways. You modify the brush stroke attributes using theattribute editor.

To modify the teapot brush attributes

1 Marquee-select the polygonal teapot.

2 To view the Attribute Editor, click the Show/Hide button on the StatusLine.

The Attribute Editor displays.

3 In the Attribute Editor, click on the teapot1 tab to display the brushattributes for the teapot stroke. (You may need to click the display arrow(Windows, Mac OS X) or select the tab from the pop-up list (Linux) inorder to see the tab.)

542 | Chapter 11 Painting

Page 557: Autodesk Maya 2009

4 In the Attribute Editor, expand the Mesh attributes section to display itsattributes.

5 In the Mesh attributes, drag the Tubes Sections slider to the left to a valueof 3.

The body, spout, and handle of the teapot update to display as 3 sidedsurfaces.

Modifying a converted polygonal mesh | 543

Page 558: Autodesk Maya 2009

Tube Sections defines the number of sides around the width of the tubesin a mesh stroke. Changing the Tubes Sections gives a range of resultsdepending on the brush type you choose.

6 Set the Tubes Sections to a value of 18.

7 In the Attribute Editor, close the Mesh attributes, and then expand theTubes attributes, then the Creation attributes.

The Creation attributes control the main body of the teapot; the “trunk”or “stalk” of your paint effect mesh type.

8 Scroll down to the Width Scale attributes.

9 In the Width Scale attributes, drag an index point handle (as shownbelow) to change the profile shape of the teapot.

The profile of the teapot body is modified.

544 | Chapter 11 Painting

Page 559: Autodesk Maya 2009

The Width Scale graph allows you to control the width of a tube byinterpolating the shape between the index points. (If you look closely atthe graph, you’ll see the profile of the teapot laying on its side.)

10 Drag the index marker back to its original position.

11 Close the Creation attribute section in the Attribute Editor, and open theGrowth attributes, followed by the Leaves attributes.

12 In the Leaves attributes, drag the sliders for the Leaves In Cluster, LeafLength, Leaf Base Width, and Leaf Tip Width attributes to experimentwith the spout of the teapot.

Modifying a converted polygonal mesh | 545

Page 560: Autodesk Maya 2009

If you want to adjust the attributes of the teapot handle, you can editthe Flower attributes.

Using this converted poly mesh is one example of how the attributes of thepaint stroke can be modified to affect the shape of another object throughconstruction history.

If you delete the paint stroke, the construction history between the stroke andthe polygonal teapot will be removed. If you then want to make furtherchanges to the teapot, you must use the Edit Polygon tools.

To render the polygonal mesh teapot

1 Render the teapot by clicking the Render Current Frame button on theStatus Line.

Beyond the lesson

In this lesson with Paint Effects, you learned how to:

n Use preset brushes from the Shelf and the Visor.

546 | Chapter 11 Painting

Page 561: Autodesk Maya 2009

n Paint directly in 3D space onto the ground plane or onto 3D objects.

n Select and move strokes in the scene.

n Edit brush and stroke attributes using the Attribute Editor.

n Render paint strokes.

n Use the Paint Effects Panel to paint fully-rendered paint strokes.

n Create a terrain to paint on using the Sculpt Geometry tool.

n Understand the structure and archetype for strokes with tubes.

n Use mesh brush types to paint hard-surface objects.

n Convert mesh brush strokes to polygonal surfaces.

You can use Paint Effects to create natural or fantastic scenery, backdrops, andatmospheres. Mesh Brush types are particularly useful for creating polygonaltrees that appear strikingly convincing, whether they are viewed close-up orfrom a distance.

Paint Effects has many other useful techniques not covered in this lesson.With Paint Effects you can:

n Modify strokes to share a single brush, make strokes glow, and animatethe movement of strokes.

n Attach a brush to an existing curve (you don’t need to paint a curve).

n Add spring-like behavior to strokes with tubes, or you can make the tubesreact to dynamic forces such as wind.

n Create animated textures; for example, falling rain.

Beyond the lesson | 547

Page 562: Autodesk Maya 2009

n Paint using a Thin Line brush type which allows you to render largenumbers of fine tubes much more quickly than the Paint Brush type. Thisbrush type is useful for painting hair.

Lesson 3: Painting textures on surfaces

Introduction

The 3D Paint Tool allows you to paint textures directly onto a model’s surface.In this lesson, you paint colors, patterns, and textures on a dinosaur model.In this lesson you learn how to:

n Prepare a surface model for painting.

n Paint on a surface using both Artisan and Paint Effects brushes.

n Use reflected paint strokes for symmetrical effects.

n Flood fill an entire 3D model with paint.

n Modify brush shapes and stamp settings.

n Paint a bump map texture directly on a surface.

Open the scene for the lesson

You will paint a dinosaur model we prepared for this lesson.

1 Do the steps outlined in Preparing for the lessons on page 503.

2 Open the scene file named 3DPaint.ma.

This file can be found in the GettingStarted directory that you set asyour Maya project:

GettingStarted/Paint/3DPaint.ma

548 | Chapter 11 Painting

Page 563: Autodesk Maya 2009

The scene contains a model named Dino. Although Dino is a polygonalmodel, the 3D Paint Tool works on all surface types: polygonal, NURBS,and subdivision surfaces.

To prepare for this lesson, we assigned a Blinn material named DinoSkinto the model. In Maya, you can paint a surface only if it has a materialassigned to it. We also gave the Blinn material a green color. A color isoptional, but it provides a base color for the texture you will paint.

Finally, we made other preparations to Dino so you can use the 3D PaintTool successfully. You’ll learn about the preparations in Preparing UVsfor painting on page 561.

3 Save the scene in your default scenes directory (File > Save Scene As).

This lesson works best when you start with a saved scene. When you usethe 3D Paint Tool, Maya automatically creates a directory to store the filetexture that will be created from your painting. By saving the scene, youensure that Maya can locate the directory and file texture that it createsautomatically.

4 Select Display > UI Elements > Tool Settings. This displays a Tool Settingspanel where the Channel Box is normally located. You will be workingwith this panel throughout the lesson.

Preparing for painting

1 Select Dino. You can paint only on selected objects. When you actuallyuse the 3D Paint Tool, the wireframe of a selected object is nothighlighted. You can check the Outliner to be sure the object is selected.

2 Select Texturing > 3D Paint Tool. The following warning appears on theCommand Feedback line:Warning: Some surfaces have no file texture assigned to thecurrent attribute.

Preparing for painting | 549

Page 564: Autodesk Maya 2009

The 3D Paint Tool requires that the material assigned to your model hasa file texture applied to it. Because there is no file texture yet assigned,the warning appears.

When you move the cursor over Dino, you see a circle-X icon thatindicates you cannot paint on the model.

3 To make sure you have the default settings for the 3D Paint Tool, clickReset Tool at the top of the 3D Paint Tool settings panel.

4 In the File Textures section of the 3D Paint Tool settings panel, set theAttribute to Paint setting to Color, then click Assign/Edit Textures.

This step and the next two steps assign a texture to Dino. (Note that youcan also paint over an existing texture that you assigned fromHypershade.)

5 Type 512 in the Size X box, which is the height of the new file texture inpixels.

By increasing the file texture size, you will see finer detail and resolutionin a rendered image of your painting. The number 512 is twice the defaultsize, 256. You could use a higher resolution, but sizes larger than 512slow the interactive speed as you paint. Notice that Size Y automaticallychanges to 512. This is because Keep Aspect Ratio is turned on, ensuringthat the proportions of the texture are maintained.

6 Click Assign/Edit Textures in the Assign/Edit File Textures window.

Maya creates a file texture and assigns it to the Color attribute of theDinoSkin material. At the end of the lesson you will learn about the nameand location of the file texture that is created.

You are now ready to paint.

550 | Chapter 11 Painting

Page 565: Autodesk Maya 2009

Painting with an Artisan brush

In the following steps, you paint various colors on the texture you justassigned. You also change the size of the brush strokes.

There are two types of brushes you can use. The default is the Artisan brush,which you’ll use in the next steps. (Artisan refers to a group of painting toolsin Maya that share common tool settings.) The other brush is based on thePaint Effects brushes; you’ll use it later in the lesson.

To paint using an Artisan brush

1 If you have a tablet and pen, you can experiment with pressure sensitivityas you paint. Open the Stylus Pressure section and turn on Stylus Pressure.(You do not need to have a tablet and pen to complete the lesson.)

By default, when you paint with Artisan brushes, the pressure you applyto the pen affects the Opacity setting of the 3D Paint Tool. The harderyou press, the more opaque the stroke.

2 In the Color section of the Tool Settings, click the box next to Color andselect a color in the Color Chooser. Leave the Color Chooser open. You’lluse it in the next few steps.

3 Paint a stroke by dragging on the model.

4 Select another color from the Color Chooser and paint over your firststroke.

The new color paints over the first color by default. Note that you canblend the colors by choosing a different Blend Mode setting, under thePaint Operations heading. You won’t blend the colors in this lesson.

5 Move the brush onto Dino, hold down the b key and drag to the left tomake the brush smaller. Drag until the number at the brush icon changesto about 0.5. You don’t need to be precise.

Use this hotkey when you need to change the brush width. To make thebrush wider, drag to the right. You can also change the width by changingthe Radius (U) setting.

Painting with an Artisan brush | 551

Page 566: Autodesk Maya 2009

6 Experiment with different colors and brush sizes on Dino.

To undo a brush stroke, choose Edit > Undo, Redo, Repeat. The numberof strokes you can undo is specified by the Queue Size in the Undocategory of the Preferences window (Window > Settings/Preferences >Preferences).

7 To remove paint, turn on Erase in the Paint Operations section and strokethe desired region.

Painting symmetrical strokes

You can reflect painted strokes along an invisible axis so that when you paint,the stroke is mirrored on the opposite side of the axis. Reflection is useful forcreating symmetrical effects.

To paint using the reflection option

1 In the 3D Paint Tool settings panel, open the Stroke section and turn onReflection and set the Reflection Axis to X.

Notice that there are now two brush outlines that run along an axis. Thereflection axis is positioned around a point at the center of the object.

2 Paint on one side of Dino, such as one of the legs.

552 | Chapter 11 Painting

Page 567: Autodesk Maya 2009

As you paint, the strokes are reflected along the axis and appear on theother side of Dino. Tumble to see the reflected stroke on Dino’s otherside.

Using Flood All to apply a single color

You can apply a single color to the entire texture without painting individualstrokes.

To use Flood All to apply a single color

1 In the Flood settings of the 3D Paint Tool settings, click the Color boxand select a pale green color from the Color Chooser.

2 Set the Flood setting to All and then click on the Flood Paint button.

The Flood Color overwrites all other painting you’ve done. You can alsouse Flood to erase painting.

3 In the Flood settings, click the Flood Erase button.

Maya eliminates all brush strokes, leaving you with the last saved versionof the texture. (To save the texture, click the Save Textures button in theFile Textures section.)

Brush shapes

You can paint with different brush shapes to produce paint strokes with hardedges, soft edges, or completely different patterns. You can choose from fourstandard Artisan brush shapes, plus 40 preset brush shapes.

To modify the shape of the brush

1 At the top of the 3D Paint Tool settings, click Reset Tool.

Reset Tool cancels the Reflection X and other settings from the previoussteps. While painting, it’s useful to reset the tool settings from time totime so previous settings do not interfere with your next strokes.

If you are using a tablet and pen, you’ll need to turn on Stylus Pressureagain to see the effect of your pressure as you paint.

2 Change the Color setting to dark red or another color that contrasts withthe current green color.

Using Flood All to apply a single color | 553

Page 568: Autodesk Maya 2009

3 In the Brush settings, click the following icon and paint a stroke:

By changing to the square brush shape, your brush stroke has a straightedge. Along with the shapes available from the icons, you can choosefrom many other unusual brush shapes that are based on image files.You’ll do this in the next step. Before you do the next step, undo thebrush stroke you just made so it doesn’t distract from the next paintstrokes.

4 In the 3D Paint Tool Brush settings, click the Browse button.

A browse window opens with a list of various image files. Each filerepresents a different brush shape.

5 Select dapple.jpg and click Open.

6 Click on Dino’s hump and barely move the brush to create a single spotof paint.

Instead of a solid color, a pattern appears on Dino. The pattern is a resultof using the dapple.jpg file for the brush shape. Undo the stroke.

7 Now drag the mouse over Dino to paint a single, continuous stroke.

554 | Chapter 11 Painting

Page 569: Autodesk Maya 2009

The brush shape pattern overlaps itself as you paint, resulting in a stripedpattern. Undo the stroke.

8 To avoid the overlapping pattern of the prior step, increase the StampSpacing (in the Stroke section) to 50. Paint on Dino with a continuousstroke and you’ll see the brush pattern without it overlapping.

The Stamp Spacing setting defines how paint is applied when you strokethe surface. If you set Stamp Spacing to 1, the edges of the brush shapepattern just touch each other. If you set the spacing to be greater than 1,there will be spaces between the brush shape pattern. If you set the spacingto be less than 1, the brush shape pattern will overlap.

Painting with a Paint Effects brush

You can use the 3D Paint Tool with the preset brushes available with PaintEffects. Paint Effects brushes include not only patterns but also images suchas flowers, feathers, hair, and fire.

In the following steps you paint on Dino with a Paint Effects brush. Beforeyou begin, consider first becoming familiar with the Paint Effects brushes, astaught in Lesson 1: Painting in 2D using Paint Effects on page 503.

To paint with a Paint Effects brush

1 In the Brush section of the 3D Paint Tool settings, click the followingicon (Get Brush) to select from the preset Paint Effects brushes:

Painting with a Paint Effects brush | 555

Page 570: Autodesk Maya 2009

The Visor window opens. The Visor organizes the hundreds of PaintEffects brushes into category folders.

2 Scroll to the watercolor folder and click it.

To the right, swatch pictures of the Paint Effects brushes appear for thiscategory.

3 Select the spatterLight.mel brush. (To see the names of the swatches, dragthe pointer over them.)

Leave the Visor window open, but move it so you can see Dino again.

If you are using a tablet and stylus, you need to turn on Stylus Pressureagain to see the effect of your pressure as you paint. Stylus Pressure is offbecause you changed from the Artisan brush to a Paint Effects brush.

For Paint Effects brushes, the pressure you apply to the pen affects threedifferent settings. If you change the settings, it affects only the selectedbrush. The settings for each brush are separate from each other.

4 Paint on Dino.

5 In the Brush section of the 3D Paint Tool settings, click the followingicon (Edit Template Brush) to modify other brush settings:

The Paint Effects Brush Settings window opens. Any changes you maketo the settings in this window affect the display of your next stroke. Asan example, you’ll increase the brush’s incandescence.

556 | Chapter 11 Painting

Page 571: Autodesk Maya 2009

6 Open the Shading section in the Paint Effects Brush Settings window.For the Incandescence1 setting, move the slider to the right and stopmidway.

7 Close the Paint Effects Brush Settings window and paint on Dino. Nowthe paint has an incandescent glow.

Smearing and blurring

In the next steps you’ll smear and blur the paint on Dino. Smearing with aPaint Effects brush blends adjacent colors together along the stroke path.Blurring softens the edges of adjacent colors by averaging their color values.

To smear and blur with Paint Effects brushes

1 Move the Visor window back into view.

2 Click the wetInWet folder and then click the cleanWaterDrip.mel brush.Close the Visor window.

In the 3D Paint Tool settings, under Paint Operations settings, observethat the Paint Operation is now set to Paint Effects Smear. The brush youselected, cleanWaterDrip, has settings that turn on the Smear settingautomatically for you.

3 Paint across the side of Dino. The paint smears and produces an effectsimilar to dripping wet paint.

Smearing and blurring | 557

Page 572: Autodesk Maya 2009

4 In the Paint Operations section of the 3D Paint Tool settings, select PaintEffects Blur.

This selects the default Paint Effects Blur brush.

5 Paint across the side of Dino to see the effect of Blur.

Painting a bump map texture

Next, you’ll paint a bump pattern on Dino. In Maya, a bump texture createsthe illusion of surface relief. It does this by perturbing the surface normals tomake the surface appear bumpy. This is useful for making Dino’s skin appearmore “reptile-like”.

To paint a bump map texture

1 In the 3D Paint Tool window, click Reset Tool to return to the defaultsettings.

2 In the File Textures section, set the Attribute to Paint setting to BumpMap.

3 Click Assign/Edit Textures.

The Assign/Edit Textures window appears.

558 | Chapter 11 Painting

Page 573: Autodesk Maya 2009

Earlier in the lesson, your painting affected only the Color attribute. Topaint bumps, it’s necessary to select a BumpMap as the new attribute youwant to paint, and then assign a new texture for the bumps you’ll create.

4 In the Assign/Edit Textures window, set both Size X and Size Y to 512and then click Assign/Edit Textures.

Maya creates a file texture and applies it to the Bump Map attribute ofthe DinoSkin material.

In the scene view, Dino’s color changes to white. Bump map textures arebased on grayscale colors. By default, when you create a rendered image,bumps will appear in the areas of the surface where there is significantgrayscale color contrast. For instance, if a region has black and whitestripes, you’ll see grooves there. Regions with little or no contrast displayno bump.

The bumps will not show in the scene view; you must create a renderedimage in order to see them. The same is true when you paint certain otherattributes, such as Transparency and Incandescence.

Before you paint bumps on Dino, you must set up the Maya panels soyou can interactively see the results of your strokes in a rendered image.

5 Select Panels > Layouts > Two Panes Stacked.

6 In the bottom panel, select Panels > Panel > Render View.

Maya now displays the perspective view, the Render View, and the 3DPaint Tool settings. With this arrangement, you’ll be able to see yourstrokes render as you paint.

7 In the perspective view, move the camera to a close-up view of Dino’sside.

8 In the Render View, select IPR > IPR Render > persp. This renders an imageof Dino in the Render View.

9 In the Render View, drag a selection box around Dino’s midsection andhump.

Painting a bump map texture | 559

Page 574: Autodesk Maya 2009

This region will update when you paint.

For the IPR renderer to render bumps as you paint, you must update thebump map texture after each stroke. You can set this to occurautomatically.

10 In the File Textures section of the 3D Paint Tool settings, turn on Updateon Stroke.

For a grooved bump effect, you need to change the brush shape.

11 In the Brush section of the 3D Paint Tool settings, click the Browse button.

12 Select the hatch.jpg brush and click Open.

13 Paint on Dino’s side.

Notice the Render View updates with each stroke.

The bumps appear as grooves in Dino’s surface because you paintedcontrasting black stripes on the white texture. In general, gray or blackover a white background results in bumps that appear indented.

If you wanted bumps that appear raised on the surface, you could startwith a black background and paint gray or white over it. For example,you could flood the texture with a black Flood Color, then paint whiteor gray strokes rather than the default black.

Greater contrast between the background color and the color you paintresults in deeper-looking bumps. Less contrast results in more subtlebumps. In the previous step, you painted using a black color, resultingin prominent bumps. If you change the Color setting to a light gray andpaint on the white background, only subtle bumps will appear.

This concludes the lesson.

14 Before doing other lessons, restore the Channel Box in the Maya window.

560 | Chapter 11 Painting

Page 575: Autodesk Maya 2009

15 Select Display > UI Elements > Channel Box/Layer Editor.

Beyond the lesson

In this lesson you were introduced to a few basic techniques related to the 3DPaint Tool. You learned how to:

n Paint textures directly onto surfaces using the 3D Paint Tool.

n Paint symmetrically onto surfaces.

n Paint grey scale attributes to create bump texture effects.

There are several other capabilities in the Paint Operations section, such asthe Clone option for Artisan brushes. With the Clone option, you can duplicatethe color and pattern from an area of the texture and then paint that patternelsewhere on the texture. For details on these options and other 3D Paint Tooltechniques, refer to the Maya Help.

Location of 3D Paint Tool file textures

If you need to move or rename a file texture that Maya creates from yourpainting, look in the 3dPaintTextures directory under the current projectdirectory. If you paint an existing file texture that you created previously, forexample, with a paint program, Maya creates a copy and stores it in the3dPaintTextures directory.

Preparing UVs for painting

In this lesson you worked with a polygonal model that was specially preparedfor painting in this lesson. To paint successfully on a polygonal or subdivisionsurface, you must set up the surface UVs beforehand. UVs are points positionedaround the surface like vertices. They control how Maya stretches a texturearound a surface. For polygons and subdivision surfaces, you must arrangethe UVs so that textures—including the ones you paint with the 3D PaintTool—look correct when applied to the surface material. (The UVs on NURBSsurfaces are automatically arranged for you, so you do not have to changethem.)

You view and edit UVs using the UV Texture Editor (Window menu). You canobtain an introduction to UVs and the UV Texture Editor by completing theUV Texture Mapping lesson in this book. You can also learn more about UVs

Beyond the lesson | 561

Page 576: Autodesk Maya 2009

in the Maya Help by referring to the sections on Polygonal and Subdivisionssurfaces.

If you already have experience with editing UVs, remember these tworequirements for 3D painting:

n UVs must not overlap.

n UVs must fit with the 0 to 1 texture coordinates.

This illustration shows the UV Texture Editor with the UVs for the Dino modelused in this lesson. These UVs meet the above two requirements. Notice thatthe UVs form several meshes; they do not need to be one solid mesh.

Painting in Screen Projection mode

When you paint on a model, the brush follows the contours of the surface.This typically produces the most desirable results. However, this defaultbehavior leads to uneven paint application in some situations. A commonexample is along the line where two surfaces join together. It can also occurif the UVs are not arranged correctly, as described previously.

The solution to these situations is to turn on Screen Projection in the 3D PaintTool settings. Screen Projection applies paint as if you are projecting cinematicfilm onto a screen. Paint appears where the projection strikes the surface.

The following figure shows an example of this situation with a Paint Effectsbrush.

562 | Chapter 11 Painting

Page 577: Autodesk Maya 2009

Beyond the lesson | 563

Page 578: Autodesk Maya 2009

564

Page 579: Autodesk Maya 2009

Expressions

IntroductionExpressions are program-like instructions you create to control keyable attributesover time. Expressions can be comprised of mathematical equations, conditionalstatements, or MEL™ commands.

Expressions offer an alternative to difficult keyframing tasks similar to Set DrivenKey. With Set Driven Key, attribute relationships can be set up and are definedusing animation curves. Unlike Set Driven Key, an expression does not use ananimation curve to define the animation of the attribute but calculates theattribute values over time from the formula defined in the expression.

Although you can create an expression to animate attributes for any purpose,they’re ideal for attributes that you want to change incrementally, randomly,or rhythmically over time.

It is possible to create custom attributes for objects and control them inconjunction with expressions. It is not possible to mix expressions with otheranimation techniques for the same attribute on an object (keyframing, pathanimation, set driven key).

12

565

Page 580: Autodesk Maya 2009

This chapter contains the following lessons:

n Lesson 1 Creating a simple expression: Introduction on page 567

n Lesson 2 Conditional expressions: Introduction on page 574

n Lesson 3 Controlling particle attributes: Introduction on page 584

Preparing for the lessonsTo ensure the lessons work as described, do these steps before beginning:

1 Select File > New Scene to create a new scene.

2 If you have not already done so, copy the GettingStarted folder fromits installation location to your projects directory. Then, set theGettingStarted directory as your Maya project. For more information,see Copying and setting the Maya project on page 25.

3 Select Window > Settings/Preferences > Preferences. Click the Settingscategory and set the Time option to Film (24 fps) so your animation playsat the default rate of 24 frames per second. Click the Timeline categoryand enter 0 and 300 for the Playback Start/End values. (Press the Enter(Windows and Linux) or Return (Mac OS X) as necessary.) Set the PlaybackSpeed to Play every frame. Click the Save button in the Preferenceswindow.

At this playback speed and frame range, the animation results of theexpressions you’ll create in the lessons will be easier to examine andunderstand.

566 | Chapter 12 Expressions

Page 581: Autodesk Maya 2009

4 With the pointer in the perspective view, press 5 (for Shading > SmoothShade All). It’s easier to see the expression effects on shaded objects thanwireframe objects in the following lessons.

Lesson 1: Creating a simple expression

Introduction

This lesson introduces you to some basic concepts regarding the creation andediting of expressions. You learn how to:

n Use the expression editor to create and edit expressions.

n Control both single and multiple attributes of objects in your scene.

Creating expressions to control a single attribute

In the following steps, you create a default sphere and write an expression toincrease its Scale Y attribute as the animation time increases during playback.

To create an expression

1 Make sure you’ve done the steps in Preparing for the lessons on page 566.

2 Create a NURBS or polygonal sphere with an X scale, Y scale, and Z scaleequal to 1. Rename the sphere Ball. (Upper and lower case text isimportant)

3 With Ball selected, choose Window > Animation Editors > ExpressionEditor.

Lesson 1: Creating a simple expression | 567

Page 582: Autodesk Maya 2009

4 In the Expression Name box, you can optionally enter an expressionname, for instance, ScaleBallHeight.

If you write several expressions in the same scene, giving each a namemight make it easier to find the desired expression if you decide to alterit later. If you don’t provide a name, the expression receives a defaultname, for instance, expression1.

Note that the Attributes list displays Ball’s keyable, unlockedattributes—the attributes you’ll most likely want to animate with anexpression. Use the scroll bar to see the entire list.

5 Enter this expression in the expression text area:

Type all characters exactly as shown above. Entries are case sensitive. Thesemicolon (;) signifies the end of the expression statement. End eachstatement in an expression with a semicolon.

An error message appears in the Script Editor and Command Line’sresponse area if the expression has incorrect syntax or typing mistakes.

6 Click Create to create the expression.

Creating the expression checks it for syntax errors and converts it to aform Maya can execute when you return to the start time or play theanimation. Clicking this button also executes the expression for thecurrent frame.

The expression sets Ball’s scaleY attribute to the value of time + 1.Ball.scaleY is the full name of the attribute. A period separates the nameof the object and attribute. Note that you must spell the object andattribute with uppercase and lowercase letters as they appear in theExpression Editor’s Objects and Attributes lists.

The word time is a commonly used predefined variable that updates asan animation plays. It contains the elapsed number of seconds from thefirst frame to the current frame. The value increases with the increasingframe number.

568 | Chapter 12 Expressions

Page 583: Autodesk Maya 2009

At the default animation playback rate of 24 frames per second, time hasthese values (rounded to four decimal places):

Time (seconds)Frame

00

0.04171

0.08332

0.1253

1.024

10.0240

You can find the time elapsed in the animation at any frame bycalculating this formula with a desktop calculator:

For example, if the frame rate is 24 frames/second and the animation isat frame 1, the elapsed time is 1 divided by 24, or 0.0417. At frame 6, theelapsed time is 6 divided by 24, which equals 0.25. Note that if your framerate was 30 frames/second the calculated values would be different.

7 Go to the start time and play the animation. Ball’s scaleY attributeincreases as the time increases:

Ball.scaleY (time + 1)Time (seconds)Frame

100

1.04170.04171

1.08330.08332

1.1250.1253

2.01.024

11.010.0240

Creating expressions to control a single attribute | 569

Page 584: Autodesk Maya 2009

Maya executes the expression each frame. This causes the object size toscale along its Y-axis, stretching its height during playback.

To see the value of Ball’s scaleY attribute at any particular frame, selectBall, display the Channel Box, and stop the animation at the desiredframe. The Channel Box updates its values after you stop the animation.

The scaling is smooth because the geometry stretches in synch with thesmall time increments of the animation playback.

8 Close the Expression Editor window.

Editing expressions

To edit an expression after you’ve created it and closed the window, you mustknow how to find the expression in the Expression Editor. The next stepsshow how to find and edit the expression. Specifically, you’ll change theexpression to alter how quickly the scaleY value changes.

To edit the expression

1 To display the Expression Editor again, select Window > Animation Editors> Expression Editor.

2 To find the expression, make sure the Ball is selected. In the Attributeslist of the Expression Editor, select scaleY, the attribute controlled by theexpression.

If you don’t see the scaleY attribute, scroll through the Attributes list asnecessary. You can also use the Select Filter menu option to customizehow you search for your expressions within the Expression Editor.

The expression you created previously appears in the expression textfield:

570 | Chapter 12 Expressions

Page 585: Autodesk Maya 2009

Ball.scaleY = time + 1;;

3 Change the expression to this:Ball.scaleY = time/5 + 1;;

By dividing time by 5, you’ll make the Y scaling increase one-fifth as fastas with the previous version of the expression.

Note that you can use the keyboard commands Ctrl-c (Windows andLinux) or Control-c (Mac OS X), Ctrl-x or Control-x, and Ctrl-v orControl-v to copy, cut, and paste text in the Expression Editor andelsewhere in Maya.

4 Click Edit to update the modified expression.

Clicking the Edit button does the same action as clicking the Createbutton. The Create button exists only for new expressions. The Edit buttonreplaces the Create button when you display an existing expression.

5 Play the animation to see the results of the new expression.

The sphere scales at a slower rate than before.

6 Stop the animation and go to the start time.

7 At this point and in subsequent steps, save the scene if you think you’llwant to examine it at a later date.

Using expressions to control multiple attributes

You can change the expression to control two or more attributes of Ball as inthis example:

Ball.scaleX = time/2 +1;;Ball.scaleY = time/3 +1;;Ball.scaleZ = time/5 +1;;

Maya scales the Ball at different rates for the X, Y, and Z dimensions.

Linking multiple attributes on the same object

You can change the expression to link the value of one attribute to anotheras in this example:

Using expressions to control multiple attributes | 571

Page 586: Autodesk Maya 2009

Ball.scaleX = time + 1;;Ball.scaleY = Ball.scaleX;;Ball.scaleZ = Ball.scaleX;;

The second statement sets Ball.scaleY to the value of Ball.scaleX. Becauseyou’ve set Ball.scaleX to the value of time + 1, Ball.scaleY also has the valueof time + 1. You’re linking one attribute’s value to another. The third statementalso sets Ball.scaleZ to the value of the attribute Ball.scaleX.

The advantage of this expression is that if you assign a different value toBall.scaleX in the first statement, the second and third statements automaticallyreceive the new value.

Controlling attributes in two objects

You can add an object to the scene and use the expression to control any ofits attributes also. For example, suppose you added a default NURBS orpolygonal cylinder named Drum to the scene. You could control the attributesof Ball and Drum with the same expression as in this example:

Ball.scaleY = time/2 + 1;;Drum.scaleX = time + 1;;Drum.scaleY = time + 1;;

You can link attributes in different objects—so a change in one attribute altersthe behavior of the other. For example, you could cause Drum’s scaleY valueto always equal two times Ball’s scaleY value as in this example:

Ball.scaleY = time + 1;;Drum.scaleY = Ball.scaleY * 2;;

If you decide to control attributes in two (or more) objects, you can selecteither object to write the expression. In fact, any object or node in a scenecan be selected when you write an expression to control an object other thana particle object.

Alternatively, you can write two (or more) expressions, for instance, one thatcontrols Ball.scaleY and one that controls Drum.scaleX and Drum.scaleY.

The advantage of creating separate expressions is that you’ll have twoexpression names, each presumably named after the object and attribute you’recontrolling. Having two expression names makes it easier to find the expressionthat controls the desired attribute.

The advantage of using a single expression to control the attributes is that allstatements are in a single expression. You don’t need to edit two expressions.

572 | Chapter 12 Expressions

Page 587: Autodesk Maya 2009

Beyond the lesson

In this lesson you learned how to:

n Create and edit simple expressions using the Expression Editor.

n Use variables, for example time, to control the specific attributes withinexpressions.When you write expressions, it is common to assign the built-in timevariable to an attribute so the attribute value predictably increases as theanimation plays. It’s also useful to link an attribute’s value to the value ofanother attribute, such as setting the ball’s scale Y and Z attributes to equalthe scale X value.

n Control multiple attributes with a single expression.Your expressions can control multiple attributes of the same object or ofmultiple objects. Alternatively, you can write a single expression for eachattribute or object.

For more information on the various mathematical operators that arepossible with expressions, refer to the Maya Help.

Behind the lesson

Although not shown in the lessons, you can decrease an attribute value duringplayback by subtracting time from some number. Example:

Ball.scaleY = 3 -­ time;;

This decreases the value of Ball’s scaleY attribute for the first three seconds ofplayback.

When you use the predefined time variable, note the animation start framevalue. The lessons in this chapter use a start time of 0. In your work, you mightcreate an animation with a start time of 1. With Maya’s default frame rate of24 frames per second, time is 0.0417 at frame 1.

Because of this small time offset from 0, the prior lesson would have requiredmore steps and instructions to work with frame 1 as the start time. For instance,suppose you use following expression with the start time at 1.

Ball.scaleY = time + 1;;

If you go to the start time, the expression sets the initial value of Ball’s scaleYattribute to time + 1, which equals 0.0417 + 1, or 1.0417. Because Ball’s scaleYattribute was 1 when you created it, going to the start time sets scaleY to avalue 0.0417 larger than its initial value.

Beyond the lesson | 573

Page 588: Autodesk Maya 2009

This discrepancy means the Ball scaleY is larger than its scaleX and scaleZattributes in the first frame of the animation. Although the difference is minorin this example, other cases might be more significant.

To start your animation at frame 1 and get the same result as the example,you can subtract 0.0417 from the attribute:

Ball.scaleY = (time -­ 0.0417) + 1;;

When you go to the start time, the expression sets Ball’s scaleY value to (0.0417- 0.0417) + 1. This equals 1, its original scaleY value.

Lesson 2: Conditional expressions

Introduction

Conditional statements set one attribute or variable for an expression basedon the condition of another attribute or variable. This means that when aparticular defined condition exists for one attribute then another attribute ischanged based on how the expression defines it to do so.

In this lesson you learn how to:

n Use conditional statements to control an expression.

n Refine the conditional statements using if and else statements.

Creating a conditional expression

In the following steps, you create a default sphere and write an expression toincrease its Scale Y attribute based on the animation playback time. In thefirst two seconds of the animation time, Scale Y increases with the value ofthe time. At two seconds and thereafter, Scale Y no longer increases.

To create an expression using conditional statements

1 Make sure you’ve done the steps in Preparing for the lessons on page 566.

2 Create a NURBS or polygonal sphere at the origin with an X scale, Y scale,and Z scale of 1.

3 Name the sphere Balloon.

574 | Chapter 12 Expressions

Page 589: Autodesk Maya 2009

4 Go to the start time.

5 With Balloon selected, choose Window > Animation Editors > ExpressionEditor.

6 Enter this expression:if (time < 2)Balloon.scaleY = time;;

This expression is an if statement. The if keyword causes the expressionto make a decision based on a comparison of two or more items. In thiscase, the expression compares the value of time to the value 2.

The expression checks whether the value of time is less than two seconds.If so, it does the assignment Balloon.scaleY = time. If time is not less thantwo seconds, the assignment doesn’t occur.

NOTE When you compare the value of time to a number in an expression,Maya interprets time as seconds rather than milliseconds, minutes, or anyother unit of time. In the example, Maya interprets 2 as two seconds.

Notice how the assignment Balloon.scaleY = time has been formatted so itappears indented under if (time < 2). Maya ignores all indentation, extraspaces, and blank lines between statements. We used the indentation tomake the expression easier to read. You could have also written theexpression as follows:

if (time < 2) Balloon.scaleY = time;;

This isn’t as easy to read. Consistent, organized spacing is a good habitto develop. This lesson attempts to show examples of good spacing stylewhenever possible.

7 Click Create to compile the expression.

The ball flattens.

The expression executes when you click the Create button. Because theanimation is at frame 0, animation time is 0. Because time is less than 2,Maya sets Balloon.scaleY equal to the value of time, which equals 0.

A scaleY value of 0 flattens the object in the Y dimension.

8 Playback the animation.

Creating a conditional expression | 575

Page 590: Autodesk Maya 2009

The flattened Balloon’s scale increases along its Y-axis. It inflates as theanimation plays.

At 2 seconds and thereafter, Balloon no longer inflates.

When time equals 2 or more, the if condition is no longer true. Thestatement that follows it, Balloon.scaleY = time, no longer executes. Thevalue of the scaleY attribute stays at the last value it had before timebecame 2, specifically, 1.9583.

Recall that this example uses a frame rate of 24 frames per second. Thetime and Balloon.scaleY have these values at various frames:

Balloon.scaleY (time)Time (seconds)Frame

000

0.04170.04171

0.08330.08332

0.1250.1253

1.01.024

1.95831.9647

1.95832.048

1.95832.0449

The if statement’s condition, (time < 2), is a comparison. The conditionmust be surrounded by parentheses to isolate it from assignment thatfollows it.

576 | Chapter 12 Expressions

Page 591: Autodesk Maya 2009

The < in the condition is a relational operator. A relational operator testshow one value relates to another. In the example, the < tested whethertime is less than 2.

Besides the < operator shown in this example, there are several otherrelational operators such as >, >=, ==, and so on. See the Maya Help formore details.

9 Stop the animation and go to the start time. Balloon flattens again becausethe scaleY attribute becomes 0 when you go to the start time. Time is 0,so scaleY is 0.

Other conditional statement options

You can make Balloon rise after it inflates by adding another if statement tothe expression.

To add an if statement to the expression

1 Change the expression to this:if (time < 2)Balloon.scaleY = time;;if (time >= 2)Balloon.translateY = time;;

2 Click Edit to compile the expression.

3 Play the animation.

Balloon inflates for two seconds. After two seconds, Balloon stops inflatingand its position skips from a Y-axis position of 0 to 2. You’ll eliminatethe motion skip in a later step.

The new if statement increases the translateY position of Balloon afterthe animation time rises above two seconds. The >= symbols mean greaterthan or equal to. Whenever time is greater than or equal to 2, theexpression assigns Balloon’s translateY the value of time. The translateYvalue therefore increases for the rest of your animation’s playback range.

Notice that a semicolon ends each statement for a particular condition.Forgetting a semicolon after each statement causes a syntax error, andthe changes you’ve made to the expression won’t take effect.

Other conditional statement options | 577

Page 592: Autodesk Maya 2009

NOTE Always examine the Script Editor for error messages after you edit anexpression and click the Create button. If you alter a previously successfulexpression and a syntax error occurs, Maya executes the previous successfulexpression when you play the animation. This might make you believe yourchanges took effect. Error messages are preceded by the text // Error:.

4 Stop the animation and go to the start time. Balloon flattens but doesn’treturn to the origin. (If Balloon has risen out of view, adjust your camerato see it.)

Balloon doesn’t return to the origin because the expression doesn’t assignBalloon a starting point for the beginning of the animation.

5 To make Balloon return to the origin, change the expression to this:if (time < 2)Balloon.translateY = 0;;if (time < 2)Balloon.scaleY = time;;if (time >= 2)Balloon.translateY = time;;

The new first statement sets Balloon.translateY to 0 whenever time is lessthan 2.

Note that you can put the three statements in any order in this example.When Maya plays each frame, it executes each statement in the expressionin the order listed. In this example, the statements work independently,so their order doesn’t matter.

We put the statements in the order of time execution because it’s easierto see the logic of the expression. If you ever need to change theexpression, you’ll be able to grasp the expression’s actions more quickly.

6 Click Edit.

7 Stop the animation and go to the start time.

578 | Chapter 12 Expressions

Page 593: Autodesk Maya 2009

The flattened Balloon returns to its correct position at the origin.

8 Play the animation.

Balloon inflates for two seconds, then rises. As it rises, it jumps slightlyhigher at approximately frame 48.

Fixing a problem in an expression

As mentioned before, Balloon skips from Y-axis position 0 to 2 after twoseconds of animation play. You can eliminate the skipping and make Balloonrise smoothly from the origin.

To fix the skipping in the animation

1 Stop the animation and go to the start time.

2 Change the expression as follows. (Changes are displayed in bold print.)if (time < 2)Balloon.translateY = 0;;if (time < 2)Balloon.scaleY = time;;if (time >= 2)Balloon.translateY = time -­ 2;;

3 Click Edit.

Playback the animation. Balloon inflates for 2 seconds, then rises slowlyand smoothly with time, from its position at the origin.

Fixing a problem in an expression | 579

Page 594: Autodesk Maya 2009

When time is greater than or equal to 2, the translateY position of Balloonbecomes 2 minus 2, which is 0. As time increases beyond 2 seconds, thetranslateY position increases in the same increments that time increases.

4 Stop the animation and go to the start time.

Using else statements

The expression achieved the desired result, but with unnecessary complexity.You can use an if-else statement to make the statement more compact andeasier to read.

1 Change the expression to this:if (time < 2)Balloon.translateY = 0;;if (time < 2)Balloon.scaleY = time;;elseBalloon.translateY = time -­ 2;;

2 Click Edit.

3 Play the animation.

The animation plays back exactly as before.

This additional variation on the if conditional statement includes theelse statement. It is used as an option when the if statement condition isnot true. The else keyword sets Balloon.translateY to time - 2 when (time< 2) is false. In English terms, the combination of the if and elsestatements means: If time is less than two seconds, set Balloon.scaleY tothe value of time. Otherwise (when time is greater than or equal to twoseconds), set Balloon.translateY to time minus two.

At any instant in the animation’s playback, either Balloon.scaleY = timeexecutes or Balloon.translateY = time - 2 executes. Under no circumstancescan they both execute. The else statement executes only when the ifcondition that precedes it is false.

The first if statement executes whenever time equals 0. It is unrelated tothe if-else statements.

Using else statements instead of multiple if statements makes anexpression simpler to read. If you use an if-else construction instead of alengthy list of if statements, you’ll also improve the execution speed of

580 | Chapter 12 Expressions

Page 595: Autodesk Maya 2009

the expression. This improves your animation’s playback and renderingspeed.

Either expression is valid. If using the if-else construction seems confusing,stick with multiple if statements.

You can accomplish most expression animation tasks with several ifstatements strung after one another.

4 Stop the animation and go to the start time.

Simplifying expressions

You can simplify the expression to make it easier to read.

1 Change the expression to this:if (time < 2)Balloon.translateY = 0;;Balloon.scaleY = time;;elseBalloon.translateY = time -­ 2;;We removed the second if statement:if (time < 2)

In its place, we enclosed the remaining statements with braces and .Maya evaluates both the statements between the braces if the condition(time < 2) is true. Setting Ball.translateY to 0 here instead of in a separateif statement makes the expression easier to read and comprehend.Reducing the statement in this way also makes it more efficient for Mayato process and easier to troubleshoot if you encounter a problem.

Note that you can put multiple statements between braces for an elsestatement, just as you do for an if statement.

2 Click Edit.

3 Play the animation.

The animation plays exactly as before with the new expression.

4 Stop the animation and go to the start time.

Simplifying expressions | 581

Page 596: Autodesk Maya 2009

Editing expressions to refine an animation

You can further refine the animation by expanding Balloon more slowly.

To edit the expression to scale the balloon more slowly

1 Change the expression to this:if (time < 2)Balloon.translateY = 0;;Balloon.scaleY = time * 0.6;;elseBalloon.translateY = time -­ 2;;

(The asterisk (*) multiplies time by 0.6.)

2 Click Edit.

3 Play the animation.

The scaleY attribute increases at 60% of the value of time, so Balloonexpands slower during playback. (The number 0.6 equals 60%.) By thetime Balloon starts to rise, it has expanded to the size of a typical balloon.

To know whether to multiply time by 0.6 or some other number, youneed to experiment.

For example, you might multiply by various percentages such as 0.2, 0.5,0.75, and finally 0.6. The 0.6 creates a life-like balloon shape at twoseconds.

4 Stop the animation and go to the start time.

You can further refine Balloon’s appearance by eliminating the flattenedBalloon that appears at the origin when you go to the start time. You can alsoscale Balloon at different rates along each of its three axes.

582 | Chapter 12 Expressions

Page 597: Autodesk Maya 2009

To edit the expression to change the balloon’s initial scale

1 Change the expression to this:if (time < 2)Balloon.translateY = 0;;Balloon.scaleY = time * 0.6;;Balloon.scaleX = time * 0.5;;Balloon.scaleZ = time * 0.5;;elseBalloon.translateY = time -­ 2;;

2 Click Edit.

At frame 0, Balloon disappears from view because its scale attributes are0.

The scaleX, scaleY, and scaleZ attributes are 0 at frame 0 because time is0. Any number multiplied by 0 is 0.

3 Play the animation.

As time increases, the value of Balloon’s scale attributes increase.

Because the expression sets scaleX and scaleZ to 50% of the value of time,these dimensions scale slower than scaleY, which is set to 60% of thevalue of time. Balloon scales faster in height than in width or depth. Thisis true for many real balloons.

4 Stop the animation and go to the start time.

5 Save the scene if you plan to examine it later.

Editing expressions to refine an animation | 583

Page 598: Autodesk Maya 2009

Beyond the lesson

In this lesson you learned how to:

n Use conditional statements to control an expression.You can accomplish many expression tasks with several if statements strungafter one another. However, using else statements instead of multiple ifstatements makes an expression simpler to read.

If statements and else statements are two of the most common programmingfeatures available in expressions. If you’re familiar with programming, youcan write expressions with an extensive syntax similar to the C language.

For further information and related techniques, refer to the Maya Help.

Lesson 3: Controlling particle attributes

Introduction

You can use an expression to control attributes of particle objects. Particleexpressions can be more complex than other types of expressions. For example,you can write an expression to control all particles in an object the same way,or you can control each particle differently.

In this lesson you learn how to:

n create a particle object

n create a creation expression to set the initial color of the particles

n create a runtime expression to control the color during playback

n use a random function to randomize how the color changes

n control the timing of an expression

Creating particle objects

In the following steps, you’ll create a particle object made of 100 randomlypositioned particles displayed as tiny spheres. You’ll also dynamically add an

584 | Chapter 12 Expressions

Page 599: Autodesk Maya 2009

attribute to the particles. To color particles with an expression, Maya requiresyou to dynamically add the appropriate attribute.

To create a particle object

1 Make sure you’ve done the steps in Preparing for the lessons on page 566.

2 From the Dynamics menu set, select Particles > Particle Tool > .

3 In the Tool Settings window, click Reset Tool, and set the followingoptions:n Particle Name: Bubbles

n Number of Particles: 100

n Maximum Radius: 5

n Click in the scene view (roughly in the center) to create the100-particle object.

4 From the Toolbox, select the Selection Tool so that particles becomeselected.

5 With Bubbles selected, display the Attribute Editor.

6 In the Attribute Editor, select the BubblesShape tab, and then open theRender Attributes section and set the following:n Particle Render Type: Spheres

n Add Attributes For: Click the Current Render Type button.

n Radius: 0.5

7 In the Add Dynamic Attributes section of the Attribute Editor, click theColor button. A window appears that prompts you to choose whether toadd the attribute per object, per particle, or connected to a shader.

Creating particle objects | 585

Page 600: Autodesk Maya 2009

8 Turn on Add Per Particle Attribute, then click the Add Attribute button.

This adds an rgbPP attribute to the particle shape node for Bubbles.Because you’re adding this attribute as a per particle attribute, you cangive each particle a different color.

Using creation expressions to set a constant color

To set an attribute that doesn’t change during the animation (the particlecolor), you’ll use a creation expression. A creation expression executes whenyou go to the start time. It doesn’t execute while the animation plays. (Foremitted particles, a creation expression executes for a particular particle whenit is emitted.)

To create a creation expression

1 In the Per Particle (Array) Attributes section of the Attribute Editor,right-click the rgbPP box and select Creation Expression from the pop-upmenu. Note that the shape node of Bubbles (BubblesShape) is displayedin the Expression Editor.

When you use an expression to control particle attributes, make sure theselected object in the Expression Editor is a particle shape node, not thetransform node of the particle object. If a particle object’s transform nodeis selected, move the mouse pointer to the scene view and press the downarrow key to select the particle shape node.

2 Enter this expression and then click the Create button:BubblesShape.rgbPP = <<1,0,0>>;;

When you click the Create button in the Expression Editor, Maya checksthe syntax of the expression. Assuming you made no typing errors, theexpression executes once for each of the 100 particles.

The expression colors all particles in the object red. The double anglebrackets << and >> enclose a vector that sets the red, green, and bluecomponents of the rgbPP attribute to 1, 0, and 0. In the RGB color scheme,this gives the object a red color.

If the particles are uncolored, check that you’ve turned on Shading >Smooth Shade All. This shading mode is necessary for particles to showthe color assigned in an expression.

3 Play the animation. The particles remain red.

586 | Chapter 12 Expressions

Page 601: Autodesk Maya 2009

Using runtime expressions

There is one other type of expression you can create for a particle object (shapenode)—a runtime expression. By default, a runtime expression executes eachframe during playback. A runtime expression does not execute when you goto the start time (or at the time in which a particle is emitted).

You’ll often create both types of expressions for a particle object—a creationexpression that initializes an attribute value in the first frame, and a runtimeexpression that controls the attribute value in subsequent frames.

The following steps show how to create a runtime expression to change particlecolor during playback.

To create a runtime expression

1 In the Per Particle (Array) Attributes section of the Attribute Editor,right-click the rgbPP box and select Runtime Before Dynamics Expressionfrom the pop-up menu.

2 Enter this runtime expression:BubblesShape.rgbPP = sphrand(1);;

3 Click the Create button to compile the expression.

4 Play the animation.

The particles flicker in random colors as the animation plays back. Theruntime expression controls the rgbPP attribute during playback. BecausergbPP is a per particle attribute, the runtime expression executes for eachparticle in the object for each frame. For each particle, the expressionassigns the rgbPP attribute the output from the execution of the sphrandfunction with an argument of 1. The sphrand function is one of Maya’smany built-in mathematical functions that are useful in expressions.

The sphrand function with an argument of 1 assigns each particle’s rgbPPcolor a random vector. The vector represents a random point in a spherical

Using runtime expressions | 587

Page 602: Autodesk Maya 2009

region of radius 1. The left, middle, and right rgbPP color componentsget a value no less than -1 and no greater than 1. (R, G, and B values lessthan 0 are treated as 0—a black color).

The sphrand function returns a different random vector each execution,so each particle receives a different random rgbPP value, and therefore,a different color. The color changes each frame.

5 Rewind and play the animation again.

The particles become red when you go to the start time, and randomcolors during playback.

NOTE You can use only one creation and one runtime expression per particleobject (shape node) in your scene. To control multiple attributes of a singleparticle object, you must do so within one creation expression and oneruntime expression. You can’t create a separate expression for each attributeas you can for other types of objects. You therefore don’t need to select anattribute from the Expression Editor’s Attributes list.

Modifying runtime expressions

You might have trouble seeing the color of a particle in any instant becausethe color changes so quickly. You can slow the change of colors to create aflashing Christmas light effect. The following steps make the particles changecolors every second of animation.

To adjust the timing of the change of color

1 Change the runtime expression to this:if ((frame % 24) == 0)BubblesShape.rgbPP = sphrand(1);;

This expression uses the modulus operator (%) to control when the rgbPPattribute of the particles receives a random color. The modulus operator

588 | Chapter 12 Expressions

Page 603: Autodesk Maya 2009

returns the remainder after division. For example, 24 divided by 24 returns0, but 25 divided by 24 returns 1. (Dividing 25 by 24 equals 1 with aremainder of 1.)

If the value of frame divided by 24 is equal to any number with aremainder of 0, the assignment to BubblesShape.rgbPP occurs. In otherwords, the assignment occurs when frame equals 24, 48, 72, and so on.At an animation rate of 24 frames/second, the assignment happens onceeach second.

The == symbols mean is equal to. In conditional statements, be carefulto type == rather than =. The = symbol means assign the value to.

2 Rewind and play the animation again.

When you go to the start time, the particles turn red because the creationexpression executes. When the animation plays, the particles receive arandom color once each second.

Note that you can change the beginning red color to random colors bychanging the creation expression to this:

BubblesShape.rgbPP = sphrand(1);;

This is the same expression as the runtime expression.

3 Save the scene if you plan to examine it later. This concludes the lesson.

Beyond the lesson

In this lesson you learned how to:

n Control particles using creation and runtime expressions.

n Apply a random function to your expression.

Beyond the lesson | 589

Page 604: Autodesk Maya 2009

For a particle object, you typically create two expressions—a creation expressionthat initializes an attribute value in the first frame, and a runtime expressionthat controls the attribute value in subsequent frames. (Creation and runtimeexpressions exist only for particle objects, not for other types of objects.)

This lesson described how to color stationary particles as a simple way todescribe creation and runtime expressions. However, it’s more typical to useparticle expressions to:

n Create sophisticated particle motion and life span; for example, themovement and fading of exploding fireworks.

n Create complex colors for emitted particles, for example, rocket exhaustflames.

n Create complex colors and movement of particles following collision withgeometry, for example, sparks resulting from fired bullets.Creating such effects requires experience and experimentation. Expressionwriting can be as complex as computer programming. A detailedunderstanding of expression execution and syntax is essential. You alsoneed to become familiar with the built-in mathematical functions such asthe sphrand function introduced in this lesson.

For further information and related techniques, refer to the Maya Help.

590 | Chapter 12 Expressions

Page 605: Autodesk Maya 2009

Scripting in Maya

IntroductionScripting languages in Maya allow you to:

n Automate repetitive or frequently performed tasks.You can write scripts to execute operations that would normally be selectedfrom the user interface or performed using tools and user manipulation.

n Change Maya’s user interface.You can create windows and controls that affect objects in the scene.

n Establish development standards.You can enforce naming conventions, workflows and model scales.

n Create new tools and functions.You can extend Maya’s functionality in ways that help you do your work.

In this chapter, you learn some common scripting techniques and features thathighlight the capabilities of scripting in Maya:

n Some basic concepts on page 592

n Lesson 1 Commands in MEL: Introduction on page 596

n Lesson 2 Saving scripts to the Shelf: Introduction on page 606

n Lesson 3 Using Variables with MEL: Introduction on page 614

n Lesson 4 Procedures and user interface creation: Introduction on page 624

n Lesson 5 Using Python in Maya: Introduction on page 644

13

591

Page 606: Autodesk Maya 2009

Some basic conceptsThe following section introduces some basic concepts that help you understandwhat’s going on when you use scripting in Maya.

The command architecture

Maya has a command-based architecture for handling all of its operations.The commands for all of Maya’s functionality are accessed through scriptinglanguage commands tied to the Maya user interface—menus, tools, dialogboxes; in fact, just about anything you interact with in Maya. As well, youcan explicitly enter Maya commands in the scripting languages that Mayasupports.

Every Maya command has multiple arguments that set the way in which thecommand executes. Arguments and their implicit or explicit values are requiredfor a command to execute.

To set argument values, the scripting languages in Maya use flags. Flags tellthe scripting language which argument of the Maya command is set withwhat value. The value that is assigned to the argument follows the flag.

Flags have short and long names in MEL and Python. Commands executeidentically whether or not you use the short or long name of the flag. Longnames are often descriptive and useful for new users; short names abbreviateflag names for power users.

Scripting languages in Maya

Maya supports two scripting languages:

n MEL (Maya Embedded Language) is a proprietary scripting languagemodeled after Unix shell script.

n Python is a recent addition to Maya that provides the same access to Maya’scommands as MEL. Python is a widely-used modern programminglanguage.

Maya’s user interface is built using scripts that execute (call) Maya commands.As Python is a recent addition to Maya, the majority of the scripts accessedthrough the user interface are written in MEL.

For example, when you click the sphere icon on the Shelf or select an itemfrom a menu, Maya calls MEL commands to create a sphere or execute thecommand associated with the menu item.

592 | Chapter 13 Scripting in Maya

Page 607: Autodesk Maya 2009

Entering commands in Maya

There are several ways to explicitly enter scripting commands in Maya.

n To enter single line MEL and Python commands, use the Command Line.To show the Command Line if it is hidden, select Display > UI Elements.The Command Line is located near the bottom edge of the Maya interface.

n To enter multi-line MEL and Python commands, use the Script Editor. TheScript Editor displays a history of executed commands, as well as the resultsand outputs of commands. To open the Script Editor, select Window >General Editors > Script Editor.

n As well, the Expression Editor uses a subset of MEL commands to createanimation in the scene. MEL commands in the Expression Editor areevaluated for every frame in the animation. The Expression Editor doesnot support Python commands. To open the Expression Editor, selectWindow > Animation Editors > Expression Editor.

You can also load external MEL and Python files and run them using the ScriptEditor. For more information, see Loading a script file on page 631.

What MEL looks like

Invoking commands in MEL has the basic structure of a command followedby a combination of flags and arguments. Flags are prefaced by the hyphencharacter in MEL.

All MEL commands are case-sensitive; SPHERE is not the same as sphere (andreturns an error message).

If no flags are provided, the command executes with default arguments. Thecommand fails if it requires arguments that it did not get.

Some basic concepts | 593

Page 608: Autodesk Maya 2009

NOTE MEL also has an alternate syntax, which implements commands and flagsin a method similar to the C programming language. For more information, seeMEL for programmers in the MEL and Expressions guide.

Getting help on MEL

You can get help with MEL in three ways:

n To access help on a particular MEL command, open the MEL CommandReference by selecting Help > MEL Command Reference.

n Help can also be accessed from within the Script Editor by using the MayaCommand help. For example, entering help sphere shows a list of flagsthat can be used with the sphere command.

n More information on all aspects of using MEL commands is also availablein the MEL and Expressions guide, part of the Maya Help. Open the MayaHelp and select Using Maya > General > MEL and Expressions.

Basics of Python

Python and MEL are scripting languages with equal prominence andcapabilities in Maya. Python can access all the Maya commands that MELdoes.

Python accesses Maya commands through the Python module maya.cmds.Modules in Python are sets of commands that add functionality to Python,and must be imported before using any of the commands from a module.

Flags in Python are implemented through Python’s named arguments. Youspecify which argument to modify and use the assignment operator (=) toassign a new value to the argument.

In order to run this or any example command, you must have imported thePython module first. Enter import maya.cmds before starting to enter Pythoncommands.

594 | Chapter 13 Scripting in Maya

Page 609: Autodesk Maya 2009

All Python commands are case-sensitive; maya.cmds.SPHERE is not the sameas maya.cmds.sphere (and returns an error message).

Getting help on Python

You can get help with Python in several different ways:

n To access help on a particular Maya (Python) command, open the PythonCommand Reference by selecting Help > Python Command Reference.

n You can also access help on Maya Python commands from within theScript Editor by using the Maya Command help(). For example: typingmaya.cmds.help("sphere") outputs a list of possible flags that can be usedwith the sphere command.

n Help for native Python commands is accessed from within the Script Editorby typing help("command") where command is the Python command youwant to access help for.

n More information on using Python commands is also available in thePython guide, part of the Maya Help. Open the Maya Help and select UsingMaya > General > Python.

n There are existing reference materials and documentation for Python onthe web, as well as many downloadable modules to add extra functionalityto Python.n Getting Started tutorials:

http://www.python.org/about/gettingstartedwww.python.org/about/gettingstarted

n Python documentation: http://docs.python.orgdocs.python.org

n Python modules: http://cheeseshop.python.orgcheeseshop.python.org

Preparing for the lessonsTo ensure the lessons work as described, do these steps before beginning:

1 Select File > New Scene to create a new scene.

2 If you have not already done so, copy the GettingStarted folder fromits installation location to your projects directory. Then, set theGettingStarted directory as your Maya project. For more information,see Copying and setting the Maya project on page 25.

Preparing for the lessons | 595

Page 610: Autodesk Maya 2009

3 Make sure the Construction History icon (below the menu bar) is on. (Ifit is turned off, it has a large X across it.)

4 Ensure that the interactive creation option for primitives is turned off byselecting Create > Polygon Primitives > Interactive Creation. The optionis off when a check mark does not display beside the item’s name in themenu.

5 Ensure that the interactive creation option for surfaces is turned off byselecting Create > NURBS Primitives > Interactive Creation. The optionis off when a check mark does not display beside the item’s name in themenu.

Lesson 1: Commands in MEL

Introduction

This lesson provides a brief introduction to using MEL scripting commands.In this lesson, you learn how to:

n Use the Script Editor to view MEL command history

596 | Chapter 13 Scripting in Maya

Page 611: Autodesk Maya 2009

n Enter MEL commands in the Script Editor

n Create geometry with MEL commands

n Modify attributes of objects with MEL commands

n Interpret Script Editor history

Entering MEL commands

You can enter MEL commands in the Command Line or the Script Editor. TheCommand Line can only accept single line MEL commands, while the ScriptEditor provides a method to input multiple MEL commands and view theresults.

To use the Command Line to input MEL commands

1 Select Display > UI Elements.

Ensure that Command Line is checked.

2 Click in the Command Line text field to position the text cursor in thefield

By default the Command Line is in MEL script entry mode. You canchange the mode by clicking on the text in the lower left hand corner.For this lesson, ensure the Command Line is in MEL script entry mode.

3 Type the following in the Command Line.sphere;;

All MEL and Python entries are case sensitive.

4 To execute the command, press Enter on the numeric part of yourkeyboard, or press Ctrl+Enter.

5 A NURBS sphere is created at the origin.

Entering MEL commands | 597

Page 612: Autodesk Maya 2009

In the Script Editor, the Enter (Windows and Linux) or Return (Mac OS X)key above the Shift key does not execute a command. It starts a new line soyou can type several commands before executing them.

Observing script history

The Script Editor displays a running history of executed commands and theresults of commands that Maya executes. You can copy most commands fromthe history section of the Script Editor and paste them in the input section toexecute them.

To set up the Script Editor

1 Select Window > General Editors > Script Editor.

The Script Editor window opens.

The lower half of the Script Editor is the input section where you enter scriptingcommands.

By default, Maya displays basic feedback from executed commands. However,when Echo All Commands is on, Maya shows all the history from a command,including when a script calls another script or modifies elements of the userinterface. While learning MEL, the extra lines of output produced when EchoAll Commands is on can be confusing because there is so much output. As

598 | Chapter 13 Scripting in Maya

Page 613: Autodesk Maya 2009

you become more experienced in MEL, the extra lines of history can be usefulfor debugging a MEL script.

1 In the Script Editor window, ensure that there is not a check mark besideHistory > Echo All Commands.

To observe script history

1 In the Script Editor, click the Clear History button.

You can more easily isolate the command history created by thecommands you perform when there is no other history in the ScriptEditor.

2 From the Shelf, select the Surfaces tab in order to view the tools locatedon that shelf.

3 Click the NURBS Sphere button on the Surfaces Shelf.

Command history is displayed in the history section of the Script Editor:

CreateNURBSSphere;;sphere -­p 0 0 0 -­ax 0 1 0 -­ssw 0 -­esw 360 -­r 1 -­d 3 -­ut 0 -­tol0.01 -­s 8 -­nsp 4 -­ch 1;;objectMoveCommand;;

Several MEL commands are executed when the Shelf button is pressed.The following happens when the button is pressed:

n The NURBS Sphere button on the surfaces Shelf executes a script calledCreateNURBSSphere;;.

n The CreateNURBSSphere script calls the sphere MEL command usingflags to set the arguments of the command to the values currentlyspecified in the NURBS Sphere menu option window. The sphere MELcommand is using flags in short form.

n The objectMoveCommand is executed every time a primitive is created.It moves the created object to the origin.

Commands in MEL must be separated with semicolons. Additional spacesand additional carriage returns do not affect the execution of the scripts.

Observing script history | 599

Page 614: Autodesk Maya 2009

Blank spaces and returns make scripts easier to read. Flags cannot beseparated from the hyphen character by extra spaces or returns.

TIP For more details on these flags, see sphere in the MEL Command Reference.

The MEL Command Reference gives a complete listing of the functionality ofall MEL commands and flags.

NOTE You can copy commands from the Script Editor history section and pastethem in the input section to execute them.

1 Delete the NURBS sphere by pressing the delete key on your keyboard.

To type a MEL command in the Script Editor

1 Select a MEL tab in the Script Editor.

Script Editor tabs allow you to quickly switch between MEL and Pythonscript entry modes. You can create additional Script Editor tabs to serveas a temporary holding area for scripts.

2 Type the following command in the input section of the Script Editor.polyCube;;

TIP When asked to type a command, you can copy it from these tutorialsand paste it into the Script Editor input section.

3 Execute the command by pressing Enter on the numeric part of yourkeyboard.

You must always type Enter on the numeric keypad or Ctrl+Enter (theregular Enter on your keyboard) to execute commands. Typing regularEnter just creates a new line in the Script Editor input.

600 | Chapter 13 Scripting in Maya

Page 615: Autodesk Maya 2009

A polygonal cube is created at the origin.

The command is removed from the input section of the Script Editorafter execution. The command and the result of the command is outputto the history section of the Script Editor:

polyCube;;// Result: pCube1 polyCube1 //

NOTE In future lessons, when a series of MEL or Python commands createsoutput, only the output created by the commands will be referred to asoutput to the Script Editor.

Comments in MEL begin with // and anything which follows these characterson a line is ignored by MEL. The same convention is used for displaying resultsof commands and output in the Script Editor history section. Similarly, results,comments and messages output by Python are prefaced with the Pythoncommenting character ( # ).

NOTE In the rest of this lesson and the remaining MEL lessons, when asked totype a command, execute the command after typing it with the Enter on thenumeric keypad on your keyboard. You can also execute commands with Ctrl+Enter(Windows) or Ctrl+Return (Mac OS X).

TIP If you do not want the command to be removed from the input section ofthe Script Editor after execution, highlight the command before execution byselecting it with the mouse.

Modifying object attributes

When you perform an action on an object in the Maya user interface, you areusing Maya commands to change the attributes of selected objects. You canuse the same Maya commands explicitly to edit the attributes of objects inthe scene.

To use the move command

1 With the polygonal cube selected, type the following in the Script Editor:move 3 2 1;;

Modifying object attributes | 601

Page 616: Autodesk Maya 2009

The polygonal cube is moved to the XYZ co-ordinates 3,2,1.

The move command has set the translate attributes to the specifiedarguments of the command. These arguments are called commandarguments as they are not used with flags.

When a command is typed into the Script Editor, it acts on the currentselection, unless an object name is provided as an argument to thecommand.

2 With the polygonal cube selected, type the following in the Script Editor:move -­1 -­2 -­3 -­relative;;

The polygonal cube moved relative to its current position by -1,-2,-3 inXYZ.

The move command is used with the relative flag to change the methodin which the command executes. The relative flag does not have anyarguments; the values -1,-2,-3 are command arguments used with themove command. The values are prefaced by a negative sign, but are notrecognized as flags as they do not contain any of the flag keywords.

This is equivalent to using the Move tool in the Maya interface.

To specify attributes of geometry with flags

1 Create a polygonal sphere with a radius of two and four subdivisions inX by typing the following in the Script Editor:polySphere -­radius 2 -­subdivisionsX 4;;

602 | Chapter 13 Scripting in Maya

Page 617: Autodesk Maya 2009

The radius flag allows you to specify a value for the radius of the sphere.The value 2 is associated with the radius flag, and is not a commandargument.

This is equivalent to specifying values within the Polygon Sphere Optionsdialog in the Maya interface.

NOTE Flags have short and long names. Commands execute the same way whetheror not you use long or short flag names. The above command could have beentyped as:

polySphere -­r 2 -­sX 4;;

Some flags have the same short names, but they are used in different contextsso it does not affect the execution of the script. For example: -­r is the shortname of the -­relative flag, used with the move command, -­r is also theshort name of the -­radius flag, used with the sphere command.

1 The sphere has a default name of pSphere#. Rename the selected sphereby typing the following in the Script Editor:rename test_Sphere;;

The rename command changes the name of the currently selected object.If multiple objects are selected, the rename command renames the selectedobjects to the specified name with a numerical index appended, as everyobject must have a unique name.

Modifying object attributes | 603

Page 618: Autodesk Maya 2009

This is equivalent to renaming an object with the Attribute Editor or theChannel Box in the Maya interface.

Editing Objects

Some MEL commands can take an edit flag that allows you to make changesto the attributes of an object. The edit flag is used in conjunction with otherflags specifying which attributes to change.

To edit objects with Maya commands

1 Select the polygonal cube

2 Edit the height of the cube by typing the following in the Script Editor:polyCube -­edit -­height 3;;

This is equivalent to changing attribute values within the Attribute Editorin the Maya interface.

3 Edit the radius of the sphere named test_Sphere by typing the followingin the Script Editor:polySphere -­edit -­radius 1 test_Sphere;;

604 | Chapter 13 Scripting in Maya

Page 619: Autodesk Maya 2009

Commands can operate on objects other than what is currently selectedby specifying an object name as an argument. The name must be the lastargument in the command.

4 Select the cube and the sphere simultaneously by holding down shiftand clicking the sphere.

5 Delete the objects by typing the following in the Script Editordelete;;

NOTE A list of all flags available for a specific command can be displayed inthe Script Editor by typing help command;;. For example, help sphere;;

provides a list of flags for the sphere command.

For a full list of MEL or Python commands and flags, select one of thefollowing from the menu bar:

n Help > MEL Command Reference

n Help > Python Command Reference

Beyond the lesson

In this lesson, you learned how basic MEL scripting commands work in Maya.You can:

n Write basic MEL creation commands to bypass the Maya user interface.

n Use flags at object creation time to specify the attributes for the objects.

n Edit the attributes of objects using a command in conjuction with the editflag.

Beyond the lesson | 605

Page 620: Autodesk Maya 2009

n Observe the history created in the Script Editor and then copy and pasteit into the Script Editor to create your own scripts.

Before proceeding with the next lesson you may want to review the materialpresented in this lesson so you are familiar with the concepts and skills. Somesuggested tasks you can try on your own include:

n Practice using creation commands through the user interface and observingthe resulting Script Editor history.

n Look through the MEL Command Reference to see more commoncommands.

n Practice copying and pasting commands from the Script Editor historysection to the Script Editor input section.

Lesson 2: Saving scripts to the Shelf

Introduction

In this lesson, you set up a three-point lighting system using MEL and savethose MEL commands as a button on the Shelf. This lets you quickly set up athree-point lighting system in future scenes. You learn how to:

n Enter MEL commands in place of selecting menu items

n Create a shelf button to run a series of commands

Three-point lighting uses three different kinds of lights:

n A main light to light the subject, cast shadows and produce highlights

n A fill light to decrease the contrast caused by the main light

606 | Chapter 13 Scripting in Maya

Page 621: Autodesk Maya 2009

n A rim light so the object stands out against the background

Three-point lighting is used extensively in film, photography and computergraphics.

Setting up the scene

Here, you create some primitive objects to display lighting and shading .

1 Select File > New Scene to create a new scene.

2 Select Window > General Editors > Script Editor to open the Script Editor.

3 Create a ground plane by typing the following:polyPlane -­height 40 -­width 40;;

A plane appears at the origin.

The height and width flags specify the dimensions of the plane.

4 Create a NURBS torus by typing the followingtorus -­axis 0 1 0 -­heightRatio 0.5;;

A torus appears at the origin.

The axis of the torus specifies the orientation of the major axis of thetorus. The height ratio flag specifies the ratio of the major radius of thetorus to the height of the torus.

5 Reposition the torus so it is not intersecting the plane by typing thefollowing with the torus selected.move 0 0.5 0;;

The move command takes the argument (x, y, z), specifying how muchand in what direction to move the selected or named object. This abovecommand moves the torus 0.5 units up on the Y-axis.

6 Bring focus to the selected torus in the scene view by pressing f.

7 Render the scene by clicking the render button on the Status Line.

The Render View opens with a rendered image of the scene.

Setting up the scene | 607

Page 622: Autodesk Maya 2009

8 Save the rendered image by clicking the Keep image button . Thislets you compare your rendered image with future rendered images.

A scroll bar at the bottom of the Render View lets you scroll through yoursaved rendered images.

In the next steps, you type commands to create three-point lighting in thescene and record them as script history for later use.

Recording the script history

In order to make a shelf button, you need to create Script Editor history tocopy to the shelf. In this procedure, you create a three-point lighting systemfor the current geometry using MEL, copy the script history, and apply thecreated three-point lighting to an existing scene.

To create the main lighting

1 Clear Script Editor history by clicking the Clear History button .

2 Create a directional light for the main lighting by typing the following:

608 | Chapter 13 Scripting in Maya

Page 623: Autodesk Maya 2009

directionalLight -­intensity 1;;

Certain commands require that you to refer to the light by name.

3 Rename the selected light to “main_light” by typing the following:rename main_light;;

4 Enable the main light to cast shadows by typing the following:setAttr "main_lightShape.useDepthMapShadows" 1;;

The setAttr command allows you to set attributes of a node. In the abovecommand, you are enabling depth map shadows on the main light.

5 Adjust the resolution of the shadow maps so that the shadows appearsharper by typing the following:setAttr "main_lightShape.dmapResolution" 2048;;

In the above command, you are increasing the resolution of the depthmap shadows to 2048.

6 Position and aim the main light by typing the following:move 0 3 0;;rotate -­30 0 0;;

Next, you create a rim light for the scene to help differentiate the torus fromits background.

To create the rim light

1 Create a point light by typing the following:pointLight -­intensity 2 -­rgb 0.9 0.9 1;;

The intensity flag has been used to set the brightness of the light. The-rgb flag sets the color and takes three values: red, green and blue. Thered and green values are less than the blue value, so the light has a bluetint.

2 Rename the light by typing the following:rename back_light;;

3 Reposition the light behind the torus by typing the following:move -­relative -­1.5 1 -­1.5;;

Next, you create a fill light for the scene to soften the main lighting, fill theshadowed part of the torus and decrease the overall contrast of the lightingin the scene.

Recording the script history | 609

Page 624: Autodesk Maya 2009

To create the fill lighting

1 Create a point light with an intensity of 0.5 by typing the following:pointLight -­intensity 0.5;;

2 Rename the light by typing the following:rename fill_light;;

3 Reposition the light above the torus in a way so that the light rays fromthe fill light are approximately 90 degrees to those of the main light bytyping the following:move -­relative 4 6 2;;

Compare the rendered images

Rendering the image

1 Render the scene in the perspective view by selecting the render scene

button on the Status Line.

2 Save the rendered image by clicking the Keep Image button in theRender View.

3 Compare the two images using the scroll bar at the bottom of the window.

The newly rendered image has a shadow. If there was no fill light, detail wouldbe lost in the shadowed area, as the shadow would be black. The rim highlightsemphasize the curvature of the torus and help to differentiate the torus fromthe background.

610 | Chapter 13 Scripting in Maya

Page 625: Autodesk Maya 2009

When creating three-point lighting in a scene with multiple objects, typicallythere is a main light that provides the main lighting for the scene, and eachobject in the scene has a linked fill and rim light.

Your three-point lighting script only works for objects of medium scale locatedat the origin, but once the lights are created, you can tweak them to bettersuit your scene.

Saving the history as a button

You can save Script Editor history as a Shelf button.

To create the shelf button

1 Highlight all the text in the history window by clicking at the beginningof the history in the upper section of the Script Editor and dragging theselection to the end of the Script Editor history section.

2 Release the mouse button. The selected text should read:directionalLight -­intensity 1;; rename main_light;; setAttr"main_lightShape.useDepthMapShadows" 1;; setAttr "main_lightShape.dmapResolution" 1024;; move 0 3 0;; rotate -­30 0 0;; pointLight -­intensity 2 -­rgb .9 .9 1;; rename back_light;; move -­r -­1.51 -­1.5;; pointLight -­intensity .5;; rename fill_light;; move -­r 46 2;;

3 Middle-drag the selected text to the shelf.

A pop-up window asks you which type of shelf button you are saving.

Saving the history as a button | 611

Page 626: Autodesk Maya 2009

4 Click the MEL button on the pop-up window.

A Shelf button is created that executes the scripting commands youdragged to the shelf setting up three-point lighting for a scene.

To test the Shelf button

1 Open the scene named Mel_Cone.ma.

This file can be found in the GettingStarted directory that you set asyour Maya project:

GettingStarted/scenes/Mel_Cone.ma

2 Render the scene in the perspective view by selecting the render scene

button on the Status Line.

3 Save the rendered image by clicking the Keep Image button in theRender View.

4 Click your newly created MEL Shelf button.

Three point lighting is applied to the scene.

5 Render the scene again by selecting the render scene button on theStatus Line.

6 Compare the two images using the scroll bar at the bottom of the window.

612 | Chapter 13 Scripting in Maya

Page 627: Autodesk Maya 2009

To delete the Shelf button

1 Middle-drag the Shelf button you want deleted to the trash can icon onthe far right of the Shelf.

NOTE The pointer icon changes to a icon when you are dragging a Shelfbutton.

Beyond the Lesson

In this lesson, you learned how to copy history from the Script Editor historysection to create Shelf buttons so that you can quickly execute a series ofcommands. You can:

n Save multiple MEL script commands as a Shelf button.

n Type basic MEL creation commands to bypass the Maya user interface.

n Use additional MEL script commands and MEL script command flags.

Here are some other things you can do with Shelf buttons.

n You can save the custom settings for a menu option box command as ashelf button by setting the parameters in the option box, and then selectingthe item from the menu while holding down Shift+Ctrl (Windows) orShift+Control+Option (Mac OS X).

Beyond the Lesson | 613

Page 628: Autodesk Maya 2009

n You can add custom images to a shelf button, change the name of a shelfbutton, or change the commands associated with a shelf button by selectingWindow > Settings/Preferences > Shelf Editor. For more information, see

n You can also create custom icons for your Shelf buttons in your favoriteimage editing program. Icons must be 32X32 pixels and in bitmap format.

Lesson 3: Using Variables in MEL

Introduction

In this lesson, you learn how to store data in MEL variables. Variables are amethod of storing data in programming, including scripting languages. Inthis lesson you use the saved value of a variable to create a pyramid of barrelsusing MEL scripting commands. You also learn how to:

n Use MEL to create copies of existing geometry

n Use variables to store and recall data

n Use the built in MEL math functions to modify the value of variables

n Apply dynamics to scene objects using MEL

614 | Chapter 13 Scripting in Maya

Page 629: Autodesk Maya 2009

Setting up the scene

To import and position the barrel

1 Open the scene named mel_lesson3_Barrel.ma

This file can be found in the GettingStarted\MEL directory that you setas your Maya project, in the scenes sub-directory.

2 Open the Script Editor by selecting Window > General Editors > ScriptEditor.

3 Select the barrel with the select tool.

4 In the Script Editor, type the following:

Type exactly as below:

rotate -­r 0 0 90;;

The barrel is rotated 90 degrees about the Z axis.

Storing scene information

You will store the value of the measurement annotation as a variable. A variableis a name used for convenience to refer to a certain location in memory. Thislocation in memory can store data.

Variables have four main characteristics; name, type, value and scope. Name,type and scope are defined at creation time. Defining the name and type ofa variable is referred to as declaring a variable. In MEL the name of the variable

Setting up the scene | 615

Page 630: Autodesk Maya 2009

is always prefixed by the “$” symbol, indicating to the scripting language thatthe following characters name a variable.

The scope of the variable determines where the variable can be accessed from.If a variable is declared within a block of code, it cannot be accessed fromoutside the block of code.

Name and type cannot change after creation. The value of a variable canchange, but the value must be of the earlier defined type.

NOTE Variables in MEL should always have their type explicitly defined. If notexplicitly stated, the scripting language attempts to imply a data type for thevariable from the context of the first appearance of the variable. It is good practiceto explicitly declare variables as implicitly defining variables can lead to scriptingerrors and slows down the execution of the script.

To store scene information as a variable

1 In the Script Editor, type the following and press enter:float $diameter_barrel;;

This command declares a variable of data type float, with the namediameter_barrel. A floating point value is a number containing a decimal.

2 To assign a value to the variable, type the following.$diameter_barrel = 4.2;;

The diameter of the barrel is 4.2 units. This value from the scene isassigned to the variable. A value is assigned to a variable with theassignment operator (=).

Storing other types of data

MEL also supports other data types that are common to most otherprogramming languages.

To declare a string variable

1 Type the following in the Script Editorstring $testString = "this is a test";;print $testString;;

The following is output to the Script Editor:

this is a test

616 | Chapter 13 Scripting in Maya

Page 631: Autodesk Maya 2009

The string data type is used to store multiple characters. The printcommand outputs the value of a variable to the Script Editor.

NOTE Variables can be declared and assigned a value in the same statement.

To declare an int variable

1 Type the following in the Script Editorint $testInt = 5;;print ($testInt/2);;

The following is output to the Script Editor:

2

The int data type is used to store integer values. Integers are positive andnegative whole numbers. In programming, when an integer is dividedby another integer, the result is an integer, which is why the output hereis not 2.5 (2.5 is not an integer).

The print command’s argument is enclosed in brackets. The printcommand can only take one argument, so brackets are used to tell Mayato evaluate the contents of the brackets before executing the command.Brackets can also be nested in a method similar to mathematicalstatements to determine the order of evaluation of statements.

In the steps that follow, you create a row of barrels by spacing the barrelsevenly. This creates barrels that are just touching, which ensures that thereare no intersections during the rigid body simulation

In the next section, we’ll use the move command to position the duplicatebarrels, using the saved value of the diameter as an argument for the Z valueof the command.

Create a row of barrels

Here, we’ll use the stored value of the diameter to space the duplicates of thebarrel. Variable values can be recalled at any time. Variables can be used asvalues for arguments.

To duplicate the barrels

1 Select the barrel.

Create a row of barrels | 617

Page 632: Autodesk Maya 2009

2 Duplicate the barrel by typing the following:duplicate;;

You have a duplicate of the first barrel, and it is the currently selectedobject.

3 Align the duplicate barrel with the original by moving the duplicate inZ by a value equal to its diameter by typing the following:move -­r 0 0 $diameter_barrel;;

A duplicate of the original barrel is created and aligned to the first barrel.

4 Make another copy of the barrel by typing the following:duplicate;;move -­r 0 0 $diameter_barrel;;

The current selection switches to the newly created geometry.

5 Duplicate the currently selected barrel and align the duplicate with thepreviously created barrel.duplicate;;move -­r 0 0 $diameter_barrel;;

When duplicating objects, the selection always switches to the duplicate.Each barrel is spaced the same relative to its neighbors.

The first row of barrels is complete.

Stacking the row of barrels

Stack the barrels in a triangular arrangement by duplicating the existing rowand offsetting the row in both X and Y.

618 | Chapter 13 Scripting in Maya

Page 633: Autodesk Maya 2009

Using basic trigonometry, you can calculate the unknown height offset. MELhas a library of built-in functions that include trigonometry functions, tohandle these calculations.

NOTE Trigonometry functions are ratios that relate two sides of a right angledtriangle dependant on one of the angles of the triangle. Trigonometry functionsare often used for animation, as trigonometric functions are periodic. Periodicfunctions cycle their output values after a certain period. These functions can easilycreate cyclical or repeating animation.

Using MEL built-in functions to calculate the Y offset

Sine is the ratio obtained by dividing the side opposite the angle by thehypotenuse. Since the center points of the barrels are spaced along the pointsof an equilateral triangle, all angles of the triangle are equal to 60°. If youmultiply the sine of 60° by the length of one of the sides of the triangle, theresult is the height of the triangle.

It is important to know which units of measurement the built-in functionsof a programming language use. Many programming languages, includingMEL and Python, perform trigonometric operations in radians. You must

Using MEL built-in functions to calculate the Y offset | 619

Page 634: Autodesk Maya 2009

convert from degrees to radians when using the sine function to calculate theY offset.

NOTE Radians are a method of measuring sections of a circle. There are 360degrees in a circle, which is equivalent to 2pi radians.

To calculate the offset in Y

1 Declare a new variable to store the value of the Y offset by typing thefollowing:float $Y_offset;;

2 Calculate the value of the Y-offset using the sine ratio. You must convertthe value of the angle to degrees with the degree to radian conversionfunction.$Y_offset = $diameter_barrel * (sin(deg_to_rad(60)));;

The assignment operator evaluates the right hand side of the expressionand assigns it to the left hand side. The degree to radian conversionfunction is the first to be evaluated, as it is within the most interior setof brackets. The sine function calculates the sine of the angle given inradians. The sine value is multiplied by the diameter to calculate the Yoffset. The variable is assigned the calculated value.

NOTE The variable $diameter_barrel does not change in value. Only thevariable on the left side of an assignment operator changes in value.

To stack the rows of barrels

1 Select and duplicate all the objects in the scene, by typing the following:select -­allDagObjects;;duplicate;;

Using the select command with the -­allDagObjects flag selects all DAG(Directed Acyclic Graph) objects, which are a set of objects that exist inthe scene such as geometry, IK chains and measure tools. Textures andanimation information do not belong to the Directed Acyclic Graph.

2 Offset the barrels by the radius of a barrel in X and the calculated$Y_offset in Y, divide the diameter by 2 to get the value of the radius.When duplicating the rows, you have created too many barrels.move -­r 0 $Y_offset ($diameter_barrel/2.0);;duplicate;;move -­r 0 $Y_offset ($diameter_barrel/2.0);;

620 | Chapter 13 Scripting in Maya

Page 635: Autodesk Maya 2009

duplicate;;move -­r 0 $Y_offset ($diameter_barrel/2.0);;

3 Using the Lasso tool, select the extra barrels.

4 Delete the extra barrels to obtain a pyramid shape.

Creating dynamics with MEL commands

Maya lets you easily add dynamic properties to the objects in your scenes. Allattributes that can be modified by selecting menu items, can be accessed bysetting the arguments of a Maya command.

In this section you create a dynamic simulation using MEL so that the stackof barrels reacts to gravity and moves in a realistic manner. Apply a rigidBodynode to all of the barrels, add a gravity field and a passive rigid body planefor the barrels to collide with.

For more information about rigid bodies and fields within dynamics in Maya,see Lesson 2: Rigid bodies and constraints on page 494 and the Dynamics guidein the Maya Help.

To add rigid body nodes to the barrels using MEL

1 Select all the barrels by typing the following:select -­allDagObjects;;

Creating dynamics with MEL commands | 621

Page 636: Autodesk Maya 2009

2 Move the stack of barrels upwards along Y (by half the height of a barrel)so they are not intersecting the ground plane.move -­r 0 (0.5*$diameter_barrel) 0;;

3 Add a gravity field to the selected geometry by entering the following inthe Script Editor.performDynamics 1 Gravity 0;;

When a gravity field is added to the geometry, rigid body nodes areautomatically added to the geometry.

To create a plane for the barrels to simulate against

1 Make a plane for the barrels to simulate against by typing the following:polyPlane -­height 100 -­width 100;;

2 With the plane selected, add a rigid body node to the plane by typingthe following:rigidBody -­passive;;

622 | Chapter 13 Scripting in Maya

Page 637: Autodesk Maya 2009

To view the simulation

1 Click the play button on the time slider to view the dynamics simulation.

Beyond the lesson

In this lesson, you were introduced to how to use variables in MEL with Maya.You can:

n Declare, set and use variables.

Beyond the lesson | 623

Page 638: Autodesk Maya 2009

n Perform mathematical operations to modify the value of a variable.

n Implement dynamics using MEL commands.

Before proceeding with the next lesson you may want to review the materialpresented in this lesson so you are familiar with the concepts and skillsassociated with them. Some suggested tasks you can try on your own include:

n Practice creating, modifying and performing operations with variables. Inthe next lesson, you use variables extensively to create a user interface.

Lesson 4: User interface creation andprocedures

Introduction

In this lesson, you create a user interface for an existing Maya procedure usingMEL scripting commands. You learn how to:

n Create a simple window

n Use conditional statements to check the existence of a window

n Use a built-in Maya procedure

n Link a procedure to a user interface

Creating a window

The first step in creating custom user interfaces is to create a window. Thiswindow contains the elements of the user interface such as text, buttons andother controls.

To create a window

1 Type the following commands into a MEL tab of the Script Editor.window -­resizeToFitChildren 1;; showWindow;;

A window appears.

624 | Chapter 13 Scripting in Maya

Page 639: Autodesk Maya 2009

The -­resizeToFitChildren flag on the window command specifies thatthe window automatically resizes to fit all of the elements within thewindow. This flag must have a value: a value of 1 turns on the flag, avalue of 0 turns it off.

When you create a window, it is not visible until you use the showWindowcommand. The showWindow command without any arguments makes thelast window created visible.

2 Close the window clicking the X in the upper right hand corner.

Referencing controls

When creating windows with MEL scripting, you must ensure that everywindow and user interface control is given a unique name. If you do notexplicitly give a window a name, it gets a default name. (In the previousprocedure, the name of the window was window1, even though you didn’tuse it.) You cannot reference or modify windows or controls that you don’tknow the name of.

To refer to a user interface element by name

1 Create a window with text and a button that closes it by typing thefollowing in a MEL tab of the Script Editor:window -­resizeToFitChildren 1 testwindow;; columnLayout;; text-­label "This is a test window you can close by\ clicking thebutton below.";; button -­label "Close" -­command "deleteUItestwindow";; showWindow;;

2 Press the Close button in the window.

The window closes.

Creating a window | 625

Page 640: Autodesk Maya 2009

Discussion: creating a simple window

In your window, you created elements for your user interface, called controls.All user interface controls must be created within a layout. Layouts instructMaya how to arrange the user interface elements in the window.

There are many different types of layouts—for example, formLayout androwLayout—but the simplest and easiest to use is the columnLayout. ThecolumnLayout lays out your controls in a column, one underneath the other.For more information on layouts, see Layouts of the MEL and Expressionsguide.

Within the layout you created a text control, with the text command. Thelabel flag’s argument is the text displayed in the window.

The button is created by the button command. The argument of the commandflag is a MEL command that is executed when the button is pressed. In thiscase, pressing the button executes the deleteUI command, which deletes thewindow you just created.

Scripts spanning multiple lines

In this script, individual commands span multiple lines. Commands can spanmultiple lines as long as the end line character is at the end of the command.One convention in MEL is to have the command keyword on one line, andpair the modifier flags and values on separate lines underneath the command,as in this example.

Strings can’t be split up over multiple lines without the use of a specialcharacter. To split a string over multiple lines, use the back slash (\) character.For example:

print "With the \\ character, you can \ split a string over \multiple lines.";;

To have a backslash appear in a string, you must use a double backslash. Thebackslash character is an escape character. Escape characters tell the scriptinterpreter that the character that follows is literal. Certain special symbolscan be created using the escape character in combination with other characters.For example, to display quotes within a string:

print "Jim said \"Hello!\" to the Maya user";;

626 | Chapter 13 Scripting in Maya

Page 641: Autodesk Maya 2009

Window naming

As user interface scripts get more complex, it is possible that you may makea syntax error. If a user interface script partially executes and halts on an error,the window still exists, but the window is not visible. If you fix the problemand would like to execute the script again, you must either give the windowa new name, or delete the hidden window.

Resolving naming conflicts

In the next section, you use conditional statements to resolve window namingconflicts. Conditional statements allow a section of code to execute dependingon the value of a variable or the state of an object in the scene.

To resolve conflicting window names

1 Create a window with a scripting error inserted before the showWindowcommand by typing the following in a MEL tab of the Script Editor:window testwindow;; fake_command;; showWindow;;

An error is output to the Script Editor.

// Error: line 2: Cannot find procedure "fake_command;;". //

The window is not displayed, but still exists.

2 Create another window with the same name by typing the following ina MEL tab of the Script Editor:window testwindow;; showWindow;;

An error is output to the Script Editor.

// Error: line 1: Object's name is not unique: testwindow //

All objects in Maya and user interface elements must have unique names.

To query a window’s existence

1 Type the following command in the Script Editor input section, to deletethe hidden window:deleteUI testwindow;;

2 Check if the window exists by typing the following command:window -­exists testwindow;;

The following result is output to the Script Editor.

// Result: 0 //

Window naming | 627

Page 642: Autodesk Maya 2009

The exists flag of the window command changes the command so thatit either returns a one or zero depending on whether or not the windowexists.

3 Type the following in the Script Editor:deleteUI non_existing_window;; sphere;;

An error is output to the Script Editor.

// Error: line 1: Object not found: non_existing_window

The sphere command does not execute as the script has halted on thescripting error.

To be able to delete the existing user interface only if it exists, conditionalstatements can be used.

To delete a window on condition

1 Type the following in a MEL tab of the Script Editor:window testwindow;; fake_command;; showWindow;;

The window is invisible as there is a scripting error, and the showWindowcommand did not execute.

2 Type the following in a MEL tab of the Script Editor:if (`window -­exists testwindow`==1) deleteUI testwindow;; window -­resizeToFitChildren 1 testwindow;; columnLayout;; text-­label "This window deleted the other one";; showWindow;;

Two concepts are being introduced here:

n The if statement allows a certain part of code to execute depending on acondition. The section of code within the curly braces only executes if thestatement inside the parentheses evaluates to true.

n The paired back-ticks within the parentheses (` `) indicate that thecommands within them are evaluated first. This is a useful part of writingMEL code: you can make certain commands (here, the conditionalstatement) dependent on other commands (here, the evaluation of whetherthe window exists), which execute and evaluate first.

628 | Chapter 13 Scripting in Maya

Page 643: Autodesk Maya 2009

Together, the if statement and the evaluation mean that only if the resultof the window existence query is “1” (the window exists) is the windowdeleted. Otherwise, the section of code within the curly braces is skipped.

Storing control names

If you refer to a control in your user interface, it must have a name. Insteadof manually specifying the name for each user interface element, you canallow the command to generate unique default names and then you can storethe name as a variable.

All user interface commands return their full name and path upon creation.You can store the return value as a variable to refer to the control at a laterpoint in the script.

To store a control name as a variable

1 Type the following in a MEL tab of the Script Editor:window -­resizeToFitChildren 1 pick_me_window;; columnLayout;;$button_one=`button -­label "Click Me!" -­command "deleteUI$button_two"`;; $button_two=`button -­label "NO!, Click Me!!"-­command "deleteUI $button_one"`;; $button_close=`button -­label"Close" -­command "deleteUI pick_me_window"`;; showWindow;;

We’re using backticks for evaluation again here, though in this case, we’recreating three variables ($button_one, $button_two, and $button_close)that hold the results of calling the button command each time.

2 Press one of the “Click Me!” buttons in the window to test the script.

Clicking one of the “Click Me!” buttons deletes the other button bycalling the deleteUI command with the variable that stores the name ofthe button control as an argument (button_one or button_two).

(If you click the button a second time, you’ll get an error as the buttonyou’re trying to delete has already been deleted.)

3 Close the window by pressing the Close button in the window.

When you created your user interface window, you assigned it a uniquename manually. This is a good practice to ensure that you cannot openmultiple copies of a user interface. With more complicated user interfaces,

Window naming | 629

Page 644: Autodesk Maya 2009

multiple copies of the same user interface could interfere with each otheror slow down Maya.

NOTE You can view the full name and path of a user interface elements byusing the print command to output the variable.

print $button_one;;

The following is output to the Script Editor:

pick_me_window|columnLayout2|button1

This is the full path of the user interface control. You are using variablesto store the name and path of controls and therefore you do not have totype the whole name and path to refer to user interface elements.

In this section, you learned how to create, delete, and check for the existenceof named windows. In the next section, you’ll hook up a more complexwindow to a procedure.

Introduction to procedures

A procedure is a series of instructions that are separate from the main flow ofthe script. Procedures allow you to reuse certain portions of a script for newapplications.

In this section, you use a procedure that is included with Maya (makeroll,which simulates an object rolling on a plane). Later in the lesson, you linkthis procedure to a user interface to provide an easier way to use the procedure.

To execute the makeRoll procedure

1 Create a cube and a ground plane by typing the following in a MEL tabof the Script Editor:polyCube -­name roll_Cube;; polyPlane -­height 10 -­width 10;;

2 Execute the makeRoll procedure by typing the following in a MEL tab ofthe Script Editor:

630 | Chapter 13 Scripting in Maya

Page 645: Autodesk Maya 2009

makeRoll roll_Cube 0 1 1.0;;

The makeRoll procedure requires the following arguments: the name ofthe object to act on, the height of the ground plane, the type ofsimulation, and the diameter of the object. The type of simulation iseither box or sphere simulation. Rolling simulation is determined usinga bounding sphere when simulation type is set to 0, or a bounding boxwhen simulation type is set to 1.

3 Set the current frame to two by selecting the current frame box and typinga two.

The expressions set up by the makeRoll procedure only take effect whenthe frame is greater than one.

4 Select the cube with the Move tool.

5 Move the cube along the plane in X and Z using the Move tool.

The cube rolls on the ground plane.

You have successfully loaded and used the makeRoll procedure. Now, you’lllink the procedure to a user interface.

Loading a script file

You can read and edit script files other people have created in the Script Editor.In this section, you open a script that contains a completed user interface forthe makeRoll procedure. However, the user interface is only a layout, and doesnot contain any functionality.

To prepare to open the script

1 In the Script Editor, ensure that Command > Show Line Numbers ischecked.

Loading a script file | 631

Page 646: Autodesk Maya 2009

When Show Line Numbers is on, line numbers appear beside thecommands in the Script Editor. The lesson occasionally refers to linenumbers to tell you where to make a modification to the script. Whenline numbers are referred to in the lesson, they are always the linenumbers of the original script.

2 Create a new tab in the Script Editor by selecting Command > New Tab.

A pop-up window asks you in which language should the commandsentered in this tab execute in.

3 Click the MEL button on the pop-up window.

You created a second MEL tab in the Script Editor.

4 Select Command > Rename Tab.

5 Enter MEL2.

The tab is renamed.

In the next steps, you load a user interface script into both MEL tabs. The MELtab will contain the original script, and the MEL2 tab will contain the userinterface script with your modifications. This way, line numbers can bereferenced from the original script to inform you where to make a modification.

To open a script file in the Script Editor

1 Select the MEL tab.

2 In the Script Editor, select File > Load Script.

3 Select the MEL script named Mel_UI_Start.mel.

This file can be found in the GettingStarted directory that you set asyour Maya project, within the mel sub-directory.

632 | Chapter 13 Scripting in Maya

Page 647: Autodesk Maya 2009

The contents of the MEL file are displayed in the Script Editor.

4 Load the same MEL script into the MEL2 tab by repeating the aboveprocedure.

5 In the MEL tab, highlight the script by selecting Edit > Select All fromthe Script Editor menu bar.

6 Execute the script by pressing Ctrl+Enter.

A user interface is created for the makeRoll procedure. There is a controlin the user interface for each argument of the makeRoll procedure.

(You can leave this window open as we’ll be doing some testing with it,though it doesn’t do anything yet.)

Discussion: what the script does

1 The controls in the user interface are created by various commands.Below,

the script has been broken up into sections to describe the various user interfacecontrols and their flags. The user interface controls and commands that youused earlier in the lesson are described only briefly below.

Conditional statement

if(`window -­exists makeRoll_Window`==1) deleteUI makeRoll_Window;;

The conditional statement checks if a window with the specified name exists.If the window exists, it deletes it.

Window command

window -­resizeToFitChildren 1 makeRoll_Window;;

Loading a script file | 633

Page 648: Autodesk Maya 2009

The window command creates a user interface window to contain the controls.For more information, see Creating a window on page 624.

Column layout

columnLayout;;

The columnLayout command creates a layout that arranges the controls withinit in a column. For more information, see Referencing controls on page 625.

Text field commands

$obj_name_text = `textField -­editable 0 -­width 400 -­textname_Of_Object`;;

The command textField creates an editable text field. The text field commandhas multiple flags. The name and path of the text field are stored as a variable.See Storing control names on page 629.

n The editable flag enables or disables editing of the text field.

n The width flag sets the width of the control.

n The text flag sets the contents of the text field.

Slider commands

$ground_int= `intSliderGrp -­minValue -­20 -­maxValue 20 -­value 0-­fieldMinValue -­20 -­fieldMaxValue 20 -­field 1 -­label "GroundPlane"`;; $diameter_float= `floatSliderGrp -­value 1.0 -­minValue1.0 -­fieldMinValue 1.0 -­field 1 -­label "Diameter"`;;

The commands intSliderGrp and floatSliderGrp create sliders. Commandsending in Grp create a group of linked controls. The slider commands createcontrols for a label, a value box and a slider. The slider command has multipleflags. The name and path of the slider are stored as a variable. See Storingcontrol names on page 629.

n The editable flag can be used to enable or disable editing of the text field.

n The minValue and maxValue flags set the minimum and maximum valuesfor the slider.

n The field flag enables the visibility of an editable value field beside theslider. By default, the field is not visible.

634 | Chapter 13 Scripting in Maya

Page 649: Autodesk Maya 2009

n The fieldMaxValue and fieldMinValue flags set the minimum andmaximum values for the field beside the slider.

n The label flag sets the text that appears to the left of the slider.

Separator commands

separator -­height 20 -­width 120;;

The command separator creates a horizontal line. It is used to space thecontrols vertically in the window. The separator command has multiple flags.

n The width flag sets the visible width of the separator.

n The height flag sets the amount of vertical spacing created by the separator.

Check box commands

$box_sim_checkbox = `checkBox -­value 1 -­label "Box Simulation"`;;$sphere_sim_checkbox = `checkBox -­value 0 -­label "Sphere Simulation"`;; separator -­height 20 -­width 120;; $execution_button=`button -­label "Execute!" -­command "print (\"something\");;"`;;

The command checkBox creates a check box. The check box command hasmultiple flags. The name and path of the check box are stored as a variable.See Storing control names on page 629.

n The value flag sets the initial value of the check box.

ShowWindow command

showWindow;;

This command enables the last created window’s visibility. For moreinformation, see Creating a window on page 624.

NOTE In the script above, you do not explicitly declare your variables. This isbecause the return type of user interface creation commands is known to be astring, and cannot be any other data type. Later in the lesson, you will allow adata type to be implied, as you do not know what data type the return will be.

Loading a script file | 635

Page 650: Autodesk Maya 2009

Linking the user interface

Currently the user interface in the window doesn’t do anything: moving thesliders and clicking the check boxes has no effect. In this section you learnhow to link the user interface to the makeRoll procedure you used earlier:

n The textField in the user interface will display the currently selectedobject.

n The check boxes in the window will be linked so that only one check boxcan be selected at once.

n The button will execute the makeRoll procedure with the argumentsspecified in the window.

In the following steps you modify the user interface script.

A completed version of the user interface script named Mel_UI_Final.mel isavailable in the GettingStarted project directory, within the mel sub-directory.

Displaying the currently selected object

The makeRoll procedure does not act upon the currently selected object. Youwill modify the script so that the textField control will display the name ofthe currently selected object.

To return the name of the currently selected object, use the ls command (list)with the selection. Since you can select multiple objects in Maya, the returnfrom the ls command is not a string, it is a string array, even if only oneobject is selected. An array is an ordered list of values used to store multipleitems of the same data type within one variable. The makeRoll procedurecannot accept a string array as an argument, so you must modify the datareturned by ls -­selection.

NOTE For more information on the ls command, see ls in the MEL CommandReference.

For more information on arrays, see Arrays in the MEL and Expressions guide.

In this next section, we’ll also create a new tempMEL tab so you’ll have a placeto test commands as you learn them.

636 | Chapter 13 Scripting in Maya

Page 651: Autodesk Maya 2009

To store the names of the currently selected objects as a variable

1 Create a new MEL tab (Command > New Tab in the Script Editor).

2 Rename it tempMEL (Command > Rename Tab in the Script Editor)

3 Type the following in the tempMEL tab:select -­allDagObjects;;

This command selects all scene objects.

4 Type the following in the tempMEL tab:$all_selected_objects =`ls -­selection`;;

This command lists currently-selected objects and outputs their namesto a variable.

5 Type the following in the tempMEL tab:print $all_selected_objects;;

This command outputs the list of stored objects to the Script Editor.

6 Execute the commands in the tempMEL tab.

The following is output to the Script Editor:

roll_Cube pPlane1

The variable $all_selected_objects is an array of strings. That is, it storesmultiple strings within the variable. Values in an array are called elements.

NOTE Arrays are used frequently in programming to manage large sets of data.If arrays were not used to store large sets of data, you would need to create avariable for each element of data, making scripts hard to maintain and taking uplots of memory. For more information on arrays, see Arrays in the MEL andExpressions guide.

Reduce your selection by extracting a single value from an array using an arrayindex.

To reduce the selection to one object

1 In the tempMEL tab, type the following:$first_selected_object=$all_selected_objects[0];;select $first_selected_object;;

The first element of the array, the roll_Cube, is selected.

Linking the user interface | 637

Page 652: Autodesk Maya 2009

Elements of an array are accessed using square brackets containing theindex number of the element you want to extract from the array. Theindex number of arrays start counting from zero.

2 Add the following commands to the top of your user interface script inthe MEL2 tab:$all_selected_objects=`ls -­selection`;;$first_selected_object=$all_selected_objects[0];;select $first_selected_object;;

These commands change your selection to the object you selected first.

3 In the MEL2 tab, change the argument of the text flag located on line14 of the original script (you can use the MEL tab for reference) fromname_of_object to the following:

$first_selected_object

The command now reads:

$obj_name_text = `textField -­editable 0 -­width 400 -­text$first_selected_object`;;

The text field now displays the currently selected object.

If you attempt to execute the modified user interface creation scriptwithout an object selected, an error occurs, as no elements exist in thestring array $all_selected_objects.

TIP Don’t execute the script from the MEL2 tab yet, as it will clear the taband we want to continue modifying the script. If you do want to execute thescript at any interim time, create a new MEL tab, copy the script into it, andexecute that.

Linking the check boxes

Check boxes can also use command flags, similar to a button. A check boxhas more functionality than a button, so the command flags are different.Check boxes have three possible command flags; changeCommand, onCommand,and offCommand:

n The changeCommand flag triggers whenever the state of the check boxchanges.

n The onCommand flag triggers when the check box is checked.

n The offCommand flag triggers when the check box is unchecked.

638 | Chapter 13 Scripting in Maya

Page 653: Autodesk Maya 2009

You can use the checkBox command with an edit flag to change the state ofa check box in the user interface.

To change the values of elements in the user interface

1 In the tempMEL tab, change the state of the make roll window’s checkbox by executing the following:checkBox -­edit -­value 0 $box_sim_checkbox;;

The Box Simulation check box, which was turned on, is now turned off.You can repeat this command with a value of 1 to turn the check boxback on.

This shows the use of the edit flag with a command as an argument toa command flag, which allows you to change values.

We’ll now use the onCommand and offCommand flags to keep the two checkboxes in sync, so that when one check box has its state changed, theother check box is set to the opposite state.

2 Replace the existing check box commands ($box_sim_checkbox and$sphere_sim_checkbox) in the MEL2 tab. This will be approximately lines38-46 depending on whether you added lines at the beginning of the file.Replace these two commands with the following:$box_sim_checkbox = `checkBox -­value 1 -­label "Box Simulation"-­onCommand "checkBox -­edit -­value 0 $sphere_sim_checkbox;;" -­

offCommand "checkBox -­edit -­value 1 $sphere_sim_checkbox;;"`;;$sphere_sim_checkbox = `checkBox -­value 0 -­label "Sphere Simulation" -­onCommand "checkBox -­edit -­value 0 $box_sim_checkbox;;"-­offCommand "checkBox -­edit -­value 1 $box_sim_checkbox;;"`;;

The commands you are replacing are located on lines 35-43 of the originalscript file.

Linking the user interface | 639

Page 654: Autodesk Maya 2009

Executing the procedure

The makeRoll procedure requires arguments to execute. To link it to thewindow, you must get the values for the arguments from the controls in theuser interface, and execute the makeRoll procedure with these arguments.

To get the values of the controls, you must use the query flag. The query flagallows commands to return values of attributes in the scene.

To query a value in the user interface

1 Change the value of the diameter slider to 10.01 by dragging the sliderto the right, or by typing a value in the diameter slider’s text field.

2 Print the value of the diameter slider by typing the following in thetempMEL tab:print ("The diameter is: " + `floatSliderGrp -­query -­value$diameter_float`);;

The following is output to the Script Editor

The diameter is: 10.01

The query flag allows you to output a value to the Script Editor.

Change the command flag of the button so that it calls makeRoll commandwith arguments values that are the same as the specified values in the userinterface.

To link the button to the makeRoll procedure

1 Replace the command flag of the execution button block in the MEL2tab (approximately line 57) with the following:-­command "makeRoll \ `textField -­query -­text $obj_name_text` \`intSliderGrp -­query -­value $ground_int` \ `checkBox -­query -­value $box_sim_checkbox` \ `floatSliderGrp -­query -­value $diameter_float`;;"`;;

640 | Chapter 13 Scripting in Maya

Page 655: Autodesk Maya 2009

Every argument of the user interface is defined by querying the userinterface elements. The backslash at the end of a line allows the commandflag argument to span multiple lines.

Your user interface is now fully functional!

A completed version of the user interface script named Mel_UI_Final.mel isavailable in the GettingStarted project directory (GettingStarted/mel).

Saving the script

To use your script in other scenes, you must save it. To execute the MELcommands in a script file without having to open it every time you want touse it, you must use global procedures.

Once you’ve saved a MEL script file that contains a global procedure in thedefault script folder of Maya, you can access it whenever you type MELcommands. Other procedures in the script file can only be called by the globalprocedure(s) defined in the script file or other local procedures.

Maya automatically sources procedures in its default scripts folders at startup. A script in the default Maya script folder has the same name as a globalprocedure defined in the script file, when you type the name of the script file,the global procedure within the script file will be executed. This allows youto create scripts that operate similar to built-in Maya commands.

1 Type the following at the top of MEL2:global proc makeRoll_create_UI()

2 At the bottom of MEL2, type the following:

Your entire user interface script should be between the curly braces.

3 Highlight the entire script by selecting Edit > Select All from the ScriptEditor menu bar.

4 With the script highlighted, save the script by selecting File > Save Scriptfrom the Script Editor.

The Script Editor only saves the highlighted commands when saving ascript.

5 Save the script as makeRoll_create_UI.mel in the GettingStarted/melfolder.

Saving the script | 641

Page 656: Autodesk Maya 2009

NOTE When saving a script, you must have the .mel extension appendedto the script file name in the Save Script dialogue box.

Using the saved script file

You can apply the makeRoll procedure to any geometry quickly by selectingthe object to apply makeRoll to, and executing the makeRoll_create_UI globalprocedure. Before using a script in your scene, you must source it. Sourcingexecutes all the commands within a script file.

You can only access global procedures declared in the script file from the ScriptEditor. Any local procedures cannot be accessed from the Script Editor, andmust be called from global procedure within the script file.

NOTE Global procedures only have access to local procedures declared beforethem in a script file.

To source and use a script file

1 Select File > Source Script

2 In the Source Script dialogue box that opens, selectmakeRoll_create_UI.mel

3 Create geometry to test the makeRoll procedure on by creating a newscene and typing the following:polyPyramid;;

4 Execute the makeRoll_create_UI global procedure to create the userinterface by typing the following in the Script Editor:makeRoll_create_UI;;

The user interface you created opens.

642 | Chapter 13 Scripting in Maya

Page 657: Autodesk Maya 2009

5 Set the frame to greater than one to view the effects of the makeRollprocedure.

6 Set the following values in the makeRoll user interface:

n Ground Plane = 0

n Diameter = 1.0

n Box Simulation = checked

n Sphere Simulation = unchecked

7 Click the “Execute” button to setup the makeRoll expressions.

8 Move the pyramid in X and Z to view the results of the makeRollprocedure.

Explore different results that occur when you apply the makeRoll procedurewith different user interface control values. Since you cannot undo themakeRoll procedure, you will have to create new geometry every time to applythe makeRoll procedure.

When you open a new Maya session, the makeRoll user interface procedureis no longer defined and must be sourced to use it.

Beyond the lesson

In this lesson, you learned how to create a user interface from an existing MELprocedure. You can:

n Create a window

n Create user interface controls in a window

n Use conditional statements to check the existence of a window

n Use a built-in Maya procedure

n Modify a user interface to add functionality

n Access elements of an array

n Query and edit user interface values

n Save and source a script

Beyond the lesson | 643

Page 658: Autodesk Maya 2009

You can create fully customized user interfaces with MEL scripting. There areadditional user interface elements not covered in this lesson.

For a full list of user interface elements, look in the MEL Command Reference.You can open the MEL command reference by selecting Help > MEL CommandReference from the menu bar. User interface commands are in the Windowscategory of the MEL Command Reference.

Lesson 5: Using Python in Maya

Introduction

Python scripting in Maya is very similar to MEL scripting. Python scriptinghas the same access MEL does to Maya functionality with very few limitations(see Current limitations of the Python guide). Python requires a differentsyntax than MEL, so commands in Python can look very different from theirMEL equivalents.

This tutorial is for migrating your MEL scripting experience to a Pythonscripting environment in Maya. This lesson does not teach Python, only howto use Python scripting in Maya. Maya uses Python 2.5 on all supportedplatforms.

Python is a highly readable, easy to maintain, high level programminglanguage. Python is widely used in industry due to its simplicity and standardlibraries.

To learn Python, try a Getting Started tutorial in Python:

http://www.python.org/about/gettingstarted/www.python.org/about/gettingstarted/

In this lesson, you learn how to:

n Enter Python commands in Maya

n Create geometry with Python scripting commands

n Return values from Python commands

n Use flags in Python with the move, scale and rotate commands

n Set the edit and query flags in Python

n Refer to named objects in Python

n Transfer values between Python and MEL

644 | Chapter 13 Scripting in Maya

Page 659: Autodesk Maya 2009

n Call MEL scripts from Python

Entering Python commands

Just like MEL, you can enter Python commands in the Command Line or theScript Editor. The Command Line can only accept single line Pythoncommands, while the Script Editor provides a method to input multiple Pythoncommands and view the results.

The Script Editor displays a running history of executed commands and theresults of commands that Maya executes. You can copy most commands fromthe history section of the Script Editor and paste them in the input section toexecute them. However, the results of Python commands are not echoed tothe Script Editor exactly like MEL.

For more information, see To set up the Script Editor on page 598.

To type a Python command in the Script Editor

1 Select Window > General Editors > Script Editor.

2 Select a Python tab in the Script Editor.

3 Type the following command in the input section of the Script Editorand execute it by pressing Enter on the numeric part of your keyboard,or pressing Ctrl+Enter.import maya.cmds as cmds

You now have access to Maya commands through the maya.cmds module.

NOTE This is how you load modules in Python. For more information aboutother Python modules, see the online Python documentation.

By convention throughout the documentation and the Python commandreference, the maya.cmds module is renamed cmds, but you can renamethe module anything you like.

Entering Python commands | 645

Page 660: Autodesk Maya 2009

In the Script Editor, the Enter (Windows) or Return (Mac OS X) key abovethe Shift key does not execute a command. It starts a new line so you cantype several commands before executing them.

TIP You can import maya.cmds automatically at startup by creating a filecalled userSetup.py in your Maya scripts directory. The userSetup.py filecan contain any Python commands you want to execute at startup.

For more information, see Initializing the Maya Environment in and forPython.

4 Create a polygonal cube by typing the following:cmds.polyCube()

A polygonal cube is created at the origin. This is equivalent to using thepolyCube command in MEL.

The command is removed from the input section of the Script Editorafter execution. The command and the result of the command is outputto the upper section of the Script Editor. The results of Python commandsare displayed in the Script Editor between a set of Python commentingcharacters (#).

You can also enter commands in the Command Line.

Show the Command Line by selecting Display > UI Elements. By default theCommand Line is in MEL script entry mode. You can change the mode byclicking on the text in the lower left hand corner. To enter Python commands,the command line must be in Python mode.

646 | Chapter 13 Scripting in Maya

Page 661: Autodesk Maya 2009

To use a Maya command with positional arguments

1 Move the polygonal cube that you created with the following Pythoncommand:cmds.move(1,2,3)

The polygonal cube moves to the XYZ co-ordinates 1,2,3.

The move command accepts XYZ co-ordinates as its commandsarguments.

2 Scale the polygonal cube with the following command:cmds.scale(2,2,2)

3 Re-scale the polygonal cube with the following command:cmds.scale(3)

Entering Python commands | 647

Page 662: Autodesk Maya 2009

When a command is not provided with enough command arguments,the command uses the default arguments. The polygonal cube X scale isset to three, but the Y and Z scale values are set to their default argumentone.

4 Delete the selected polygonal cube.cmds.delete()

Using flags in Python

Flags are used with commands to modify their execution. Python implementsflags as named arguments. Some flags in MEL do not require values. As allnamed arguments in Python require a value, these flags are given the valueTrue to enable the flag, or False to ignore the flag. When setting multiplenamed arguments, argument-value pairs are separated by commas within thebrackets. Command arguments must appear before named arguments in acommand.

To use flags in Python

1 Create a polygonal cube with the width defined at creation time by typingthe following:cmds.polyCube(width=5)

648 | Chapter 13 Scripting in Maya

Page 663: Autodesk Maya 2009

The width flag allows you to set the width of a cube at creation time.

2 Create a polygonal sphere with the radius and subdivisions in X andname defined at creation time.cmds.polySphere(radius=1, subdivisionsX=4, name="testSphere")

You can use multiple flags to modify the execution of a command byseparating the flag-value pairs with a comma. The radius flag sets theradius of the created sphere. The subdivisionsX flag sets the number ofsubdivisions in X for the sphere.

NOTE A list of flags available for a command can be output to the Scripteditor by typing cmds.help("command"). For example: cmds.help("sphere")

To use flags with command arguments in Python

1 Move the polygonal sphere by typing the following in the Script Editor:cmds.move(2,2,2)

2 Select the polygonal cube.

3 Move the polygonal cube by typing the following:cmds.move(1,2,3)

Using flags in Python | 649

Page 664: Autodesk Maya 2009

4 Move the polygonal cube relative to its current position by typing thefollowing:cmds.move(-­1,0,-­2,relative=True)

The polygonal cube moves relative to its current position. The relativeflag must be placed after the command arguments, as in Python, whenpassing arguments, named arguments must appear after positionalarguments. The command arguments must always be the first argumentsof the command.

5 Move the polygonal sphere without selecting it by typing the following:cmds.move(3,2,1,"testSphere",relative=True)

The name of the object must be passed as a string after the commandarguments, but before the flags.

650 | Chapter 13 Scripting in Maya

Page 665: Autodesk Maya 2009

To use flags with multiple arguments in Python

1 Create a yellow tinted point light by typing the following:cmds.pointLight(rgb=(1,1,0.5))

The point light command creates a point light at the origin. The rgb flagspecifies the color of the light. The rgb flag require three values; red,green and blue.

When flags require multiple values, the values must be packed withinPython’s tuple or list data types. Tuples are a method of storing multipleitems of homogenous data within a single variable, similar to an arrayin MEL. The list is similar to the tuple, but supports multiple data typeswithin a single variable. The above command packs the RGB values intoa tuple. You could also use a list to achieve a similar effect.

2 Move the currently selected light by typing the following:cmds.move(12,15,12)

3 Create a blue tinted light by typing the following:cmds.pointLight(rgb=[0.2,0.2,1])

Square brackets [ ] indicate lists, and parentheses ( ) indicate tuples.

The values for the rgb flag can be packed into either a list or a tuple andperform the identical operation.

4 Move the currently selected light by typing the following:cmds.move(12,15,-­5)

5 Select the polygonal cube and polygonal sphere by clicking the polygonalcube, then shift clicking the sphere.

6 Frame the selected objects by pressing the f hotkey on your keyboard.

7 Render the scene by pressing the render current frame button onthe Status line.

The Render View opens and displays the following image.

Using flags in Python | 651

Page 666: Autodesk Maya 2009

8 Select all objects in the scene and delete them by typing the followingcmds.select(allDagObjects=True)cmds.delete()

Using the Maya command select with the allDagObjects flag selectsobjects that exist physically in the scene such as geometry, IK chains andmeasure tools. These appear on an internal Maya representation calledthe DAG. For more information, see DAG.

Using the edit flag in Python

When you perform an action on an object in the Maya user interface, you’reusing Maya commands to change the attributes of selected objects. You canuse the same Maya commands explicitly to edit the attributes of objects inthe scene.

Some Maya commands take an edit flag that allows you to make changes tothe attributes of an object. The edit flag is used in conjuction with other flagsto specify which attributes to change.

To edit the attributes of an existing object

1 Create a NURBS torus by typing the following:testVarName=cmds.torus(r=1, axis=(0,1,0) )

652 | Chapter 13 Scripting in Maya

Page 667: Autodesk Maya 2009

The axis flag specifies the initial orientation of the torus. Geometrycreation commands return the name of the created object, so you caneasily refer to the object by storing the name of the object as a variable.

NOTE Most creation commands return the name of the created object as areturn value. This value can be stored as a variable to refer to the object at alater time. This is especially useful when referring to controls within a userinterface.

2 Deselect the torus using a Python command.cmds.select(deselect=True)

3 Edit the height ratio of the named torus by typing the following:cmds.torus(testVarName,edit=True, hr=0.4)

When the edit flag is set to True, the command is put in edit mode. Whenin edit mode, all flags within the brackets of the command now changethe attributes of the specified object.

NOTE The edit flag does not need to be the first flag in a command. It is anamed argument and can be positioned anywhere within the command afterthe positional arguments.

Using the edit flag in Python | 653

Page 668: Autodesk Maya 2009

Communicating between Python and MEL

MEL and Python in Maya each have built in commands to communicate witheach other. MEL and Python communicate by calling commands in the otherlanguage and evaluating the results of the last executed command.

Python communicates with MEL using the eval() command. Unlike the otherPython commands in this lesson, the eval() function does not belong to theMaya commands module (maya.cmds). The eval() function belongs to themaya.mel module. The eval() function can call MEL scripts or execute MELcommands by sending the commands as a string. Multiple MEL commandscan be called in the string by separating the commands with semi-colons. ThePython eval() function returns the results of the last executed MEL script orcommand within the eval brackets.

MEL communicates with Python using the python command. The pythoncommand accepts a string as its only argument. The string is sent to Pythonto be evaluated, and the result is returned to MEL. As Python has a moredescriptive type system, some results from Python commands returned toMEL have their data type modified. For more information on type conversion,see MEL/Python communication of the Python guide.

To call MEL commands from Python

1 Select a Python tab in the Script Editor

2 Import the MEL moduleimport maya.mel

The maya.mel module is a module for evaluating MEL expressions inPython.

3 Call a MEL command by typing the following:maya.mel.eval("sphere -­radius 3;;")

A sphere of radius three is created at the origin, just as if you had usedthe Python command.

4 Select a MEL Tab in the Script Editor

5 Declare a variable in the MEL tab by typing the following:global float $MyMELVariable=22.7;;

Only global MEL procedures, variables and scripts are accessible fromwithin Python.

654 | Chapter 13 Scripting in Maya

Page 669: Autodesk Maya 2009

6 Select a Python tab.

7 Transfer the MEL variable’s value to Python by typing the following:TransferMELvar = maya.mel.eval("$temp=$MyMELVariable")

When transferring variables between MEL and Python, the functionsreturn the value of the statement. MEL syntax does not allow you toreturn the value of a variable by using the variable as a command string.In MEL, when a variable is assigned a value, the value is returned to theScript Editor. Within the eval() statement, you assign the value of theglobal MEL variable to a temporary variable.

8 Output the value of the transferred MEL variable using Python commands:print TransferMELvar;;

To call Python commands from MEL

1 Select a MEL tab in the Script Editor.

Commands typed in the MEL tab are executed in MEL.

2 Call a Python command by typing the following:python "cmds.sphere()";;

A sphere is created at the origin, just as if you had typed the commandin the Python tab.

3 Select a Python Tab in the Script Editor

4 Declare a variable in the Python tab by typing the following:MyPythonVariable=22.7

5 Select a MEL tab in the Script Editor.

6 Transfer the Python variable’s value to MEL by typing the following:float $TransferVarPy = `python "MyPythonVariable"`;;

Evaluation back quotes are used in MEL to use the return value of acommand in assignment, when the return value is normally returned tothe Script Editor history window.

7 Output the value of the transferred variable in MEL:print $TransferVarPy;;

Communicating between Python and MEL | 655

Page 670: Autodesk Maya 2009

TIP Transferring values between Python and Maya can also be accomplishedby using invisible user interface elements. You can edit and query the contentsof user interface elements with both scripting languages.

Beyond the lesson

In this lesson, you learned how to access Maya’s functionality through Pythonscripting commands. You can:

n Type basic Python commands in the Script Editor to access MayaCommands.

n Use named arguments as flags at object creation time to specify theattributes for the objects.

n Use commands that require multiple arguments by packing the argumentsin a tuple or list.

n Edit the attributes of objects using a command with the edit flag.

n Execute Python commands from the MEL interpreter and execute MELcommands from the Python interpreter.

n Transfer values between Python and MEL.

The MEL tutorials introduce some other uses for scripting in Maya. You canfollow through with the MEL tutorials by using the Python CommandReference to translate MEL commands to their Python equivalents.

Python can also be used to write scripted plug-ins. For more information, seeIntroduction to Maya Python API in the API guide.

656 | Chapter 13 Scripting in Maya

Page 671: Autodesk Maya 2009

Index

in expressions 581% in expressions 588

3D Paint Tool 550

A

Accuracy 471active rigid body 498Add Attribute button 586Add Attributes 488

for Current Render Type 487Add Dynamic Attributes 488, 585Add Influence 328Add Keys Tool 198Add Per Particle Attribute 488, 586age, particles 489Along Axis 480Alpha Gain 80animation

curves 192planning, storyboarding 294

Animation Preferences 188Annotation

creating 279description 279

anti-aliasing 397, 454Append to Polygon Tool 108arms

joint chain 310Around Axis 480, 483array

description 488Artisan Erase 552Assign Edit Textures button 550Assign New Material 406Assign Textures button 558–559assigning a texture map 352Attribute Editor

attribute tabs 66description 66

viewing 66Attribute to Paint 550, 558attributes

controlling multiple 571description 37displayed in Attributes list 568linking 572shading 69

audio clips 261Autodesk

technical support 11Web site 11

Automatic Mapping 362applications 362triplanar projection 362

Away From Axis 480, 483axis indicator 19

B

base objectinfluence object 328

base shapeblend shape 345

birth, particles 489blend modes 551blend shape deformer 338

adding shape to 343editor 339improving deformations 345

blending animation types 217Blinn shading material 379, 381

description 68Blur, 3D Paint 557bones 305Boolean operations 132border edges 86Bounding Box 200braces, in statements 581brackets, double angle 586

657 | Index

Page 672: Autodesk Maya 2009

Break TangentsGraph Editor 194

Bridge 105Browse button 554, 560brush profile 555brushes

3D Paint, Paint Effects 555description 518Kelp 534Mesh 538Teapot 539Thin Line 548

bump, painting 558

C

cameraapplications 435create 435

Camera Attribute Editor 390camera tools

Dolly Tool 44overview 43Track Tool 46Tumble Tool 45

camerasanimating 437, 439Film Gate 439undoing changes 438

CanvasClear 509Set Size 508

Canvas Clear 506Caustic Photons 471Caustics

Caustic Photons 467description 458Emit Photons 466light sources 473Photon Intensity 466photon maps 466photons 466

Channel Box 24blend attributes 219, 221description 37hiding, showing 24

locking channels 284naming and renaming objects 38transforming and rotating

objects 38translation, rotation, scaling 24

character set 232character setup

description 303Circle 158clear canvas 506clip cycle

description 248clip library 256clip manipulator 244clips

applications 228audio 261blending 260components 231creating 230, 233cycling 248description 225, 228duration 232importing 239inserting 256keyframing 261name 232Outliner 261regular clips 230renaming 234repositioning 236reusing 239scale 232scaling 243source 230, 239Visor 261

cloth texture 384–385cluster deformer 332cluster handle 334cluster weights 335Collapse 280collapse hierarchy 280collisions, rigid bodies 494color

Christmas light effect withparticles 588

658 | Index

Page 673: Autodesk Maya 2009

giving object constant color 586giving particles randomly changing

color 586particles 488ramp 489

Color 551color bleeding 454Color Chooser 69, 392Combine 105components

description 63conditional statements

if 576Conserve attribute 485constraints 494

description 277orient 282parent 291point 280rigid bodies 494

construction history 120, 140, 165control object (IK) 276control vertices (CVs) 138

description 64converting a UV selection 370Crease Proxy Edge Tool 130creasing

subdivision surface 181Create

Expression Editor 568Create Blend Shape 338Create Clip

options 247, 249Create Cluster 334Create Constraint 497Create Polygon Tool 98Create Ramp 489creation expressions 586

assigning to rgbPP 586cube primitive 21, 80

options 47curve

direction 139edit revolved 140start 139

cuttingsubdivision surface 176

CV Curve Tool 138cycling a clip 248

D

Delete by Type 121Delete Keys 318detail

subdivision surface 177Dim Image 363directional light

create 425description 425editing attributes 426

displaycreased edges 131only selected object 341Poly Count 132soft and hard edges 127template 61

Display Image 365, 370Display Level 178Display Resolution 390Display Unfiltered 373Dolly Tool 44

description 44double angle brackets 586Draft rendering setting

description 444driven keys

description 201Duplicate Tool 160

description 39, 56options 39, 49

Duration 232dynamic attributes

adding 486, 584dynamics

definition 475

E

edge loop 87description 87

Index | 659

Page 674: Autodesk Maya 2009

termination 118edges

border 86creasing 126hardening 126selecting subdivision surface 179

Edit buttonexpressions 571

Edit Deformers > Blend Shape > Add 343Edit Ramp 493elbow

influence object 327electronic tablet

sculpting surfaces 150else keyword

expressions 580Emit from Object 478emitters 476

creating 477Omni 478

End Bounds 523End Time 188equal to (==) operator 589errors

syntax 578Essential Skills Movies 5

closing the movie window 6playing 6

exiting Maya 27Expression Editor 568expressions

advantage of separate 572advantage of single 572creating 568description 565editing 570execution details 573naming conventions 568

Extrude 100extrusion manipulator

subdivision surfaces 175

F

face selection mode 85

facessplitting 110

facial animation 330FCheck 401, 493fields 476, 493file saving 27fingernails 179fingers 171Flipbooks 493Flood

Sculpt Geometry Tool 147Flood All 553Forward Kinematics (FK) 262, 314, 318Four Panes 138Frame In 231Frame Out 231Frame Selection

Graph Editor 192frames per second setting 378Freeze Transformations

description 278Full Crease Edge/Vertex 181

G

Get Brush icon 555Getting Started with Maya

about the lessons 2before you begin 3introduction 1lesson conventions 4using lesson files 5using tutorials online 3

Global Illum Photons 448, 453Global Illumination

Accuracy 452color bleeding 454description 440light sources 456photon maps 447photons 447Radius 452rendering process 447, 449

Go to Bind Pose 327Graph Editor 191

path animation 213

660 | Index

Page 675: Autodesk Maya 2009

Set Driven Key 205tangent modification 214

Gravity 498, 524ground plane 519group nodes

animating 200Group Under 332grouping objects

description 52Growth attributes 545

H

Harden Edge 128hardware render 491Hardware Render Buffer 491Hardware renderer

description 389Help

Find Menu 10launching 7

Help resources 5Hide Selection 165hierarchy

about 264collapse 280, 290description 52grouping 52skeleton 305viewing in hypergraph 265

Hinge constraint 497hole

creating subdivision surface 176Hotkeys

brush scale 534description 55setting 55

Hypergraph 53character setup 307description 53overview 54viewing 53viewing hierarchies 54

HypershadeCreate Textures 416description 413

rename operation 416

I

if statementsexpressions 575

if-else statementsexpressions 580

IK handles 314control object 276creating 274creating and animating 315description 274parenting 286

IK Rotate Plane handle 317IK Solvers

Enable and Disable 326ikSCsolver 275

image planedescription 77importing 78transparency 79

image size 444, 454, 463Import Clip 239Incandescence1 557Influence list

Paint Skin Weights Tool 323influence object

smooth skin 326initial orientation

hinge constraint 497Insert Edge Loop Tool 106, 114Insert Isoparms 154Inverse Kinematics (IK)

description 262, 314limiting motion 284translation limits 290

IPR 559description 389region to be updated 392

IPR Render Current Frame 391Isolate Select 341isoparms 143

Index | 661

Page 676: Autodesk Maya 2009

J

jawjoint 309

joint chains 305Joint Size 306, 321Joint Tool 306joints 305

influence on skin 321moving 311

K

Keep Aspect Ratio 550Keep Hard Edge 129Keep Image 446, 464keyframes (keys)

adding 198deleting 197description 186setting 189

keying into a clip 261keys

delete redundant 198Key Selected 300moving 193setting 298

L

Lambert shading material 379–380layouts

changing panel layout 32four view layout 39shortcuts 32

Leaf Width Scale attributes 544Leaves attributes 545legs

joint chains 305level of detail

subdivision surface 177lifespan attribute 489lights

applications 424attributes 430directional 526

dropoff 431intensity 527penumbra 431spotlight 427, 445

Line Smoothing 492Line Width 487Linear

Graph Editor tangents 194linking attributes 572Load Driver

Set Driven Key 203Load Selected Characters 231Loft Tool 158, 162Look Through Selected 429

M

Magnitude 481main menu 20Make Paintable 534Map Visualizer 456, 473mapping UVs 361

applications 361marking menu 64masks and modes, selection

description 57material

assigning 406Blinn 379default shading 68description 379, 406Lambert 379surface 68

Max Displacement 148Max Influences 321Max Photon Depth 469Maya

about 1installing 4launching 15user interface 15–16using Maya Help 7

Maya Hardware rendererdescription 389

Maya Helpindex 7

662 | Index

Page 677: Autodesk Maya 2009

popup help 8Tutorials 3using 7using Help index 7using Help Line 10using Search 8

Maya Software rendererdescription 388

Maya Unlimited 2Maya Vector renderer

description 389mental ray for Maya renderer 376, 462

description 389menu sets 20

description 20Polygons 74selection 20

Mesh brushesapplications 538attributes 543description 538

meteors 486Mirror Across 308Mirror Geometry 122modeling

description 73polygons 74shaded mode 83symmetry 84types 73

modules 20modulus operator (%) 588morphing facial expressions 339motion

speeding up with Graph Editor 195motion capture data

creating clips from 246description 245extending the length of 248redirecting 252

Motion PathAttach to Motion Path 208

motion path animationdescription 206

movekey points 193

objects 35UVs 370

Move and Sew UVs 368Move Snap Settings 87Move Tool 35, 88

N (normal) manipulator 96, 180X, Y, Z manipulator 35

mute track 243, 256

N

neckjoints 309

new scene 30nodes

description 37initialShadingGroup 67input 67parent 54pivot point 58renaming 55root 54shape 67transform 67

non-proportional scaling 51nonlinear animation

description 225normals

surface 146Normals

Harden Edge 128Soften Edge 127

Number of Sections 143Circle 158

Number of Spans 143NURBS

applications 135creating NURBS curves 138editing tools 165Loft Tool 158sculpting NURBS surfaces 142Smoothness 144

O

object selection 34, 123

Index | 663

Page 678: Autodesk Maya 2009

offset 280Opacity 551

Paint Cluster Weights Tool 336Sculpt Geometry Tool 149

operatorsassigning values to 589equal to 589less than 577

order of statements 578orient constraint

creating 283description 282

origin 18orthographic view 43Outliner 230, 234, 261

description 140, 164parenting objects 164placing clips from 240

Output window 396

P

paint brushesblending 512

Paint Effects3D objects 529, 533applications 547Brush Settings window 557brushes, 3D Paint 555making surfaces paintable 534panel 527

Paint Effects to Polygons 541Paint Selection Tool 85, 333Paint Skin Weights Tool 323Paint Weight Menu 324painting

2D strokes 5043D strokes 5163D strokes in scene view 519bump 558interactively 558pressure sensitivity 516strokes 518UV preparation 561

pairBlend attribute 222panel 18

panel layout 448, 461parent constraint

description 291weighting 294

parent node 54parenting

description 271particle attributes, per object and per

particle 488particle object 478particles

applications 475changing form of 485description 476render type 485streaks 486

path animationblending 217description 206position marker 212Twist attribute 216UValue 210

per object attributes 488Per Particle (Array) Attributes 586per particle attributes 488

how to distinguish 488perspective view 43Photon Intensity 448, 451, 469photon maps 466, 473

description 447visualizing 456

Photon Refractions 469photons

Accuracy 471Caustic Photons 471description 447Emit Photons 448Global Illum Photons 448Max Photon Depth 469Photon Intensity 448, 451, 469photon maps 473Photon Refractions 469Radius 471

pivot pointdescription 58

664 | Index

Page 679: Autodesk Maya 2009

playbackanimation 299controls 188quickening 199speed 188

Playblast 191, 199description 223

point constraintdescription 280

polesurface 148

Pole Vector Constraint 317Pole Vector XY Z 317polygon count 132Polygon Proxy Mode 171polygonal cylinder

creating 31options 31

polygonscomponent types 74display settings 76extruding 100four-sided quads 81selection settings 76smoothing 81, 124

Polygons to Subdiv 170preferences

modeling 76primitives

applications 29–30creating 21, 80interactive creation 77modifying 162NURBS sphere 50NURBS torus 62plane 530polygonal cube 47, 80polygonal cylinder 31, 48types 30, 157

procedural textures 380description 383

process 375projection mapping UVs 361PSD file format 354

Q

quads 81Quaternion rotation 222

R

Radius 471, 551Circle 158Sphere 143

Radius(L) 150Radius(U) 146

Paint Cluster Weights Tool 336Paint Skin Weights Tool 325

rain 486ramps 489, 493Range Slider 188raytracing 442Redirect Tool 252

creating redirect control 252keyframing control 254positioning control 253

Refine Selected Components 180, 182Reflection

Sculpt Geometry Tool 151Reflection X 552refractions

Max Trace Depth 468photon refraction 468refraction levels 468

renaming clips 234Render Current Frame 525Render Sequence 492Render Settings 397, 443render types, setting for particles 485Render View 389, 462, 559

Keep Image 446, 464rendering

anti-aliasing 454batch rendering 398, 403compositing layers 403description 375hardware 376, 403image size 444, 454methods 376overview 377

Index | 665

Page 680: Autodesk Maya 2009

panel layout 448, 461raytracing 442render settings 443sampling 455shading surfaces 405shadows 445software 376, 388view region to be rendered 390

rendering particles 493Replace

Paint Cluster Weights Tool 336Retain component spacing 87return to start time 188reusing clips 239Revolve Tool 137

creating surfaces 139editing surfaces 140

rewind 188rgbPP attribute 488

use in expressions 586ribs

joints 311–312ridges

subdivision surface 181rigid bodies 494

active 498applications 475collisions 494constraints 494passive 498

rigid skinning 329root

skeleton 313root node 54Rotate Tool

description 36X, Y, Z manipulator 36X, Y, Z, manipulator 92

Rotate UVs 371rotating objects

options 51rotInterpolation 222runtime expressions 587

assigning rgbPP in 587

S

sampling 455Save As 549Save Scene 27saving files 27, 40, 60scale

non-proportional 51Scale

Paint Skin Weights Tool 325scale, multiplying by percentage 582scaling clips 243scene painting view 527scene view vs Render View 389scrub 189Sculpt Geometry Tool 142, 145

basic techniques 145preparing surfaces 143sculpting terrain 532

Section Radius 483selection

border edges 91Convert Selection 99faces 85hierarchy 58hierarchy, object, component 57masks and modes 22, 57mode 22objects 24, 34, 123Paint Selection Tool 85polygon components 89Select Border Edge Tool 92UVs 365–366vertices 89

semicolon terminatorexpressions 568

Set Driven Key 202Graph Editor 205

Set Initial Position 497Set Key 189Set Preferred Angle 315sewing UVs 367shaded mode 51, 83, 541shading material

assigning 68Blinn 68

666 | Index

Page 681: Autodesk Maya 2009

shading networksdescription 383

shading surfaces 405shadows 445, 462

description 433Shelf 22

preset brushes 518saving preset brushes 512

Show Region Marquee 393Show/Hide Editor 22Size X, Size Y 550, 559skeletons 304

creating 268hierarchy 267moving group node 317parenting models 271posing and animating 315root 313

skin 319skin weights 321, 323

modify 324Smear 557Smear, 3D Paint 557Smooth

Paint Skin Weights Tool 325Smooth Bind 321Smooth Shade All 83, 379smooth skin 321

influence object 326unnatural deformation 322

smoothing polygons 81, 124Snap Mode 22

Snap to Grid 87Snap to Points 159

Soft Modification Tool 133Soften Edge 127Software renderer

description 388software rendering 388solo track 242source clip 230Source In 232Source Out 232spans, displaying 144sphere primitive 50

options 64

sphrand function, use with randomcolor 587

spinal columnjoint chain 309

spineparenting arms and legs 313

Split Polygon Tool 110spotlight

aiming 428Cone Angle 431description 427

Stamp Spacing 555Standard Mode 177starting Maya 15statements

expression order 578static channels

remove 198Status Line 20–21

expanding and collapsing items 22Streak render type 486stroke

attributes 521attributes, Global Scale 523attributes, Gravity 524attributes,Turbulence 535description 518Stroke Refresh 528

strokesdeleting 536polygon conversion 541rendering 525, 537, 540tubes 520

Stylus Pressure 150, 516, 551Subdiv Proxy

Crease Proxy Edge Tool 130description 124toggle display 126using 125

subdivision surfacesconverting polygons 169cutting 176Extrude Face 173extrusion manipulator 175selecting faces 173selecting vertices 175

Index | 667

Page 682: Autodesk Maya 2009

Split Polygon Tool 171summary track

description 241surface

material 68normals 146pole 148

symmetry 84syntax, errors 578

T

Tail Fade 487Tail Size 487Tangent

Graph Editor 200handles in Graph Editor 194

targetblend shape 338

template brushdescription 506, 519modifying settings 507resizing 507

template display 61, 305applications 61description 61untemplating objects 66

Test Render 491texture map

applications 347assigning 352description 347procedural 380UVs 349

texturescloth 384–385interactive 3D placement 419procedural 383

The Art of Maya 3ticks

red key 189time

expressions 575predefined variable 568value at different frames 568

Time option 378

Time Slider 188time warps 261Toggle Texture Borders 369

applications 369Tool Settings 549Toolbox 32

transformation tools 34, 87torus

options 62track 231

description 231muting 243soloing 242view area 232

Track Tool 46description 46

transform nodesnot used for particle expressions 586

transparency, skin 322Trax Editor

character sets 232clip library 256clip manipulator 244cycling a clip 250Graph Anim Curves 238Load Selected Characters 231motion capture data 245mute track 243Offset attribute 251panel layout 227repositioning clips 236scaling clips 243solo track 242summary track 241time warps 261Toolbar 233track 231

triplanar projection 362tubes

attributes 544Creation 539editing attributes 510Flower 539Leaves 539

Tumble Tooldescription 45

668 | Index

Page 683: Autodesk Maya 2009

Turbulenceoptions 535

Twist 317Twist attribute 216Two Panes Stacked 559

U

UI Elements 549undo 37, 532Update on Stroke 560Use Depth Map Shadows 430, 434user interface 15–16user preferences

restoring 12saving 11

UV Texture Editorapplications 357converting a selection 370description 357Dim Image 363Display Image 365, 370Display Unfiltered 373Move and Sew UVs 368Rotate UVs 371Toggle Texture Borders 369viewing UVs 359

UVsAutomatic Mapping 362description 349image range 359–360mapping 361modifying 365moving 370preparing for painting 561projection mapping 361selecting 365–366sewing 367shells 368viewing 357, 359

V

ValuePaint Cluster Weights Tool 336

Vector rendererdescription 389

velocitycontrolling in particles 485

verticessubdivision surface 175–176

viewing rendered frames 401viewing shaded objects 51views

orthographic 43perspective 43shaded 52wireframe 55

Visor 230, 261description 240placing clips from 240preset brushes 518, 533

volume axis field 479Volume Shape 480

W

Wireframe on Shaded mode 83workspace 17world space coordinates 96

X

X-Ray 83, 322X, Y, Z

axes 19axis indicator 19origin 18

X, Z ground plane 519

Index | 669

Page 684: Autodesk Maya 2009

670