Download as pdf or txt
Download as pdf or txt
You are on page 1of 24

BONUS

Your First Maya Animation


Once you have an overview of how Maya works, from Chapter 1 of the book, you can put
this knowledge to practical use. In this bonus chapter, youll get to try out modeling, keyframing, texturing, and using Mayas built-in dynamics, all in one animation that shows off the power of Mayas interface and renderer. Youll also get a chance to practice the basics of maneuvering around a Maya scene, and youll start to see how adjusting various options can lead to different results. Although we wont deal with theory or do a lot of explaining in this bonus chapter (thats what the book is for!), you should get a good idea about many of the major parts of Maya if you follow along. If you are familiar with other 3D animation packages, going through this tutorial should get you ready to use Maya proficiently. If you are new to the whole world of 3D animation, the animation here will be challenging yet rewarding. Dont get discouraged if things dont turn out perfectly the first time you try. Just remember to save your project often, and under different names, and you can always go back a step or two and try again. But enough talklets do some animating!

Setting the scene: modeling Texturing your models using the Hypershade Lighting the scene Animating the rocket Creating a follow camera Rendering the animation Advanced topic: adding exhaust

Copyright 2004 SYBEX Inc., 1151 Marina Village Parkway, Alameda, CA 94501.

www.sybex.com

2 BONUS CHAPTER: YOUR FIRST MAYA ANIMATION

Setting the Scene: Modeling


In this bonus chapter, were going to build, texture, light, and animate a little rocket ship that takes off, loses power after a couple of seconds, and crashes back to earth. Although this modeling and animation project is a bit simplified, it is definitely a real-world example of what you can do in Maya. Remember that you can return to this project as you progress through the book, refining your work. Given a bit of time and practice, you should be able to get this project looking goodeven if youve never done 3D work before! To give you an idea of what youre working toward, take a look at Figure BC1, which shows a still shot from the completed animation. (To get the full effect, see the rocket.mov movie on this CD. For this project, youll find the complete animation on the CD along with the rocket.ma project file.)

SAVING MAYA PROJECT AND SCENE FILES Your project consists of several folders (or directories) of information about the scene (which is where your scene file is stored), any rendering jobs, source images, output images, textures, and so forth. Whenever you first create a new scene in Maya, there are two steps to saving: first, save your project (which contains all the proper places for Maya to store your projects information), and then save the actual scene file. You might want to browse for your new projects file location. With the New Project window open, click the Browse button next to the Location text field, and use the standard file browser to choose the location of your project. Maya is based on the Unix operating system, which means you must never use spaces in your filenameseven if youre running the Windows version of Maya. If you do, Maya displays an error message when you try to open your scene later, and you wont be able to access your earlier work! The Windows operating system will allow you to save according to its filename conventions, but Mayas file system will have problems recognizing names with spaces. It is a good idea to append a number to the name of every scene (for example, rocket001). Maya does this automatically when you turn on the Incremental Save option. Choose File Save Scene . (The symbol in Maya is known as an option box. More on this a little later.) When the Save Scene Options window opens, click the Incremental Save check box. As you work, you will want to save your scene often, in case you run into any problems. With Incremental Save turned on, each time you save, Maya will create a new file, numbered sequentially (rocket002, rocket003, and so on). If you are concerned about disk space on your hard drive, you can limit the number of incremental saves since new backup files are created each time you save. In the Save Scene Options window, click the Limit Incremental Saves check box. The default limit is 20 increments, which is usually enough to save the last four or five versions, so type 5 in the Number Of Increments box. Once the limit is reached, Maya deletes the oldest incremental file and replaces it with the most recently saved one.

Copyright 2004 SYBEX Inc., 1151 Marina Village Parkway, Alameda, CA 94501.

www.sybex.com

SETTING THE SCENE: MODELING

The first step to almost any animation in Maya is to build your scene elements; therefore, well build the rocket (and ground) as our first step. To build our little ship, well use just a couple of the many modeling techniques Maya has available. 1. First, we need to create a project and save our file in this project so that it has a home. Open Maya by double-clicking its desktop icon. Now, from the File menu, choose File Project New. In the New Project option window, click the Use Defaults button, type a name for your project (something such as rocketProject) in the Name text box, and click Accept to accept these choices. You now have your project saved in your default directory on your hard drive. You also need to save your scene. To do that, choose File Save Scene As, and then choose an appropriate name for the file (such as rocket1). 2. After you save your project and file, change your scene window from the default perspective view to a four view of the scene by first clicking in the scene (large) window and then pressing and releasing the spacebar quickly. (You can also simply LM click the Four View Quick Layout button in the Tool Box.) Your scene window should change to four smaller panes, each labeled for its view (top, side, front, and perspperspective). Select the side view by clicking your mouse inside this pane; then press and release the spacebar quickly again so that the side view fills the entire viewing pane (see Figure BC2). To create the body of the rocket, well use an EP (Edit Point) curve tool to define four points that make up the rockets outline and then revolve this curve into a surface. 3. Select the EP Curve tool (choose Create EP Curve Tool); your cursor should turn into a cross, indicating that youre now using the EP Curve tool. Because we want the first (top) point of the curve to lie directly on the X axis (the thick vertical line at the center of the pane), we need to turn on the Snap To Grids feature before we create the first point on the curve. Click the Snap To Grids button on the Status line (the topmost toolbar).
Figure BC1 The rocket taking off

Copyright 2004 SYBEX Inc., 1151 Marina Village Parkway, Alameda, CA 94501.

www.sybex.com

4 BONUS CHAPTER: YOUR FIRST MAYA ANIMATION

Figure BC2 The side view pane

You can also use a keyboard shortcut to enable grid snapping: hold down the X key on the keyboard while clicking, and each point you click will snap to the nearest grid intersection.

4. A little below the top of the window, where the Y axis meets one of the other grid lines, click once (with your left mouse button) to create your first point. Now turn off the Snap To Grids feature (click it again), and create three more points, approximately like Figure BC3. If you hold down the mouse button when you click to create a point, you can move that point around until you like its positioning; you can also press the backspace key to remove the last point you made. When you are satisfied with the shape of the ship, press the Enter key to save the points (the line will turn green). 5. The next step is to create a surface from our outline. Be sure Modeling is showing on the Status line (at the far left top of the screen). If it is not, choose Modeling from the popup menu there. Now revolve the curve by choosing Surfaces Revolve . Selecting the option box with your mouse opens a window in which you can change the
Figure BC3 An outline of the rocket ship

options of your commandin this case, the Revolve command.

Copyright 2004 SYBEX Inc., 1151 Marina Village Parkway, Alameda, CA 94501.

www.sybex.com

SETTING THE SCENE: MODELING

6. In the Revolve option window, choose Edit Reset Settings and then set the segments to 16 (instead of the default 8). Click the Revolve button. You should now see your curve transformed into a squat rocket ship body! To shade your rocket ship, press the 3 key (on the main keyboard, not the numeric keypad) and the 6 keythe 3 key changes your view to highresolution, while the 6 key turns on smooth shading mode (instead of wireframe). Figure BC4 shows the revolved rocket in high-resolution, smooth shading mode. Most option windows close when you click the item-name button (in this case, Revolve). To keep the window open (to create other objects, for instance), click the Apply button instead of the Revolve (or other) button. 7. Rename your object (shown in the Channel Box, at the right of the main window) from revolvedSurface1 to something more appropriate, such as body: click once on the objects name (revolvedSurface1) at the top of the Channel Box and type your new name, replacing the old one. Press Enter and save your work now. If you dont see the object name listed (and a Channels menu directly above it), click the Show The Channel Box button (above where the Channel Box would be). This should change your view to the Channel Box view. If you still dont see the object name, make sure your object is selected.
If something goes wrong on this or any step in the project, remember that you can always press the Z (undo) key to move back one or more steps in your work.
Figure BC4 The revolved rocket

8. Now we need to build our rocket engine exhaust nozzle. Well create this from a revolved curve that well drag up into the rocket, leaving only its broad base visible. Well use the same method we learned to create the rocket itself: choose the EP Curve tool (or press the Y key, which will reselect the last used tool), and then click several points to form the outline curve (see Figure BC5) that youll revolve into an exhaust nozzle shape. To make the size (scale) of the curve easier to see, try creating the exhaust nozzle directly below the rocket body. 9. When you are satisfied with the look of your curve, press the Enter key and, while the curve is still selected (green), choose Surfaces Revolve to revolve it into a nozzle. (Note that we dont have to use the options this time; this revolve operation will use the same
Figure BC5 The curve for the exhaust cone

Copyright 2004 SYBEX Inc., 1151 Marina Village Parkway, Alameda, CA 94501.

www.sybex.com

6 BONUS CHAPTER: YOUR FIRST MAYA ANIMATION

options you set for the rocket body last time.) Press the 3 key to smooth out the view of the engine nozzle; then rename the object (in the Channel Box) from revolvedSurface2 to nozzle and save your work. 10. We now need to move the nozzle into the base of the rocket. Choose the nozzle (if its not green, click or drag a selection marquee on the nozzlebe sure not to highlight the rocket body or the original curve you used to revolve the nozzle); then press the W key to enter Move mode. You should see several colored arrows (above the nozzle) around a yellow box. Click and drag up on the green arrow until the nozzle is where you want it , as shown in Figure BC6.
Figure BC6 Move the nozzle up to the bottom edge of the rocket.

11. Now lets create a cockpit for our ship from a default sphere. Click the sphere (ball) button on your tool shelf, or choose Create NURBS Primitives Sphere (remember to press the 3 key to display the sphere in hi-res mode). You wont be able to see the sphere, because it is currently inside the rocket body, so change to Move mode (press the W key) and move the sphere to the right of the rocket body. Now change to Scale mode (press the R key) and stretch the sphere up until it is about twice as tall as it is thick. Finally, change back to Move mode (press the W key) and move the sphere into position near the front end of the rocket body (see Figure BC7). Be sure to change the name of the object (in the Channel Box) from nurbsSphere1 to cockpit, and save your work. 12. No 1950s-era space ship would be complete without some fancy fins. Well create one fin using a default cone and then adjust its points to make it look more like a fin. Choose

Figure BC7 Putting the cockpit in place

Create Polygon Primitives Cone , choose Edit Reset Settings, set the Subdivisions Along Height option to 5 (instead of 1), and click Create; then name the cone fin1. Set Maya to Move mode, and then move the cone out so it is below the cockpit. Now change to Rotate mode (press the E key) and rotate the cone so it points away from the side of the ship. To do this, grab the outermost (yellow) ring of the Rotate tool and MM drag to the right, as illustrated in Figure BC8. 13. The fin is almost correctly placed, but its currently much too small. Change to Scale mode (press the R key), and scale the whole cone out (click the yellow box in the center, and then MM drag to the right) until it is the right size. Were getting closer, but now the cone has been scaled out in all directions. To fix this, change to four-view mode (press the spacebar quickly), and, in front or top view, click the red (X axis) scale box at the end of the scale manipulator and scale the fin so it is thin in that dimension (see Figure BC9). 14. Now that the cone/fin is thin, return to the side view (click in the side view, and then press and release the spacebar). Highlight the fin so it is green; then press the F8 key to go into Component mode. Drag a selection marquee around the point at the tip (it will

Figure BC8 The cone, moved and rotated

turn yellow), press W (Move mode), and then move that point down so it is about as low as the exhaust nozzledont worry that it looks very angular right now. Next, draw a

Copyright 2004 SYBEX Inc., 1151 Marina Village Parkway, Alameda, CA 94501.

www.sybex.com

SETTING THE SCENE: MODELING

selection marquee around the second row of points in from the tip (be sure to select only this row), and move them down some as well. Finally, choose the bottom set of points on the next three rows in (toward the body), and move them up a bit. You should now have a curved fin, as in Figure BC10. Save your work. 15. When you like the shape of the fin, press the F8 key again to return to Object mode. Although the fin is nice, it could use some smoothing. Be sure the fin is still selected (green), and then choose Polygons Smooth to smooth out the angles between polygon facets. At this point, you might want to move the fin in toward the body more so that the fin sticks partway into the body. We have one fin; now we need to make two more. Rather than model these new fins, lets make Maya do the work. First, we need to move the pivot point of the fin (the point around which it rotates) to 0 on the X and Z axes, and then well just tell Maya to make two duplicates and rotate them. 16. Click the fin to highlight it and make sure you are in Move mode (click the Move tool in the Tool Box or press W on your keyboard). Now, press the Insert key on your keyboard. The arrows of the manipulator handles will disappear, and you will see the pivot point in the center yellow box. Click the blue handle (it may be difficult to see), and drag it to the center line. To more accurately center the pivot point, hold down the X key while dragging, forcing the pivot point to snap to the grid. When the pivot point has been moved, press the Insert key again to return to normal Move mode. You may find it easier to move the cones pivot point if you shift to wireframe display mode momentarily. To do so, just press the 4 key on your keyboard (not on the numeric keypad). 17. Now choose Edit Duplicate . In the option window, set Rotate Y (the middle box) to 120 (120 degrees, or one-third of a circle), set Number Of Copies to 2, and click Duplicate. You will now have three fins spaced evenly around the body of the shipMaya even names the other fins fin2 and fin3 for you! 18. As a last step, we need to make some ground for our rocket to take off from. Choose Create NURBS Primitives Plane , choose Edit Reset Settings, and then set the Width and Length to 100 (so the ground is very big). Click Create, and then rename the plane ground. Youll notice that the plane is right in the middle of the rocket. Using the Move tool, move the plane down until it is a significant distance below the ship (as in Figure BC11)dont let
Figure BC11 Figure BC10 A curved fin in Component mode Figure BC9 The cone, scaled

the rocket body, fins, or nozzle touch the plane, or you will have big problems later in this tutorial!

Moving the ground underneath the rocket

Copyright 2004 SYBEX Inc., 1151 Marina Village Parkway, Alameda, CA 94501.

www.sybex.com

8 BONUS CHAPTER: YOUR FIRST MAYA ANIMATION

MAYA SHORTCUT KEYS The QWERTY keys (across the top left of your keyboard) are shortcut keys. Memorize these keys nowusing shortcut keys is one secret to getting work done in Maya quickly! (If you tend to share your computer, such as in a school lab environment, the default Maya Hotkeys may have been altered. To restore them to their defaults, choose Window Settings/Preferences Hotkeys and press the Restore Defaults button.) The function for the QWERTY keys is as follows: Q Places Maya into Select mode (in which you can only select, not modify, scene elements). (Ctrl+Q places Maya into Lasso Select mode (also for selection only). W Places Maya in Move mode. E Places Maya in Rotate mode. R Places Maya in Scale mode (not Rotate mode!). T Places Maya in Manipulator mode. (We wont deal with this tool in this bonus chapter.) Y Places Maya in whatever modebesides Move, Scale, and Rotatewas last chosen (the EP Curve tool, in our work). You can also adjust the display of objects in the scene using the 17 keys on your alpha keyboard (not the numeric keypad). 1 Changes the display of any selected object into low-resolution display (which increases interactivity with the program, but the objects look blocky). 2 Changes the display of any selected object into medium-resolution display. 3 Changes the display of any selected object into high-resolution display (which looks much better, but can slow response). 4 Changes the display of all objects in the scene (not just selected objects) to wireframe display (faster interactivity and the ability to see through objects). 5 Changes the display of all objects in the scene to smooth-shaded display (basic coloring is visible). 6 Changes the display of all objects in the scene to texture-shaded display (the basic look of a texture is visible on objects). 7 Changes the display of all objects in the scene to textured-shaded and lit display (so the basic effect of lights can be seen).

Copyright 2004 SYBEX Inc., 1151 Marina Village Parkway, Alameda, CA 94501.

www.sybex.com

SETTING THE SCENE: MODELING

To alter the size of the plane, you can either scale it using the Scale tool or click the makeNurbsPlane text in the Channel Box and change the width setting.

19. Now that we have all our pieces, we need to get rid of the construction history for each of them and then erase the curves that generated them (otherwise well have problems later in the animation process). First, select everything in the scene (or RM choose Select All in the scene window); then choose Edit Delete By Type History. Now find the curves you used to build the body and nozzle of the rocket. (You can choose any component of the rocket and then use the Right and Left arrow keys to scroll through all the componentsor you can use the Outliner or Hypergraph to find the curves.) When you each curve is selected, press the Backspace or Delete key to delete them all. As a last step, we need to make all our rocket components into one object (well call it rocket) and move the pivot point of our rocket down to the ground plane (the reason for this will be apparent as we animate the ship). 20. Drag a selection marquee around the ship and all its components (be sure not to include the ground, though!); then hold down the Ctrl key and press G. This creates a new group (called group1) that contains all the pieces of the rocket we have modeled. Rename this group to rocket. If you accidentally highlight the ground plane with the rocket components, hold down the Shift key and click anywhere on the plane to deselect it.
In the future, if you click any component of the rocket (the body, say) and press the Up arrow key, Maya automatically chooses the rocket group for you. This technique is known as pick walking.
Figure BC12 Moving the rocket pivot point down

21. Be sure the rocket group is still selected (check to see that its name is showing in the Channel Box); then press the Insert key. Move the pivot point down (using the green handle) until it is below the bottom of the nozzle (see Figure BC12). Moving the pivot point will be important when we animate the scale of the ship (otherwise, the ship will scale around its middle, instead of its bottom). Be sure to press the Insert key again after you move the pivot point. Save your work. 22. Lets take a look at our handiwork. Change to perspective view in the scene panel (remember the spacebar trick), change to Shaded mode (press the 6 key), and then rotate around your ship by holding down the Alt key and the left mouse (LM) button and dragging around the scene window. Your rocket should look like that in Figure BC13.
Figure BC13 Perspective view of the rocket

Copyright 2004 SYBEX Inc., 1151 Marina Village Parkway, Alameda, CA 94501.

www.sybex.com

10 B O N U S C H A P T E R : Y O U R F I R S T M A Y A A N I M A T I O N

If your results are different from those you see in the book, you might want to return to the area that is different and rework it until you are satisfied with the results. Save your work and take a breakgood job so far!

Texturing Your Models Using the Hypershade


You might find the model youve created so far a bit well gray. Lets remedy that situation now by adding materials to the model elements, giving them a bit more color and interest. Materials in Maya are the general container for a shading network, which gives an object its color, transparency, reflectivity, and so forth. Normally, you create a material and then edit the materials settings or add textures (images or procedural textures) to get the look you want. Think of materials in Maya as your own virtual paint can. To create these materials, well use the Hypershade. Follow these steps: 1. Select the cockpit and then choose Window Rendering Editors Hypershade to open the Hypershade window. 2. To the left of the Hypershade is the Create Bar panel. (If you dont see it, click the checker icon in the upper-left corner of the screen, or choose Options Create Bar
Figure BC14 Creating a new material for the cockpit

Show Create Bar.) To create a new material, click the button at the top of the panel and choose Create Materials. Simply click the Phong material, and a new material will appear in the window on the right called the Hypershade panel. Name the new material cockpitPhong by holding down the Ctrl key, double-clicking the default name (Phong1), and then typing the new name, as in Figure BC14. 3. To assign this new material to the cockpit, just MM drag the material ball onto the cockpit in the scene window. Because the Phong material is still gray, you wont see much difference yet. 4. To adjust the color of the new material, double-click it in the Hypershade. This opens the Attribute Editor (shown in Figure BC15) with several options you can control for color and other attributes. 5. All were interested in for the cockpit is its color. Click the gray rectangle next to the word color, and, in the color picker that pops up, choose a very dark blue (almost black) color. You can watch the cockpit itself change as you adjust the color. When you get a color you like, click the Accept button.

Copyright 2004 SYBEX Inc., 1151 Marina Village Parkway, Alameda, CA 94501.

www.sybex.com

TEXTURING YOUR MODELS USING THE HYPERSHADE

11

6. Lets make another Phong material for the body of the rocket. Once again, click the Phong icon in the Create Bar panel on the left side of the Hypershade window, and then rename this new material bodyPhong. Now MM drag the material ball onto the body of the rocket. 7. In the Attribute Editor, adjust the color of the new material to a very pale blue-gray (the color of brushed aluminum). To make this work right, youll need to set the saturation of your color very low (we set it to 0.075). 8. When you accept the color, youll probably notice that the specular highlights (the shiny areas) on the rocket body are big and ugly. Fortunately, we can compensate for this. In the Specular Shading area of the Attribute Editor, set the Cosine Power (the size of the highlight) to a large number, such as 75, and set the Specular color to a darker gray (drag the slider to the left). When you finish, you should have a more pleasing highlight. 9. To create the ground shade (we dont want a specular highlight on the ground!), lets use the Lambert shader, which does not create highlights. Create a new Lambert material by clicking the Lambert icon in the Create Bar panel and renaming it groundLambert. Then MM drag the new material onto the ground plane, assigning it to the plane. (You may need to go into perspective view to see the ground plane.) 10. In the Attribute Editor, set the color of the ground plane to a dusty orange-yellow (a desert dirt color). 11. The last two materials well make will be a bit more interesting. First, lets create a material with a procedural texture for the nozzle. Create a new Phong shader, name it nozzlePhong, and assign it to the nozzle. 12. Instead of assigning a color to the new material, click the little checkerboard next to it (to the right of the slider) to open the Create Render Node window. Click the Checker button to apply a checkered pattern to your material, as shown in Figure BC16. 13. Although this texture as it currently is might be all right for playing checkers, its not what were after. In the Attribute Editor, make both of the colors in the checker pattern a shade of gray (drag the sliders next to the color swatches). Finally, decrease the Contrast setting to about 0.7. These changes will make the pattern much subtler.
Figure BC15 Attributes for the Phong shader

Copyright 2004 SYBEX Inc., 1151 Marina Village Parkway, Alameda, CA 94501.

www.sybex.com

12 B O N U S C H A P T E R : Y O U R F I R S T M A Y A A N I M A T I O N

Figure BC16 Giving the object a checkered material

14. Now click the place2Dtexture1 tab (at the top of the Attribute Editor) and set the Repeat UV to 16 and 0.5, respectively. This will give the nozzle the ringed appearance (seen in Figure BC17) common to rocket nozzles. 15. Finally, lets create the fin material, using a ramp to get our effect. First, create a new Phong material (called finPhong), and assign it to all three finsyou will probably have to rotate the scene panel in order to see all three fins so you can do this. 16. In the Attribute Editor, click the checkered box next to Color again to open the Create Render Node window. Choose Ramp from the list of 2D textures. You should see a Ramp Attributes window with a default ramp, and all the fins should have the colors applied to them. 17. Although the smooth transitions of the default ramp are nice, theyre not what we need for our fins. From the Interpolation pop-up menu, choose None. This turns off the smooth interpolation of the colors, making the ramp a series of color bars. 18. To change the ramp colors, select the ramp node (the circle to the left of the color bar) and then click the Selected Color swatch to open the color picker. To create a new color node, just click in the color swatch where you want that new node. To move a color up or down, drag the circle on the left of the color bar. Finally, to remove a color, click the box to the right of the color bar. You can use whatever colors you like for the ramp, but when you are finished, you should have something like Figure BC18, which is also on the CD in a color version.

Figure BC17 A ringed nozzle

Copyright 2004 SYBEX Inc., 1151 Marina Village Parkway, Alameda, CA 94501.

www.sybex.com

LIGHTING THE SCENE

13

We now have a fully textured ship and ground plane. Although none of these materials is terribly complex, they give the ship some color and add to the cartoonish feel of the world were creating. To be able to see our ship when we render it, well next need to add some lights to the scene.

Lighting the Scene


To light this scene, well add four lights: one ambient light to shade the whole scene and three spotlights. This lighting setup will give the scene a night-time quality, which is a bit more fun than one big light for the sun. Additionally, well make two of the lights track (or aim toward) the ship at all times. Follow these steps: 1. First, lets create our ambient light. Choose Create Lights Ambient Light . In the option window, set the intensity to 0.2, click the color swatch and set the color to a pale blue, and then click Create. 2. To see how the scene is lit so far, press the 7 key on your keyboard to go into Lighted mode (the scene should be almost dark). Press the 5 key to return to Smooth-Shaded mode. 3. Now lets create our spotlights. Choose Create Lights Spot Light . In the option window, choose Edit Reset Settings, and then set the penumbra angle to 10 (this fades the edge of the spotlight); then click Create. Rename this light frontSpot (if the Channel Box isnt open, click the Show The Channel Box button at the far right of the Status line to toggle it back on). Press the W key to get into Move mode, and then move the light up and away from the ship, toward the camera. Be sure the light is above the rocket by a significant amount; otherwise, it wont light the ground below the ship (which gives depth and solidity to the scene).
To move your lights, you will need to use the top and side views (press the spacebar to see these views) and scale these views out by holding down the Alt key, along with the left and middle mouse buttons, and dragging to the left in each window pane.
Figure BC18 The finished ramp

4. Because we want this spotlight to aim at the ship at all times, lets add an Aim constraint to it. First, click any part of the ship; then press the Up arrow key (be sure the Channel Box says rocket in its title area). Then, holding down the Shift key, click (or drag around) the light, highlighting it as well. Finally, from the Animation menu set (choose Animation from the top-left pop-up menu), choose Constrain Aim . Choose Edit Reset Settings, and then change the three aim vector text boxes to read 0, 0, and 1. Click the Apply button and verify that the spotlight is pointing toward the rocket (the cone should open toward the rocket body). If the spotlight is looking in another direction, try the following settings until one works: 0,0,1; 1,0,0; or 1,0,0. (The aim vector of a spotlightlike

Copyright 2004 SYBEX Inc., 1151 Marina Village Parkway, Alameda, CA 94501.

www.sybex.com

14 B O N U S C H A P T E R : Y O U R F I R S T M A Y A A N I M A T I O N

that of the camera well add shortlyis determined by where you place the lights in relation to the rocket. Because your rocket might be aligned along a different axis, you will have to try these settings until you discover the proper axis for your scene.) After you determine the proper aim vector, as shown in Figure BC19, the spotlight will be locked onto the rocket, wherever it goes. 5. We now need to create another light, this one off to the right side of the ship. Create a new spotlight (choose Lights Create Spot Light), call it rightSideSpot, and move it off to the right of (and above) the ship. 6. We want this light to follow the ship as well, so well do the same trick again: first, select the rocket (remember to press the Up arrow key), and then Shift+select the rightSideSpot light. Finally, choose Constrain Aim to force the light to point at the ship. You should not need to open the option box this time, because the proper aim vector should be set now. If your light is not aiming in the right direction, undo the last step, open the Aim constraint option box, and repeat the end of step 4, earlier. 7. Finally, lets create our last spotlight (which will stay pointed at the launch area). Once again, create a spotlight; then name the new light leftSideSpot, and move it to the left and above the rocket. Figure BC20 shows all three spotlights as they would look in the top view. 8. Because we wont be auto-aiming the light, well need to aim it manually. In the top view (with the light still selected), from the panel menu at the top of the top view panel, choose Panel Look Through Selected to change the view to show what the light sees (nothing at this point). Rotate the view until the rocket is centered in the view as in Figure BC21 (hold down the Alt key and drag with the left mouse button). To return to top view, choose Panel Orthographic Top.
Figure BC19 The spotlight aimed properly

Copyright 2004 SYBEX Inc., 1151 Marina Village Parkway, Alameda, CA 94501.

www.sybex.com

ANIMATING THE SCENE

15

Figure BC20 The left-side spotlight placed

Figure BC21 A view of the rocket through the light

9. To see how your scene is lit, press the 7 key again. It should be well (and evenly) lit across the ship and the ground near it. If not, try moving your lights around, or increasing their intensity. 10. Save your work and take a break. Good job so far!
It is often difficult to see how well lit your scene is using the flat (openGL) renderer. To get a better view of your scene, either click the Render The Current Frame button in the right part of the Status line or choose Render Render Current Frame from the Rendering menu set (the top-left pop-up menu). This will create a quick little rendering of your scene.

Animating the Scene


If things havent been interesting enough so far, were really going to have fun here: well animate our little ship and use some of the power of Mayas dynamics engine to launch it and bring it back to earth.

Keyframed Animation
First we need to create a keyframe animation of the ship about to take off. Keyframe is an old animation term for important moments in an animation (key frames). In digital animation, you tell the computer which frames are important (the keyframes), and the computer in-betweens the rest of the frames between these key frames, creating an animation. For our simple animation, well animate only the scale of the ship as it squashes, getting ready for takeoff, and then stretches as it leaps off the ground. This is classic cartoon

Copyright 2004 SYBEX Inc., 1151 Marina Village Parkway, Alameda, CA 94501.

www.sybex.com

16 B O N U S C H A P T E R : Y O U R F I R S T M A Y A A N I M A T I O N

anticipation and overshootyoull recognize the effect from any old Tex Avery cartoons you run across. Follow these steps: 1. To create our first keyframe, first be sure youre on the first frame of the animation (use the VCR-like controls at the bottom-right of the screen to rewind, and check to see that the Timeline marker is at 1). 2. Next, select the rocket (be sure its the whole rocket group, and not just the body); then, in the Channel Box, drag your mouse over the text of the three scale channels (scales X, Y, and Z), highlighting them. Then, with the mouse over the selected channels, use the right mouse button to choose (RM choose) Key Selected from the pop-up menu (see Figure BC22). The channels for scale should turn orange (green on Irix), indicating that theyre now keyframed. 3. After you create your first keyframe manually, Maya can automatically keyframe your channels. Check to be sure the auto-keyframe option is on by verifying that the Auto Keyframe Toggle icon at the bottom-right of the screen (below the VCR-like time controls) is red. If its not, simply click it to turn it red. 4. By default, our animation runs for 24 frames, or one second. (Maya defaults to 24 frames per secondfilm speed.) So we need to lengthen our animation. In the number field for the end time (to the right of the Range Slider), set the frame range to 100 framesa bit over four seconds. 5. Move the time marker (the gray bar in the Time Slider) out to 48 frames (2 seconds) by dragging it across the Time Slideror just click about where the 48th frame would be. Be sure your rocket is still selected, and then enter Scale mode (press the R key) and scale down the Y (green) axis so that the rocket becomes shorter (a scale of about 0.7 on the Y axis channel should do). You may notice that this simply shrinks the rocket; we also need to scale out the X and Z axes to make the rocket appear to maintain a consistent volume as it squashes. Although we could do this via the X and Z scale handles, it is easier to do so in the Channel Box itself. Click in the scale X text box, and then enter a value of 1.4. Do the same in the scale Z box. Your rocket should now look squashed, as in Figure BC23, rather than simply shrunk. 6. We now need to hold this squashed look for some frames (a hold keyframe). Move the time marker to frame 60, select the scale X, Y, and Z channels again, and RM choose Key Selected. (Alternatively, you could reenter the numbers you had before, forcing Maya to create a new keyframe via the auto-keyframe option.) 7. At this point, its a good idea to play back your animation to see how it looks so far. Click
Figure BC22 Choose Key Selected from the pop-up menu.

the Rewind button on the VCR-like controls (or press Alt+Shift+V); then click the Play button (or press Alt+V) to play the animation. The rocket should squash down and then hold its appearanceand then the animation loops and repeats itself.

Copyright 2004 SYBEX Inc., 1151 Marina Village Parkway, Alameda, CA 94501.

www.sybex.com

ANIMATING THE SCENE

17

8. Now lets make the rocket stretch out, as if stretching to take off from the ground (dont worry for now that its not moving up). Move to frame 70 and set the X, Y, and Z scales to 0.7, 1.4, and 0.7, respectively. (The rocket should look stretched out now.) 9. We need another hold keyframe (with the rocket stretched out), so move to frame 78, choose the scale channels, and RM choose Key Selected once again. 10. Now move to frame 90 (close to four seconds), and reset all the scale channels to 1the ship will now return to its original shape at 90 frames. When you play back the animation, you should see the rocket squash, preparing for takeoff, then stretch up (as it takes offdont worry, well take care of that next!), and finally return to its original shape. If you dont like how the animation runs, you can Shift+click any keyframe in the Timeline (highlighting it in red), and then drag that keyframe left or right on the Timeline, thereby adjusting the speed of the animation between each keyframe.

Figure BC23 Squash your rocket ship.

Using Dynamics for Animation


Weve completed the keyframing for this animation project. Now lets make Maya do the rest of the work. Well make the ship rise into the air by giving it a force (or impulse) and then drag it back down using gravity. Finally, well make the ground and rocket collide. To do all this, well use what is known as rigid body dynamics to tell Maya what forces act on our object (the rocket). As explained in Chapter 13 of the book, Rigid Body Animation, Maya (specifically, its dynamics engine) will use our input to do all the calculations necessary for realistic movement. Follow these steps: 1. First, we need to make both the rocket and ground rigid bodies, so theyll react to each other and forces we apply to them. Select the ground plane, and then change to the Dynamics menu set (from the pop-up menu at the top left of your screen). Choose Soft/Rigid Bodies Create Passive Rigid Body . (Be sure not to select Active!) In the option window, set the Static and Dynamic Friction to 0.5, and set the Bounciness to 0.2. Click Create to create the rigid body.

Copyright 2004 SYBEX Inc., 1151 Marina Village Parkway, Alameda, CA 94501.

www.sybex.com

18 B O N U S C H A P T E R : Y O U R F I R S T M A Y A A N I M A T I O N

2. Now lets make the rocket a rigid body. Select any of the rockets body parts and press the Up arrow key (be sure rocket is the name selected in the Channel Box). Choose Soft/Rigid Bodies Create Passive Rigid Body . In the Rigid Options window, as in Figure BC24, set the rockets mass to 1000, set the Impulse Y to 5000, and set the Impulse Position Y to 12 (this forces the impulse to be above the rockets body, so it wont spin around when you launch the rocket). Click Create.
If you get an error message when you try to create the rockets rigid body, check (using the Hypergraph or the Outliner) to be sure you have erased the two curves for the nozzle and body of the rocket. If you havent, do sothis should take care of any error messages.

3. With the rocket still selected, choose Fields Gravity . In the option window, set the magnitude of gravity to 25 (this setting is far heavier than Earths gravity, but it makes the animation look better!), check to be sure the Y direction of gravity is set to 1 and that X and Z are 0, and then click Create. Because the rocket was selected when you created the gravity field, it will be attached to gravity (that is, affected by it). 4. If you play back the animation now, you will see that it looks just the same as before. Thats because our rocket is still a passive rigid body (meaning that nothing can affect it). What we have to do is keyframe the rocket to be an active rigid body just at the frame where it should take off. Select the rocket, and then move to frame 62. Under the Shapes/RigidBody2 node (in the Channel Box), you should see a channel called Active (toward the bottom) that is set to off. Click once on the text (the word Active), and
Figure BC24 The Rigid Options window

then RM choose Key Selected to set a keyframe. Now move to frame 63, click in the Off text box, and type the word on. This will set a keyframe, setting the active state of the rockets rigid body to on, so it can now be affected by forces. 5. Before you play back the animation, youll want it to run longer. Set the playback length to 1000 instead of 100. (Type 1000 in the Playback End Time box, just to the right of the Range Slider.) The frame range should now go from 1 to 1000. Rewind and play back the animation (which is extremely important; otherwise Maya will become confused about its calculations and you will see some very strange results). You should now see the rocket zoom off into parts unknown. If the rocket gets stuck in the ground, youve got a rigid body interpenetration error, a problem youll learn more about in Chapter 13. To fix it, move the ground down a bit and run the animation again. (Dont forget to rewind!)

Copyright 2004 SYBEX Inc., 1151 Marina Village Parkway, Alameda, CA 94501.

www.sybex.com

CREATING A FOLLOW CAMERA

19

6. To make our ship stop going up and up, we need to turn off our impulse. Go to frame 104 (with the rocket still selected), select the channel for Impulse Y, and RM choose Key Selected. Move to frame 105, and type 0 in the Impulse Y number field (setting the impulse to 0 from this point on). When you play back the animation, the rocket should rise out of sight and then, about frame 450, crash back down into the ground, bouncing around until it comes to rest.
To see the animation better, try zooming your camera back (press Alt, and with the left and middle mouse buttons, drag left) this is called scaling the view. Also, if you dont like the way the rocket bounces off the ground, you can set the grounds bounciness lower (or higher), and you can change the rockets impulse setting from 5000 at the start to some other similar number (such as 5001). This small change will make the bounces go in very different ways.

You should now have a complete rocket animation, using keyframes for part of it and making Maya do the calculations for the rest. Next, well discuss how to make a new camera and have it aim at the ship at all times; then well talk about how to render out the whole animation. Save your work and take a break. Good job!

Creating a Follow Camera


As you might have noticed, the default perspective cameras view of this animation leaves something to be desired. What we need is a camera that follows the rocket into the air and back againwe need to aim our camera at the ship, just as we did with the lights. Aiming a camera at an object would not be a good idea if we wanted realistic animation. It is generally better to keyframe the camera to follow the objects motion, because this introduces human errors into the camera tracking (making the motion look like a person operating a camera instead of a computer operating one). For our cartoonish animation, having a camera follow the rocket is acceptable; however, if you want, you can keyframe the motion instead. 1. Create a new camera (choose Create Cameras Camera) and name it followCamera. Using the four view panes, move the camera down the X axis (to the right in the top view), and then move it up a bit off the ground planedo not rotate the camera at this point! 2. Select the rocket, and then Shift-select the new camera. In the Animation menu set, choose Constrain Aim to force the camera to point at the rocket. 3. To look through your new view, choose a panel (the top view, say), and, with only the followCamera selected, choose Panels Look Through Selected. Make this your sole

Copyright 2004 SYBEX Inc., 1151 Marina Village Parkway, Alameda, CA 94501.

www.sybex.com

20 B O N U S C H A P T E R : Y O U R F I R S T M A Y A A N I M A T I O N

viewing pane (press the spacebar), and then play back the animation. You should see the camera follow the rocket up into the air and then back down again. 4. Save your work.
If the camera is too close to the action or too far away, just zoom your view (Alt+LM and RM buttons and drag) to get a better view.

Rendering the Animation


Although watching the animation play in your scene window is great, its probably a bit bumpy (especially if you have a slower machine). You can render a cleaner view of your animation in two ways: playblasting and final rendering (batch rendering). Although a final rendering gives high-quality results, it takes a great deal of time to produce these results. Playblasting, on the other hand, produces a rougher (smooth-shaded) look, but goes as fast as your video card can spit out images. Thus, for a quick look at the animation, playblasting is a far better choice than a final rendering. Playblasting the animation is one step: choose Window Playblast and watch as Maya creates an animation for you, using the basic shading mode of your computer. Once the animation is complete, you can view it in its own little movie window, as in Figure BC25. Youll learn more about playblasting in Chapter 8 of the book, Basic Animation. Rendering the final product is a bit more complex and takes much longer. Essentially, a final (batch) rendering creates a high-quality snapshot of each frame of the animation, using all the lighting, material, and animation information your scene can provide. The results of a final rendering can be excellent, but it is a fairly slow process, because your computer has to do many calculations for every pixel of every image. Thus, you will only want to proceed with these steps when youre sure youre happy with your animation. 1. Choose Window Rendering Editors Render Globals or click the Render Globals button in the Status line to open the Render Globals option window. In the Image File Output section, type a name (such as rocketRender) in the File Name Prefix File box. Set the Frame/Animation Extension to name.#.ext, set the end frame to about 700 (you want to be sure its a large enough number that the rocket has come to rest first), set the Frame Padding to 4 (this adds zeros before your frame number, so the frame will be numbered render.0001, render.0002, and so forth, instead of render.1, render.2, and so on), and set the active Camera to followCamera (otherwise Maya will use the default persp camera, and you will waste your rendering time). 2. Twirl down the Resolution arrow, and set the Render Resolution to 320240.

Copyright 2004 SYBEX Inc., 1151 Marina Village Parkway, Alameda, CA 94501.

www.sybex.com

ADVANCED TOPIC: ADDING EXHAUST

21

3. Twirl down the Anti-aliasing Quality arrow, and set the Presets field to Intermediate Quality (this makes for a fairly fast render time, but with decent quality). 4. After you change your settings, close the Render Globals window, and open the Rendering menu set (the top-left pop-up menu). Choose Render Batch Render. 5. Maya will render out all 700 frames of the animation (which will take some time). You can view the progress of each frame in the Feedback line (at the bottom-right of the screen), or, to view the current frame that is rendering, choose Render Show Batch Render. To cancel the render at any time, choose Render Cancel Batch Render. 6. When the rendering job is finished, you can view it using the FCheck utility. In Irix, type fcheck in a shell window; in Windows, choose Run (from the Start menu), and type fcheck in the text field or select fcheck from the Maya folder by browsing the Programs folder in the Start menu. A window will open, letting you navigate to your images folder (it should find this for you automatically). Choose the first frame of your animation and click OK. FCheck cycles all frames into memory and then plays back the animation at full speed. Congratulations! You have modeled, textured, lit, animated, and rendered an animation in Maya. If patting yourself on the back isnt your style, you can move on to the next section, where you will learn how to create a particle exhaust trail for the rocket. If this was enough practice for a start, you can re-enter the book at Chapter 2 and save particles until the end of your study.

Advanced Topic: Adding Exhaust


If youve worked extensively with other animation packages, what weve done so far may seem fairly straightforward. In that case, youre probably ready to explore another area of Maya dynamics, namely particles. Well use a particle emitter to create a shower of particles and then texture them to look like smoke and flames. To make it appear that the exhaust is powering the rocket, well turn the emitter on and off (via keyframes) at the appropriate moments. 1. First, we need to create our emitter. In the Dynamics menu set (top-left pop-up menu), choose Particles Create Emitter . In the option window, name the emitter exhaustEmitter, set the emitter type to Directional, set Rate to 0, and, under the Distance/ Direction section, set Spread to 0.3 and DirectionY to 1 (so the emitter points downward). Twirl down the Basic Emission Speed Attributes arrow and set the Speed to 60. Finally, click Create. You now have a particle emitter, which needs to be attached to the nozzle of the rocket.
Figure BC25 The playblasted animation in its own window

Copyright 2004 SYBEX Inc., 1151 Marina Village Parkway, Alameda, CA 94501.

www.sybex.com

22 B O N U S C H A P T E R : Y O U R F I R S T M A Y A A N I M A T I O N

2. To attach the emitter to the nozzle, first move the emitter (which should still be selected) down into the base of the nozzle. With the emitter still selected, Shift-select the nozzle and press the P key, making the nozzle the parent of the emitter (so that the emitter will travel along with the rocket as it moves). 3. If you play back the animation right now, the particle emitter will shoot out no particles, because its rate is set to 0 particles per second. Just before the rocket takes off (frame 63), we need to turn on the engineour particles. Go to frame 59, select the Rate channel for the emitter, and RM choose Key Selected to set a keyframe at 0 for this frame. 4. Now go to frame 60 and set a rate of 500 so there are suddenly many particles shooting out from the ship. If you play back the animation now, a shower of particles (points by default; well fix that in a moment) will shoot out from the exhaust nozzle, as shown in Figure BC26. 5. Now we need to turn off our rocket. Go to frame 104 and set a keyframe for the Rate at 200 (select the Rate text, and type 200). Now, at frame 105 (where the impulse turns off as well), set a new keyframe for Rate at 0. When you now play back the animation, the particles will stop coming out of the rocket at frame 105however, the particles hang around forever (they never die). We need to give our particles a life span so they will die off like good flames should.
For more on controlling how particles live and die, see Chapters 14, 15, and 16.

6. With the emitter still selected, press Ctrl+A to open the Attribute Editor. Once in the Attribute Editor, click the particleShape1 tab at the top; then, in the Lifespan Attributes section, choose Random Range for the Lifespan Mode. Leave the Lifespan at 1 (second), but change the Lifespan Random to about 0.3. Setting these two attributes this way makes each particle live 1 second, plus or minus 0.3 seconds (or in a range from 0.7 to 1.3 seconds). When you now play back the animation, you should see the particles die out approximately a second after they are created (thus the trail of particles follows the rocket up as it takes off). Save your work. 7. Now that we have a good trail of particles to work with, lets change the rendering type from points to something more interesting. In the Attribute Editor (with the particleShape1 node still selected), under the Render Attributes section, set the Render Type to Cloud (s/wfor software rendered). Next, click the Current Render Type button to add the attributes that belong with the cloud render type.

Copyright 2004 SYBEX Inc., 1151 Marina Village Parkway, Alameda, CA 94501.

www.sybex.com

SUMMARY

23

8. In the new fields, make the radius 1.5, the Surface Shading 1, and the Threshold 0.5. When you play back the animation (which will now run significantly slower), you should see that the exhaust particles are now spheres. To see what they would look like in a real rendering, click the Render The Current Frame button in the Status line or choose Render Render Current Frame (from the Rendering menu set). 9. Now were closing in on a good exhaust cloud. The last piece of the puzzle is to create a texture for the particles. Play the animation to a frame where the particles are showing; then open the Hypershade (choose Window Rendering Editors Hypershade). To create a cloud texture, we need to create a volumetric texture. To do so, click the arrow next to Volumetric in the Create Bar panel to open the volume materials. Click the particleCloud material (the light blue ball), which will then appear in the right-hand window of the Hypershade (Figure BC27), and then rename the material exhaustVM. 10. Select the exhaust particles, right-click the material (in the Hypershade), and RM choose Assign Material To Selection. Move over to the Attribute Editor, and set the color of the material to a bright yellow. Set the Transparency to a light gray (by moving the slider to the right), and set the Glow Intensity to 0.5. Test render your current framethe exhaust should now glow a bright yellow as it is emitted from the nozzle. If youre not satisfied with the look of the exhaust, try adjusting some of the material settings or the render attributes of the particleShape1 node. Save your work again. When you are satisfied with the look of your exhaust, you can render out the entire animation sequence (see the Rendering the Animation section earlier) to see how things look with your exhaust plume. To compare your work with ours, you can take a look at rocket.mov also provided on this companion CD.

Figure BC26 Particles being emitted from the nozzle

Summary
Congratulations! You have completed a real-world animation project your first time out. If your work does not look the way you would like it, thats all right: it can take quite a while to get an animation package producing just what you had in mind. No matter how you did, you can always return to this project as you continue through this book. You may find that after reading a few chapters of Maya 5 Savvy, youd like to give this project another try. In that case, use this bonus chapter as a reference, not a guide. In other
Figure BC27 A new particle cloud shader

Copyright 2004 SYBEX Inc., 1151 Marina Village Parkway, Alameda, CA 94501.

www.sybex.com

24 B O N U S C H A P T E R : Y O U R F I R S T M A Y A A N I M A T I O N

words, try to do the work by yourself, and read the directions here only when you get stuck. In this way, youll make the project your own, and youll learn even more from it. Whether you tried this rocket animation with years of digital 3D experience under your belt or it was your first foray into the wonderful world of 3D, you should be able to see how powerful the Maya environment can be.

Copyright 2004 SYBEX Inc., 1151 Marina Village Parkway, Alameda, CA 94501.

www.sybex.com

You might also like