Recipe 5.1. Solutions for Integrating 3D with Flash Projects


Problem

You want to add 3D graphics easily to your Flash projects.

Solution

Use the appropriate Swift 3D software solutions from Electric Rain.

Discussion

As Flash has progressed over time, many designers have wanted to add 3D graphics and animation to their Flash projects. It is not possible to add true real-time 3D graphics, because the Flash Player does not contain a 3D rendering engine, so it is necessary to simulate such effects. Methods for creating these simulations have varied, along with the results and practicality associated with each.

Freehand drawing methods

Illustrators have long been giving 2D drawings the illusion of depth through perspective drawing techniques. Obviously this method can require highly developed drawing skills. If the project involves animation, it can also require a lengthy time investment, reminiscent of hand-drawn frame-by-frame cell animation. Making revisions in animation or graphics with this method can result in basically the entire animation needing to be recreated. Obviously, this problem could be disastrous if working under a tight deadline or budget.

Importing prerendered images from 3D programs

Importing a sequence of bitmap images rendered in a traditional 3D design program may be a perfectly acceptable solution for some projects. However, if vector data is required, the tedious task of hand-tracing each image can be as time-consuming as perspective drawing. Manual rendition also has the downfall of making revisions difficult. Using the bitmap auto trace feature in Flash may be a possibility, but its results usually leave a lot to be desired in both quality and the resulting file size. Also, with all the traced elements residing on a single layer, animating any objects with a background can be difficult at best.

Mimicking 3D with ActionScript

Armed with ActionScript and Flash's drawing API, it is possible to create the illusion of 3D shapes and even animate them in mock 3D space, all from within Flash. Unfortunately, only basic geometric shapes can be created, and although bitmaps can be mapped to the faces of these objects, it is by no means an easy task. Achieving photorealistic results is not possible and the entire process has to be completed programmatically with no real-time visual preview. This method also requires an advanced working knowledge of ActionScript, making it difficult to accomplish for many intermediate-level designers and developers.

Using Swift 3D from Electric Rain

With the use and demand for 3D graphics and animation on the rise, a number of designers from traditionally 2D backgrounds are being drawn to 3D design for the first time. Committing to take the plunge into 3D can be a daunting task, as it is a multifaceted discipline steeped in its own software tools, lingo, and techniques. To the uninitiated, this new world can be as confusing as taking those first steps into Flash, and one of the hardest tasks of breaking into 3D is figuring out where to start. Before undertaking the actual task of even learning to work in three dimensions, you must first select the appropriate tools. The number of software solutions and the myriad of features therein can quickly make it difficult to choose your tools. The financial investment for many high-end software packages and their relatively steep learning curves can be enough to stop many would-be enthusiasts dead in their tracks before they can even create their first polygon; however, that is all changing. If your primary desire is to create 3D graphics and animation for use in Flash, the Swift 3D line of software solutions from Electric Rain (Erain) are the perfect fit. The combination of a relatively mild learning curve and low price make this midrange 3D program an ideal solution for beginner and advanced Flash users alike.

When released in April 2000, the goal of the Swift 3D standalone application was to provide the ability to render 3D graphics and animation to vector-based formats compatible with Macromedia Flash. It quickly became the premiere tool for this purpose, and the industry leader. Now in Version 4.5, Swift 3D has continually improved its integration with Flash. Along the way, there have also been additions to the Swift 3D family of products, and although the remaining portions of this chapter are focused on working with the Swift 3D 4.5 (build 471 at the time of this writing), these alternative solutions are worthy of mention.

Accompanying the release of Swift 3D 2.0 were plug-ins for 3DS Max and Lightwave (now both properties of Autodesk), as well as SoftImage; however, the Lightwave plug-in has been discontinued. The plug-ins grant users of these high-end 3D applications the opportunity to work within the environments and with powerful tools with which they are already familiar, while granting them access to the rendering and export options of Erain's vector-rendering engine, RAViX 4.

The most recent addition to the Swift 3D lineup is Swift 3D Xpress, which as the name hints is a "light" version of Swift 3D. It is not a standalone application, but rather an extension that installs into Flash MX 2004 and Flash 8 and is accessed from the Commands menu. It provides access to Swift 3D's basic tools for performing common 3D tasks without having to leave the Flash authoring environment. Because its feature list is a scaled-down version of the full application, it is discussed in more detail at the end of the chapter, so that the differences between the full and express versions are evident.

Flash and Swift 3D are like chocolate and peanut butter: each great in their own regard, but when combined, they provide rich results. However, before we get cooking, it is important that you know your way around the Swift 3D kitchen and tools contained therein. If you are new to Swift 3D, now might be a good time to open the program.

A fully functioning trial of Swift 3D is available for download from the Erain web site (http://www.erain.com/downloads/trials/). The only feature that is disabled is rendering and export.


The Swift 3D authoring environment is split up between six interfaces. These include the Scene Editor, Extrusion Editor, Lathe Editor, Advanced Modeler, Preview and Export Editor, and finally the Web Assistant, which is really an information portal rather than a tool. Switching between editors is done using the tabs that run across the top of the interface (see Figure 5-2).

Figure 5-2. Tabs at the top of the interface for switching between editing environments


Projects will always take place in at least two of the editors ( Scene Editor and Preview and Export Editor), but it is not uncommon to make use of them all to some extent. The following sections provide brief overviews of each, as well as for what they are commonly used to accomplish.


Scene Editor

The Scene Editor (see Figure 5-3) is the default view that greets you upon opening the program. As the name clearly implies, this is where you construct your scene, arranging and animating your models in 3D space, applying lighting, adjusting environmental settings, and positioning the cameras with which your 3D world is viewed. The features of the Scene Editor include:


Viewports

The most prominent elements in the Scene Editor, the viewports act as windows into your 3D world. By default, two viewports are visible, each assigned a different camera view. Whatever is showing in the left viewport is what will ultimately be rendered and exported.


Main toolbar

This toolbar contains a horizontal row of icon-adorned buttons across the top of the interface; here a simple click will let you do things like save, undo, and test render viewports. This is also where you will find shortcuts to adding simple predefined 3D objects (primitives), free lights, and cameras.


Properties toolbar

Here you set general scene properties, such as physical dimensions, environment, background color, and more. The categories of Layout, Camera, and Environment are always present; however, the toolbar is context-sensitive and displays other properties available for selected objects as well.


Animation timeline

In the animation timeline, objects are animated in 3D space. Structured much like its counterpart in Flash, the timeline is organized by named layers and uses keyframes. Although there are also animation timelines within the Extrusion and Lathe Editors, their usage is slightly different (as is discussed later).


Hierarchy menu

The Hierarchy menu lists all objects (models, cameras, and lights) within a scene, providing an alternative method for selection. It is also where parent-child relationships are created between objects for greater control when animating.


Rotation trackball

Allows selected objects to be rotated on all axes. Options for locking rotation to a single axis and the degree of rotation can also be set, as well as resetting an object to its default position and rotation.


Lighting trackball

The Lighting trackball lets you position scene lights. Buttons to the right of the ball provide the ability to both add and delete lights.


Gallery menu

The Gallery menu includes an assortment of different libraries, which include complete models, materials, and preset animations and lighting schemes.


Status bar

Often overlooked, the status bar provides real-time feedback regarding a number of important properties while you work, including mouse coordinates and progress.


Extrusion Editor

The Extrusion Editor's purpose is to create 3D objects by extruding a 2D path. In a nutshell, extrusion is adding depth to a one-dimensional vector path. A good analogy is comparing a single sheet of a paper to an entire ream. Although the two share the same basic shape, the ream also has depth. This is accomplished by creating a vector profile using the editor's drawing tools. You may also edit imported vectors shapes using the Extrusion Editor. See Recipe 5.2 for more details regarding importing and working with AI and EPS files. When extruded, you also have the option to assign various bevel types to an object. Figure 5-4 shows an example of an extruded path.

Figure 5-3. Overview of the Swift 3D interface

The Extrusion Editor also contains an animation timeline that corresponds to the master timeline in the Scene Editor. The features and use of this timeline are discussed in Recipe 5.3.

Figure 5-4. Example of 2D path extruded to 3D object


Lathe Editor

The Lathe Editor is similar to the Extrusion Editor, in that you are working with 2D vector paths; however, that is where the similarities end. The basic principle of lathing in 3D is to rotate a 2D path around a central axis, which in the case of Swift 3D is the y axis. You have the option to turn it a full 360°, creating a closed symmetrical shape, or to set the Sweep Angle to degree of your liking, in which case the span of degrees not covered will be subtracted from the model. When using a Sweep Angle of less than 360°, there is also the option to have the shape closed or open on the exposed ends. Figure 5-5 shows the same path as was used in the extrusion example, but lathed around the y axis less than 360°.

Like the Extrusion Editor, the Lathe Editor also contains an animation timeline, the features and use of which are discussed in Recipe 5.4.

Figure 5-5. Example of 2D path lathed to 3D object


Advanced Modeler

The Advanced Modeler is not so much an editor as a full modeling environment, allowing for the creation of model mesh as well as features for precisely applying and modifying materials. It also provides the only tools that you can edit on the model mesh level, pushing and pulling polygons to create complex objects. The Advanced Modeler is ideal for creating organic shapes, such as those used in character design. Lathe and Extrusion objects may be brought into the Advanced Modeler for modification, allowing for the creation of shapes not possible using the other editors alone. In appearance, the Advanced Modeler looks a lot like the Scene Editor, but it has up to four viewports and no animation timeline (see Figure 5-6). Due to the complexity of mesh modeling, the discussion in this book only scratches the surface of the Advanced Modeler; the content and techniques associated with it are worthy of a chapter, if not a book, of its own!

Figure 5-6. Advanced Modeler interface

When an object from one of the other editors is brought into the Advanced Modeler for editing, it ceases to be a lathe or extrusion and is no longer tied to the properties associated with both object types. Also, any animation that may have been applied in Lathe or Extrusion Editor timelines will be lost.



Preview and Export Editor

Many of the settings that determine how a final piece will ultimately appear are set in the Preview and Export Editor, which is usually the last stop for a project while working in Swift 3D. You decide not only what will be rendered and exported, but whether it will be in a raster or vector format, each of which comes with its own unique settings. A screenshot of the Preview and Export Editors can be seen in Figure 5-7.


Web Assistant

As previously stated, the Web Assistant is not an editor, and it is not actually required at all when working on projects. It acts as a resources portal for both online and offline information regarding Swift 3D, such as help files, tutorials, technical support, and product updates.

Figure 5-7. Preview and Export Editor


Basic elements of a 3D scene

A scene created in Swift 3Dand in most 3D programscontains a number of basic elements. Although the features and options of each of these may vary from program to program, the basics remain the same. These include 3D objects (models), lighting, cameras, and environment:


3D models

Rather self-explanatory. Any object in a scene that is not a camera or a light.


Lights

Without them there isn't much to see! In Swift 3D, these include those found on the Lighting Trackball, as well as Scene Lights. Trackball lights can be thought of as "world" lighting, as they rest outside of the viewports and affect everything in your scene. Positioning these lights can be done only by using the trackball. They can be animated. Scene lights, on the other hand, appear within the viewports and can be manipulated much like any other object. A scene can contain a maximum of 16 lights, which includes the sum total of both world and scene lights.


Cameras

Any time you are using a viewport, you are looking through a camera lens. Swift contains seven standard cameras (Front, Back, Left, Right, Top, Bottom, and Perspective). These cameras are not represented within the viewports, and only the Perspective camera may be animated. The other, more flexible cameras, known as scene cameras, include both Free and Targeted cameras. These are displayed within viewports and can be positioned and animated like other objects. As in lighting, Free cameras are visible within viewports and can be positioned and animated like 3D models. A maximum of 250 Free and Targeted cameras may be added to a scene.

One of the more challenging concepts for a designer coming from a 2D background grasp is the z-axis. While Flash contains simple x and y-axes for placing objects on the stage, 3D adds that all-important z-axis (the third dimension). Unlike in Flash, where you simulate depth by stacking objects on one another or change their scale, in a 3D composition you actually position the object further away in 3D space. In the Swift viewports, you can easily determine what axis you are working with by the axis indicator located in the center of the viewport.



Environment

The Environment settings in Swift 3D are comprised of three elements: Background Color, Ambient Light Color, and Environment. Background Color is used to designate the color visible in the background of a scene, just like setting the background color of the stage in Flash. Ambient Light Color is the hue of the overall lighting of a Scene and is independent of color settings made to individual lights. For example, if the Ambient Light Color is set to red, a white object in the scene will take on a red or pink hue. Finally, there is the Environment setting, which is confusing for some users when they first start working in Swift 3D, due to an understandable misconception of its use. Setting an Environment shares many similarities to applying a material to an object. In fact, it is basically just that, however instead of an object that is visible within the viewport, the material is instead being applied to an invisible sphere that encompasses the entire scene. Like materials, Environment can be designated as a solid color or various gradient types (procedural environments), as well as imported bitmap images. However, it is important to understand that unlike Background Color, Environment is not readily noticeable in the Scene Editor when applied. The Environment exists outside of the camera's field of vision and is only exposed in the faces of objects that have a reflective material applied after rendering has taken place. Refer to Figure 5-8 for a visual example of an object rendered with different Environment settings.

Figure 5-8. Example of an Environment on two spheres with reflective materials applied; sphere on the left was rendered with a solid white environment, and the one on the right with a bitmap image





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