Importing 3D Formats into Away3D


Away3D 3.6 Cookbook

Away3D 3.6 Cookbook

Over 80 practical recipes for creating stunning graphics and effects with the fascinating Away3D engine

        Read more about this book      

(For more resources on this subject, see here.)


The Away3D library contains a large set of 3D geometric primitives such as Cube, Sphere, Plane, and many more. Nevertheless, when we think of developing breathtaking and cutting edge 3D applications, there is really no way to get it done without using more sophisticated models than just basic primitives. Therefore, we need to use external 3D modeling programs such as Autodesk 3DsMax and Maya, or Blender to create complex models. The Power of Away3D is that it allows us to import a wide range of 3D formats for static meshes as well as for animations.

Besides the models, the not less important part of the 3D world is textures. They are critical in making the model look cool and influencing the ultimate user experience.

In this article, you will learn essential techniques to import different 3D formats into Away3D.

Exporting models from 3DsMax/Maya/Blender

You can export the following modeling formats from 3D programs: (Wavefront), Obj, DAE (Collada), 3ds, Ase (ASCII), MD2, Kmz, 3DsMax, and Maya can export natively Obj, DAE, 3ds, and ASCII. One of the favorite 3D formats of Away3D developers is DAE (Collada), although it is not the best in terms of performance because the file is basically an XML which becomes slow to parse when containing a lot of data. The problem is that although 3DsMax and Maya have got a built-in Collada exporter, the models from the output do not work in Away3D. The work around is to use open source Collada exporters such as ColladaMax/ColladaMaya, OpenCollada. The only difference between these two is the software versions support.

Away3D 3.6 Cookbook

Getting ready

Go to and download the OpenCollada plugin for the appropriate software (3DsMax or Maya).

Go to and download the ColladaMax or colladamaya plugin.

Follow the instructions of the installation dialog of the plugin. The plugin will get installed automatically in the 3dsMax/Maya plugins directory (taking into account that the software was installed into the default path).

How to do it...

  • 3DsMax:

Here is how to export Collada using OpenCollada plugin in 3DsMax2011.

In order to export Collada (DAE) from 3DsMax, you should do the following:

  1. In 3DsMax, go to File and click on Export or Export Selected (target model selected).
  2. Select the OpenCOLLADA(*.DAE) format from the formats drop-down list.

    Away3D 3.6 Cookbook

  • ColladaMax export settings: (Currently 3DsMax 2009 and lower)

ColladaMax export settings are almost the same as those of OpenCollada. The only difference you can see in the exporting interface is the lack of Copy Images and Export user defined properties checkboxes.

Away3D 3.6 Cookbook

Select the checkboxes as is shown in the previous screenshot.

Relative paths: Makes sure the texture paths are relative.

Normals: Exporting object's normals.

Copy Images: Is optional. If we select this option, the exporter outputs a folder with related textures into the same directory as the exported object.

Triangulate: In case some parts of the mesh consist of more than three angled polygons, they get triangulated.

Animation settings:

Away3D supports bones animations from external assets. If you set bones animation and wish to export it, then check the Sample animation and set the begin and end frame for animation span that you want to export from the 3DsMax animation timeline.


For showcase purposes, you can download a 30-day trial version of Autodesk Maya 2011. The installation process in Maya is slightly different:

  1. Open Maya.
  2. Go to top menu bar and select Window.
  3. In the drop-down list, select Settings/Preferences, in the new drop-down list, select Plug-in manager. Now you should see the Plug-in Manager interface:

    Away3D 3.6 Cookbook

  4. Now click on the Browse button and navigate to the directory where you extracted the OpenCollada ZIP archive. Select the COLLADAMaya.mll file and open it.

    Away3D 3.6 Cookbook

  5. Now you should see the OpenCollada plugin under the Other Registered Plugins category.
  6. Check the AutoLoad checkbox if you wish for the plugin to be loaded automatically the next time you start the program.
  7. After your model is ready for export, click on File | Export All or Export selected. The export settings for ColladaMaya are the same as for 3DsMax.

How it works...

The Collada file is just another XML but with a different format name (.dae). When exporting a model in a Collada format, the exporter writes into the XML nodes tree all essential data describing the model structure as well as animation data when one exports bone-based animated models.

When deploying your DAE models to the web hosting directory, don't forget to change the .DAE extension to .XML. Forgetting will result in the file not being able to load because .DAE extension is ignored by most servers by default.

There's more...

Besides the Collada, you can also export OBJ, 3Ds, and ASE. Fortunately, for exporting these formats, you don't need any third party plugins but only those already located in the software.

Free programs such as Blender also serve as an alternative to expansive commercial software such as Maya, or 3DsMax Blender comes with already built-in Collada exporter. Actually, it has two such exporters. At the time of this writing, these are 1.3 and 1.4. You should use 1.4 as 1.3 seems to output corrupted files that are not parsed in Away3D. The export process looks exactly like the one for 3dsMax.

Select your model. Go to File, then Export. In the drop-down list of different formats, select Collada 1.4. The following interface opens:

Away3D 3.6 Cookbook

Select Triangles, Only Export Selection (if you wish to export only selected object), and Sample Animation. Set exporting destination path and click on Export and close.

You are done.



        Read more about this book      

(For more resources on this subject, see here.)

Exporting models from 3DsMax to ActionScript class

The biggest disadvantage of using external model formats is that they consume precious time while being loaded and parsed. There is an alternative way to export meshes that you should be aware of and this is exporting directly into the ActionScript class. Apparently, the advantage is obvious as we don't need to load and parse the XML text of Collada, .3ds, or .obj formats. That saves us a lot of initiation time. So basically you would ask why not always use the ActionScript export. Well, there is one noticeable limitation to the current exporter—it doesn't export animations. Also if your application requires loading of multiple unique models, AS3 would not be the best solution. In such a case all the AS3 models are compiled directly into the program causing an unnecessary size increase of the whole application. So for the scenario like this, the external loading could be a better solution.

Getting ready

The script was written by Shirotokoro (also developer of WOW Physics engine) and can be downloaded at:

After the download, unzip the content into any easy to remember place as you will need to target the script file from inside 3DsMax.

How to do it...

Open 3DsMax, in the side toolbar, open the Utilities dialog and select the MAXScript category:

Away3D 3.6 Cookbook

Next click on the Run Script button and navigate to the directory where you saved the exporter files. Select the file from the script3ds max folder and open it. Now you can see it in the Utilities drop-down dialog. In order to activate it, click the drop-down list and select the AS3GeomClassExport:

Away3D 3.6 Cookbook

Now we can see the exporter's interface opened:

Away3D 3.6 Cookbook

Let's see the options we have:

  • Package: Defines class package namespace
  • ClassName: Add name for your ActionScript class
  • Engine: You should select Away3D
  • Scale: Relative scaling of the Mesh object
  • Swap face normal: Check this if you want to invert the faces
  • Round vertex coord: Rounding vertex coordinates floating number
  • Click on the Export Class button and you are done

Inside Away3D, you can insert the model you exported from 3DsMax by instantiating the class. In the following example, we create a new instance of the MyCube() model class, which we previously exported from 3DsMax:

private function initGeometry():void{
var cb:MyCube=new MyCube();
cb.material=new BitmapFileMaterial("material1.jpg");


The applied texture wraps the model according to the UV mapping from 3DsMax.

How it works...

All the magic happens with the help of the MaxScript, which generates an Away3d class that extends the mesh super class. The exported class contains vertex coordinates, UV mapping, and faces indices data—all this is already in ActionScript with no need to load and parse external data.

Preparing MD2 models for Away3D in MilkShape

The MD2 format was introduced by ID software in 1997 and was initially used to create animated models for Quake 2. With time, many other game engines started to use this format. MD2 is a compact binary format that is easy to use for controlling character animation. MD2 is probably the best choice at the time of writing when you need to import animation into Away3D. Due to its binary nature, MD2 is loaded and parsed much faster than the Collada format.

Getting ready

Although some of the 3D packages such as Blender contain a native MD2 exporter, I suggest you use a program named MilkShape by ChumBaumSoft.

MilkShape is an easy to use multi-format importing, editing, and animating software that is really the perfect choice to create animated models for Away3D:

  1. Go to and download MilkShape 3D version that is given free for 60 days trial. Install it.
  2. In the following example, as well as in consequential ones, we are going to use great low poly models of characters from Valve's "Team Fortress". These were modeled by a talented 3D artist, Tom Tallian, and are free to download from his web page at

How to do it...

Initially, our spy is in .max format. In order to import it into MilkShape, we should convert it to one of MilkShape's recognizable formats. In 3DsMax, we export it as .3ds and it is ready for work in MilkShape.

Now let's open MilkShape. In the top menu bar, go to File | Import. From the multitude of the formats you can see in the drop-down menu, select Autodesk 3Ds.

If we try to export our model as it is to MD2, we would get the following notification:

Away3D 3.6 Cookbook

The problem is that MD2 requires bones to be attached to the vertices in order to compile.

Even if you don't need a rigged character but just a static MD2 model, you still have to define at least one joint and attach it to the mesh's vertices.

On the right side of the toolbar, click on the Joint button:

Away3D 3.6 Cookbook

Create a joint in the region of a model's head. Now click on the Select button and in the selection type menu, click on the Vertex button:

Away3D 3.6 Cookbook

Switch to the Joints panel, double-click on the joint (it is named joint1 by default), then holding the SHIFT key, select all the meshes of the model. Now click on the Assign button and the model is ready for MD2 export:

Away3D 3.6 Cookbook

Go to File | Export. In the drop-down list, select Quake 2 MD2. You are done.

How it works...

As you can see, the MD2 export forces us to apply joints to our mesh. It is enough to apply a single joint to the whole mesh for the sake of a static model export which doesn't require animation. There is no need to worry about the possibility of wasted file size in this case, as applying the joint without setting actual key frame animation sequences doesn't make our file "heavy".

There's more...

Being done with static MD2 export, let's go and rig our character so that it can be animated. Believe me it is fun.

Before we begin, let's first scale up our joints a little so that it is going to be more convenient to control them. Go to File | Preferences. On the following screenshot, increase the number of the Joint Size to whatever value you think looks good for your joint circles:

Away3D 3.6 Cookbook

As you now know how to set joints, let's create a full skeleton for our spy. To create an intact complete skeleton, we need to follow a certain sequence:

Away3D 3.6 Cookbook

As you can see from the creation stream screenshot in the previous image, the first point of the skeleton is located in the basin area of the body. The workflow is as follows:

  1. Create a joint in the basin area.
  2. Then continue creating additional joints downwards for the left leg.
  3. Then once again select the basin joint and continue to create joints for the right leg
  4. .
  5. Now when we are done with the legs, let's go up. Select the basin joint and then create the next two—first in the neck region and the second in the head center.
  6. Now all that is left is to do the hands. Select neck joint, and create sequence of additional joints along the right hand down. Then again select the neck joint and return over the same routine for the left hand.
  7. Now adjust the joint in such a way that each joint corresponds to a body's anatomical joints and also check that the bones are centered to the surrounding mesh.

In order to animate your model, click on the Anim button in the bottom-right corner of the program and you will see the timeline become active. Each animated movement should register with a key frame, otherwise the animation data would be lost. After defining the position of a joint, use Ctrl + K to set a key frame for that transformation. Proceed with this routine till you get the desired result.

The last part before we can export it is to define the animation sequence names. Unless you wish to have only one single animation type of your model, you need to give names to different sequences of the animation in order to use them later in Away3D to access actual animations.

Defining and naming of animation sequences is made outside the MilkShape program. You need to create a file with the .QC extension having the following structure:

// Sample MD2 config, copy into export directory
$modelname spyAnimatedReady.md2
$origin 0.0 0.0 0.0

// skins
$skinwidth 128
$skinheight 128
$skin skin.pcx
$skin pain.pcx

// sequences
$sequence stand 1 3
$sequence walk 4 84

We are interested in the last block. There we actually define the animations name, as well as a start and end frame of the given sequence. Notice that it is critical to have a single space gap between sequence definition {name} {start frame} {endframe}.

After defining your sequences, save the file to the same directory where you export the MD2 file.

Now export the MD2 file as we have done with the static model and now it is ready for Away3D.


In this article we took a look at importing various 3D formats like 3DsMax/Maya/Blender into Away3D.

Further resources on this subject:

You've been reading an excerpt of:

Away3D 3.6 Cookbook

Explore Title