Flash_and_Flex_03_2009

Sound and Animation

Blender to Flash workflow

by Dennis Ippel

3D in Flash has seen a massive popularity surge since the Flash Player 9 release. Despite all the new possibilities there is a lot to do to make it perform well. One way to optimize a 3D Flash experience is by exporting a 3D model straight to ActionScript 3.0.

(Figure 1). This screen consists of the following elements (top to bottom):

What you will learn… • Creating a simple 3D object in Blender • Working with materials and textures in Blender • Using the Sandy 3D Engine for Flash

What you should know… • Basic 3D concepts • Familiar with the Flash interface • Familiar with ActionScript 3.0

• main application menu • 3D view with the default cube • 3D view menu • buttons window

Blender Blender is a free open source program that is available for all operating systems. It has a small installation size and offers a wide range of tools that help you create stunning 3D content. With the Python programming language you can talk to Blender’s API which enables you to create plug-ins. TheBlenderuserinterfaceisabitdifferentfrom Flash and Photoshop and can be intimidating at first. Once you get used to the way it works you’ll appreciate it more and more though. Here’s brief overview a basic overview of how it works. The Blender User Interface When you download Blender from http:// www.blender.org , install it and the launch it for the first time you’ll see the default screen, see

The main application menu is where you can open files, save files, render the scene and change program settings. The 3D view is where you edit the 3D scene. There are several modes for this view which you can access by clicking on the drop down menu next to the Object menu, see (Figure 2). In this article we will only use two of these modes: Edit Mode and Object Mode. The latter affects whole objects and Edit Mode affects the geometry of an object. With the button next to the Mode menu you can access the Viewport Shading menu, see (Figure 3). Here you can select the type of interactive shading that is applied to the viewport. We will use Shaded and Textured when we create a material for our object.

Level of difficulty

L oading and parsing XML files is the most commonway inwhich 3Dobjects are loaded into 3D Flash engines like Sandy, Away3D or Papervision3D. The structure of these XML files is described in the COLLADA ( COLLAborative Design Activity ) specification. Because a lot of information is captured in these XML documents they tend to be very big. This has a few disadvantages that have an impact on the performance of the 3D application: • a fairly large XML needs to be loaded into the application • all the nodes in the XML DOM have to be traversed • the 3D object information needs to be decompressed • the vertex data needs to be translated into the format used by the 3D engine. So if your 3D model has a lot of vertices and information about texture coordinates it will take some time to display the object on the screen. What if we can skip all these steps and export the 3D model to an ActionScript 3.0 class? Let’s take a look at a 3D content creation suite that allows you to do this.

Listing 1. Setting up the 3D scene

private function setup3DScene() : void {

var camera : Camera3D = new Camera3D( 550, 400 ); camera.x = 0; camera.y = 0; camera.z = 150; camera.lookAt( 0, 0, 0 ); scene = new Scene3D( "scene", this , camera, new Group( "rootGroup" ) );

}

03/2009 (5)

84

Made with FlippingBook HTML5