As we saw in Chapter 2, Creating and Displaying Primitives, 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 flexibility, Away3D can load and display 3D models created by external 3D modeling applications.
3D modeling applications are specifically 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 file that can be used with Away3D will be covered for the following 3D modeling applications:
Actually creating a model in these 3D modeling applications is outside the scope of this book. 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.
This chapter covers the following:
Away3D includes classes that can load a wide range of 3D model file 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.
Format |
Extension |
Static |
Animated |
Away3D Class |
---|---|---|---|---|
DAE |
* |
* |
| |
MD2 |
* |
* |
| |
ASE |
* |
| ||
AWD |
* |
| ||
KMZ |
* |
| ||
3DS |
* |
| ||
OBJ |
* |
| ||
AS |
* |
* |
The following instructions show you how to export a Collada file 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.
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 difficult to find. You should be able to find a copy if you search the Internet for Autodesk3dsMax2009_ENU_TrialDownload.exe
, which is the name of file that will install the trial version of 3ds Max 9.
MAX
file you wish to open and click on the Open button.MAX
file was located.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/.
Like Milkshape, Sketch-up does not support exporting animated Collada files. Sketch-Up can be downloaded for free from http://sketchup.google.com/.
SKP
file you wish to open and click on the Open button.DAE
file.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 file.
BLEND
file you wish to open and click on the Open button.BLEND
file was located in the Export File textbox.Despite being free and open standard, exporting to a Collada file 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 file that Away3D could read. At best Away3D would display a static mesh, and at worst it would throw an exception when reading the DAE file. 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 file, this is no guarantee that the resulting file can be read correctly by Away3D.