Recipe 5.3. Adding Simple 3D Animation to Flash


Problem

You want to animate 3D objects in Swift 3D for use in Flash.

Figure 5-17. Knight with lathed base


Solution

Use drag-and-drop animations from the gallery toolbar and customize them with the timeline.

Discussion

There are two primary ways to add animation to a Swift 3D scene. If all you require are simple rotations and spins, most likely the preset Gallery Animations will fulfill your needs. The second method is manual keyframe animation, similar to that done within Flash. In either case, at the core of movement in Swift 3D is the animation timeline.

Most likely if you are reading this book, you have at least a basic working knowledge of Flash and thus have some familiarity with a timeline. Although there are specific differences between the Swift 3D timeline workflow and that of Flash, the basic concept remains the same. Motion is defined through modifying aspects of an object at specific points (keyframes) in the timeline and the software generates the necessary frames in between these points. When an object is selected, the properties that are available for animation are reflected in the layers of the timeline. See Figure 5-20 to review the parts of the timeline.

Figure 5-18. Setting depth for extruded elements of knight


The "Animate" button in the main toolbar must be active ("red") in order to edit the timeline in any way.



Selected Objects Name

The name of the object or group of objects that is currently selected.


Property Layers

The list of object properties that may be animated for the current selection.


Playback Controls

Used to control the playback of animation within the Scene Editor viewports.


Frames Per Second

This property is just like FPS in Flash. If you want an animation to play back in Flash at the same speed as it was created in Swift 3D, this setting and the FPS of the target FLA must be the same.

Figure 5-19. Final knight with black material applied

Figure 5-20. Swift 3D Animation timeline


Looping Playback Button

When this button is depressed, the animation will continuously loop until stopped. If looping playback is active when rendering a scene, the last frame of the animation will be left out in order to accommodate for a smooth loop.


Current Frame Indicator

Shows the current place in the timeline that is being viewed. By dragging this indicator to the left and right, you may also "scrub" through the animation.


Keyframe

Signifies points in the timeline where the property of an object has been modified. To set a keyframe, place the Current Frame Indicator at a desired frame and modify an object. Unlike Flash, a keyframe in Swift 3D is made up of two elements, a "Stop frame" handle and a "Start frame" handle. If these are dragged apart, the green line that represents animation in the timeline will become red, which will cause the specific animation to stop for a time equal to the number of frames it spans.


Timeline Scale Bars

By dragging these horizontally, you can increase or decrease the duration of all animation within the timeline.


Timeline Scrollbars

These act like any other scrollbar, allowing you to view items that are currently not visible due to limitations of space.

Model objects, trackball lights, scene lights, scene cameras, and the perspective camera may all be animated, but there are some common properties that cannot be animated. Some of these include:

  • Environment and Background Color

  • The color of lights

  • Camera Lens Length

  • Bevel settings

  • Mesh Deformations modeled in the Advanced Modeler

  • Segmentation

  • The Sweep Angle of lathed objects

Here I'll provide a quick example of using the basic features of the timeline and animation gallery. The goal of the exercise is to animate the sunglasses shown in Figure 5-21. The planned animation will include the glasses spinning a full 360° horizontally along the x-axis while simultaneously folding the armatures to the closed position. During the process, object pivot points will be repositioned by manually animating with keyframes and applying a preset animation from the Gallery toolbar.

Figure 5-21. Sunglasses model to be animated


The first step is to organize the various part of the model for animation, forming parent/child relationships to make things easier.

I have created relationships between the objects in the Hierarchy menu (see Figure 5-22) so that all parts of the glasses are under the influence of the parent named "Glasses." This step allows me to animate the entire model at one time. Below Glasses is another grouped relationship between the frames and the lenses, and finally two more additional children, one for each armature. This structure lets me apply animation to each armature without affecting the position of the overall model.

To keep positioning simple, I will animate the armatures first, but before applying any changes, I first must reposition each arm's pivot point. Currently it is set to the center of the armature's mesh, and if I were to rotate the left arm, it would look similar to Figure 5-23. Not exactly what I had in mind.

Figure 5-22. Parent/child relationships in the Hierarchy menu


Figure 5-23. Example of rotating an object with incorrectly placed pivot point


Confirm that the Animate button is deactivated. After clicking Move Pivot Only, which is found under Position in the Properties Toolbar, use the mouse to reposition the pivot point so that it is located approximately where the hinge would be located. Doing this type of positioning requires working between the Top and Left viewports, and it often helps to switch over to wireframe view to remove visual obstacles. When in place and looking at the model through the Top viewport, check to see your progress by toggling on Lock Spin and giving the left arm a quick rotation with the trackball (see Figure 5-24).

Figure 5-24. Example of rotating an object with the pivot point adjusted to the correct position


Everything appears to be in place, so undo the rotation and repeat the process to reposition the right arm's pivot point. After both are in place, it is time to start animating.

With the Animate button in the active state, place the Current Frame Indicator at frame 30 and again rotate the left arm using the trackball and Lock Spin. Repeat for the right arm; the glasses are now folded shut. To make sure that the positioning is good, toggle off Animation Mode and switch to the Perspective view, rotating the camera to see how things look (see Figure 5-25).

The positioning looks good; however, the animation preview shows that the meshes of the arms are actually coming into contact with one another and intersecting. It is always good to check an animation from multiple angles to detect problems such as this.

To solve the issue of the overlapping mesh, reenter Animation Mode and select the right armature. After dragging the Start Frame handle in the Rotation layer to the fourth frame, the right arm has a slight delay before starting to close. This keeps it from hitting the left arm and the problem is solved, as shown in Figure 5-26.

Now that the armature animations are completed, the final step is to apply the horizontal rotation to the glasses. Using the Top viewport, drag and drop the ERHorizontal Right animation to the Glasses group. When previewing the animation, two problems are evident right away. First, the spin finishes 10 frames before the armature animation. Second, the glasses extend off of the pedestal as they rotate.

Figure 5-25. Final position of armatures in animation


In order to have the armature animation end with the rotation, select all in the Glasses group and drag the Timeline Scaling Bars to the 30th frame. To fix the problem of the glasses rotating off of the pedestal, reposition them to the center of the pedestal at the 30th frame. This fix will cause the glasses to move backward along the z-axis as they rotate. Setting the Stop Frame handle of the Position layer at frame 17 caused the glasses to move to the desired position before the animation was fully completed. Figure 5-27 shows every fifth frame of the animation.

You should now have a good understanding of the animation timeline, the role that pivot points play, and structuring items in the Hierarchy menu. Armed with this basic knowledge, you will be able to apply it to create much more complex animations of your own.

Figure 5-26. Adjusting start frame in the timeline to set a delay in the start of animation


Figure 5-27. Every fifth frame in 30-frame animation of sunglasses rotating while folding





Flash 8 Cookbook
Flash 8 Cookbook (Cookbooks (OReilly))
ISBN: 0596102402
EAN: 2147483647
Year: 2007
Pages: 336
Authors: Joey Lott

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net