Take Flash to the next dimension by creating detailed, animated, and interactive 3D worlds with Away3D
- Create stunning 3D environments with highly detailed textures
- Animate and transform all types of 3D objects, including 3D Text
- Eliminate the need for expensive hardware with proven Away3D optimization techniques, without compromising on visual appeal
- Written in a practical and illustrative style, which will appeal to Away3D beginners and Flash developers alike
Models and Animations
It is possible to create a 3D object from the ground up using basic elements like vertices, triangle faces, Sprite3D objects, and segments. However, creating each element manually in code is not practical for more complex models. While the classes from the away3d.primitives package offer a solution by providing a way to quickly create some standard shapes, advanced applications will need to display more complex shapes. For those situations where these standard primitive shapes do not provide enough fexibility, Away3D can load and display 3D models created by external 3D modeling applications.
3D modeling applications are specifcally designed to provide a visual environment in which 3D models can be manipulated. It is certainly much more convenient to create or edit a 3D mesh in one of these applications than it is to build up a mesh in code using ActionScript.
Away3D can directly load a wide range of 3D formats. The process of exporting a 3D mesh into a fle that can be used with Away3D will be covered for the following 3D modeling applications:
- 3ds Max: A popular commercial modeling, animation, and rendering application which runs on Windows.
- Blender: A free and open source modeling application, which is available on a number of platforms, including Windows, Linux, and MacOS.
- Milkshape: A commercial low-polygon modeler which runs on Windows that was originally designed for the game Half-Life.
- Sketch-up: A free 3D modeling application provided by Google. A commercial version is also available that includes a number of additional features. Sketch-up runs on Windows and MacOS.
Actually creating a model in these 3D modeling applications is outside the scope of this article. However, 3D models are provided that can be loaded and then exported from these applications, which will allow you run through the procedure without having to know how to make a 3D model from scratch.
3D formats supported by Away3D
Away3D includes classes that can load a wide range of 3D model fle formats. All the supported formats can be used to load a static 3D model, while a smaller number can be used to load animated models. The following table lists the 3D model formats supported by Away3D, their common extensions, whether they can load animated 3D models, and the Away3D class that is used to load and parse them.
Exporting 3D models
The following instructions show you how to export a Collada fle from a number of different 3D modeling applications. Collada is an open, XML-based format that has been designed to provide a way to exchange data between 3D applications. Away3D supports loading both static and animated 3D models from the Collada format.
Exporting from 3ds Max
3ds Max is a commercial 3D modeling application. At the time of writing, the latest version of the ColladaMax plugin, which is the plugin that we will use to export the 3D model, was 3.05C. This version supports 3ds Max 2008, 3ds Max 9, 3ds Max 8 SP3, or 3ds Max 7 SP1. Note that this version does not support 3ds Max 2010 or 2011.
A trial version of 3ds Max 9 is available, although it can be diffcult to fnd. You should be able to fnd a copy if you search the Internet for Autodesk3dsMax2009_ENU_TrialDownload.exe, which is the name of fle that will install the trial version of 3ds Max 9.
- Download and install the ColladaMax plugin from http://sourceforge.net/projects/colladamaya/files/.
- Open 3ds Max.
- Click File | Open. Select the MAX file you wish to open and click on the Open button.
- Click File | Export from within 3ds Max.
- Select COLLADA (*.DAE) from the Save as type drop-down list.
- Select the same directory where the original MAX fle was located.
- Type a fle name for the exported fle in the File name textbox, and click on the Save button.
- In the ColladaMax Export dialog box make sure the following checkboxes are enabled:
- Relative Paths
- If you want to export animations, enable the Enable export checkbox.
- If you want to export a specifc range of frames, enable the Sample animation checkbox and enter the required values in the Start and End textboxes.
- Click on the OK button to export the fle.
Exporting from MilkShape
The Collada exporter supplied with MilkShape does not export animations. So even if the MilkShape MS3D file we are loading contains an animated model, the exported Collada DAE file will be a static mesh. A trial version of MilkShape can be downloaded and installed from its website at http://chumbalum.swissquake.ch/.
- Click File | Open. Select the MS3D file you wish to open and click on the Open button.
- Click File | Export | COLLADA….
- Select the same directory where the original MS3D file was located.
- Type a flename for the exported fle in the File name textbox and click the Save button.
Exporting from Sketch-Up
Like Milkshape, Sketch-up does not support exporting animated Collada fles. Sketch-Up can be downloaded for free from http://sketchup.google.com/.
- Click File | Open. Select the SKP file you wish to open and click on the Open button.
- Click File | Export | 3D Model….
- Select Collada File (*.dae) from the Export type combobox.
- Select an appropriate directory, and type a filename for the exported file in the File name textbox.
- Click on the Options… button.
- Make sure the Triangulate All Faces checkbox is enabled.
- If the Export Texture Maps option is enabled, Sketch-Up will export the textures along with the DAE file.
- Click on the OK button to save the options.
- Click on the Export button to export the file.
Exporting from Blender
The latest version of the Collada exporter for Blender, which is version 0.3.162 at the time of writing, does support exporting animations. However, in most cases Away3D will not load these animations correctly. It is recommended that only static meshes be exported from Blender to a Collada fle.
- Click File | Open…. Select the BLEND file you wish to open and click on the Open button.
- Click File | Export | COLLADA1.4 (*.dae) ….
- Type a flename for the exported fle in the directory where the original BLEND fle was located in the Export File textbox.
- Make sure the Triangles and Use Relative Paths buttons are pressed.
- Click on the Export and Close button.
A note about the Collada exporters
Despite being free and open standard, exporting to a Collada fle that can be correctly parsed by Away3D can be a hit-and-miss affair. The Collada exporters for 3ds Max are a good example. During testing, neither the built-in Collada exporter included with 3ds Max, nor the third-party OpenCollada exporter from http://opencollada.org (version 1.2.5 was the latest version at the time of writing) would export an animated Collada fle that Away3D could read. At best Away3D would display a static mesh, and at worst it would throw an exception when reading the DAE fle. Likewise, neither of the Collada exporters that come with Blender (which was at version 2.49b at the time of writing) would consistently export an animated Collada mesh that was compatible with Away3D.
It is important to be aware that just because a 3D modeling application says that it can export to a Collada fle, this is no guarantee that the resulting fle can be read correctly by Away3D.