Hi adamac,

Awesome work!!!
Here's how I embedded my texture to make a single SWF:

1 -- I used prefab to create the BSP project files for my level.

2 -- In the "MyBSPProject.as" (default name) under the lines:

                [Embed(source="myBSPTree.awd", 
mimeType="application/octet-stream")]
                private var BSPFile:Class;

I added:

                [Embed(source = "images/aw_0.png")]
                private var PNGFile:Class;

That was the default texture name that got packaged in when I did my
light baking/BSP export.

3 -- I make sure to have Cast and CentralMaterialLibrary imported:

        import away3d.core.utils.Cast;
        import away3d.loaders.utils.CentralMaterialLibrary;

4 -- I create a private var _mat as a BitmapMaterial:

                private var _mat:BitmapMaterial;

5 -- In the initAway3D() function, after created the BSP tree, I
create the new material from the embedded bitmap, get a reference of
the old material using CentralMaterialLibrary, and then replace the
dud with my fresh new material!

                        _mat = new BitmapMaterial(Cast.bitmap(new PNGFile()));
                        _mat.smooth = false;

                        
_tree.replaceMaterial(CentralMaterialLibrary.getMaterial("aw_0"),
_mat); // "aw_0" was the default name PreFab gave my object.

When you compile, you only have one SWF with no other external files
and you don't need to embed a separate SWF with movieclips and images
and whatnot. Just repeat the steps if your level consists of numerous
objects, making sure to invoke CentralMaterialLibrary for each
different object and replacing with a different material.


Reply via email to