Recipe 5.2. Creating 3D Objects


Problem

You want to create 3D objects for use in Flash.

Solution

Use Swift 3D's multiple editors for accomplishing different modeling needs.

Discussion

Four of the five editors in Swift 3D are used for modeling of one kind or another. Each has its own specific strengths and weaknesses, and learning which editor is ideal for a specific task can greatly increase your productivity and level of success. Some planning and forethought regarding how an object is constructed will help you determine which editor is best for the job at hand. Often a combination of editors is required to achieve exactly what you want. To illustrate this point, the following example creates a chessboard and three sample pieces using the different modeling tools at your disposal in Swift 3D.

Setting up a new document

To begin, we need to first set up a new Swift 3D document. Create a new file and set the viewport dimensions, found under Layout in the properties panel, to 800 x 600. Select Environment in the properties panel and double click the Background Color preview to enter edit mode. Set the color to dark gray (R: 128, G: 128, U: 128), so that there will be contrast when working with the black and white elements of the chess game. Finally, assign the right viewport to the Top camera and set the secondary viewport to Front.

Building the chessboard

A chessboard is made up of 64 squares of alternating color; in this case, black and white. Though a relatively simple object, even this could be modeled in a variety of ways. Thinking over it quickly, here are a few options that you could try. They will all give you basically the same results:

  • Use individual plane or rectangle primitives to create each of the black and white alternating squares. Even with numeric placement and grouping/duplicating objects, the primary disadvantage to this method is the time that it would take to precisely position each square.

  • Use a checkered material and apply it to a plane or extrusion. Again, this is a possibility; however, getting the materials to line up perfectly with the edges of the shape to which it is applied might prove difficult.

  • Import an AI/EPS document that contains the checkerboard vectors created in an external program. Although this approach solves the issue of placing each shape mentioned in the first example, you will still need to set all of the extruded depths to the same value, so that shapes line up. Also, relying on an external program and importing is probably overkill for this task.

These are all feasible solutions, yet there is a much simpler answer. By taking advantage of the segmentation settings of plane primitive and surface groups available in the Advanced Modeler, we can quickly create a checkerboard that is uniform in size and accurate in placement.

Enter the Advanced Modeler and click on the Plane primitive button. Under Segmentation in the plane properties, set both the width and height to 8. Working in the Perspective view, click and drag in the viewport to add the primitive plane. The Perspective view is used because primitives added to this viewport automatically maintain their proportions and are placed at the viewport's origin (X:0,Y:0,Z:0).

When adding a primitive to one of the Orthographic viewports, holding down Ctrl (Win)/Option (Mac) constrains the objects' proportions.


What we have now looks slightly more complex than a chessboard (see Figure 5-9). The reason for this is that polygons in Swift 3D are always triangular. Each segment is thus composed of two polygons in order to make a square.

Drag-and-drop the "ER VectorFlat Black" material, located under the Flat tab in the preset materials gallery, to the plane. This step will not only take care of the material for the black squares, but will also make the wireframe more easily visible for selection purposes.

Figure 5-9. Primitive plane in the Advanced Modeler with height and width segmentation of 8 applied


Before going any further, enter Edit Mesh mode to make the necessary tools available. If necessary, select the Plane primitive button and click the Edit Mesh button located on the right side of the top toolbar. When active, the button will be red and any object selected will turn orange.

Switch to working in the Front viewport and deselect the plane by clicking on an empty area in the viewport. Press the F key to enter Face Selection Mode. Starting at the top-left corner of the plane, select every other segment (two polygons per square). When finished, it should look like a black and orange checkerboard in the viewport (see Figure 5-10).

With the selection still active, go to Surface Groups in the properties panel (see Figure 5-11) and click the Group Selection button, which will create a new surface group comprised of what will be our white squares. To finish, drag-and-drop the "ER VectorFlat White" material to the material preview located below the lists of available surfaces. The squares of the chessboard are now finished, and you can return to the Scene Editor.

Figure 5-10. Selecting individual polygon faces in the Advanced Modeler


You can rename surface groups by selecting them from the list and typing in a new name in the "Surface name" field.


The final step will create a slight border around the board and give it depth. In the Scene Editor, add a Box primitive to the viewport. By default, it will be placed directly in the center of the checkerboard, which is ideal for our needs.

Click the Scaling Mode icon in the top row of buttons and, while working in the Top viewport, enlarge the box until it is slightly larger than the chessboard. Manual scaling is performed by selecting an object and dragging the cursor to the left, right, up, or down while Scaling Mode is active.

Select the box and set its height, under Sizing in the Properties toolbar, to 0.005. Working in the Front viewport, position the box using the cursor and/or the keyboard arrow keys so that it rests just below the checkerboard, with little or no space between the two. When in place, apply the "ER VectorFlat Black" material to finish the chessboard (see Figure 5-12). Select all with Ctrl-A (Win)/Command-A (Mac) and group with Alt-G (Win)/Command-G (Mac). Rename the new group "board" in the properties panel, so that it is easy to identify in the Hierarchy menu, and save the file.

Figure 5-11. Creating surface groups in the Properties toolbar


Figure 5-12. Example of finished chessboard model


The border could have been added in the Advanced Modeler, but the point of this exercise was to teach you how to use the primitives of the Scene Editor.


Creating the chess pieces

Now that we have the playing field, we need the players. For this exercise, we will be modeling only a pawn and knight; however, after doing so you should have the experience necessary for completing the remaining pieces if you wish to do so. Modeling the pieces will make use of all four editors.

As you should recall, lathe objects are created from vector paths, so the first things we need are profile drawings of our pieces. I have chosen to draw the profiles in Adobe Illustrator and import them into Swift 3D (the original AI document may be downloaded from http://www.rightactionscript.com/fcb/chpt5/chess.ai). The reason I use an external program to do this is that though the Lathe and Extrusion Editors both have basic drawing tools, they simply are not of the same capability level of those found in a dedicated illustration program. Figure 5-13 shows the paths as they appear within Illustrator. Black items will ultimately be lathed objects, and the gray objects will be extrusions.

Figure 5-13. Vector path chess piece profiles drawn in Adobe Illustrator for import


Modeling the pawn

Create a new document as in the chessboard exercise. It is generally good practice in projects like this to model each major element in its own document and later combine them into a single file. This process keeps the working environment from slowing down, which can occur when a large number of model meshes are present.

Import the paths by going to File Import…and navigating to the local copy of the AI file. After being interpreted, the paths will be brought into the Scene Editor as extruded objects.

While the group is still selected, Ungroup with Alt-U (Win)/Command-U (Mac) so that we may work with the paths individually. Select the pieces of the knight and group them (Alt-G/Command-G). In the Properties Toolbar, rename the group "Knight" and check the Hide checkbox. When finished, you should see only the pawn extrusion on the stage, with the Knight grouping visible in the Hierarchy Menu.

Select the pawn and enter the Extrusion Editor. Double-click the outline to select the entire path and copy it. Delete the path, enter the Lathe Editor, and paste the path there. This rather roundabout method is necessary because it is not possible to take an extruded path directly into the Lathe Editor or to import an external file.

If you cannot view the entire path, use the Zoom tool and zoom out until you can. Click and drag a bounding box around the entire path to select it. Using the keyboard arrow keys, move the path to the right until the left edge is aligned with the green vertical line (y-axis). In the Point Properties panel, when the x-coordinate under Properties is at 0, the path is perfectly aligned (see Figure 5-14).

Returning to the Scene Editor, you will find that the pawn model is complete (see Figure 5-15). Apply a white or black glossy material, rename the lathe object "Pawn," and hide it.

If you wanted to create rectangular chess pieces, you could follow the same process. The only difference would be to change some of the Lathe object properties after returning to the Scene Editor. Reducing the Radial Segments to 4 and deactivating Radial Smoothing will result in a pawn with sharp corners, as displayed in Figure 5-16.


Modeling the knight

With the pawn geometry now hidden, select "Knight" in the Hierarchy menu and uncheck the Hide box. Lathe the base of the knight just as with the pawn. Once completed, position it so that the top of the base is just touching the extruded body, as shown in Figure 5-17.

The next step is to set the depth and bevel type for each of the extruded objects. Assign all objects an Outer Round bevel type, with a depth of 0.030. Bevels in Swift 3D are an additive process, which results in an object's geometry becoming thicker when bevels are applied. Because of this, you may need to slightly adjust the pieces of the knight so that they are symmetrical and remain aligned. Use Figure 5-18 as a reference point for setting the extrusion depth, found under Sizing.

Figure 5-14. Vector path for the pawn inside of the Lathe Editor


With the sizing and bevel options set, it now seems that the base might be a little too narrow, giving the piece an unbalanced appearance. To remedy this, select the base and enter the Lathe Editor once more. Select all the points that do not rest on the center axis and move them to the right. This step will increase the diameter of the base without altering the height. The exact amount is up to you, but it should not extend past the outer edges of the knight's body.

Figure 5-15. Lathed pawn model


After applying the material of your choice, the knight model should look similar to Figure 5-19.

Figure 5-16. Pawn model without radial smoothing and reduced radial segmentation





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