Home

timknip edited this page Sep 13, 2010 · 37 revisions
Clone this wiki locally

Welcome to the asblender wiki!

ASBlender is an Actionscript 3 library to read Blender .blend files.

See blender-file-format for an explanation of the .blend format.

The .blend format contains all C-structures used, which are defined in the so called DNA. This way .blend files are fully backward compatible.
Check out the DNA of a Blender 2.48 .blend.

ASBlender simply maps these structures to AS3 Object’s. This means there are no “blender” classes like “BlenderScene” in this library. Everything is an Object, Array, Number, int or String.
This means that using this library requires some basic knowledge on the inner workings of Blender. So the learning curve can be rather steep. Its up to you to do something with the data. ASBlender simply provides you the .blend data.

But if your goal is to import simple .blend’s containing a single mesh, the examples below should get you going pretty fast.

See:

Hello World:

  • First you need the create a ByteArray by loading a .blend file or by using [Embed].
  • Create a BlendFile object: var blend:BlendFile = new BlendFile();
  • And read it: blend.read( theByteArray );

All scenes in the .blend are read by default, you can access the scenes contained in the .blend thru var scenes:Array = blend.scenes.
Blender can contain more then one Scene, but its likely there’s only one.

Of course you can access other structures like IpoCurve, Panel, Lamp, etc. too. Use for example var curves:Array = blend.readType(theByteArray, "IpoCurve"); to read all curves.

Note that I’m still learning how all these structures stick together. More example code will follow as my knowledge increases.

Have fun!
Tim