Away3D: More with Metasequoia
Two weeks ago, I started playing with Away3D and working on parser for Metasequoia. There were some codes for that (from sleepydesign or libspark) but they didn’t work with the new version. I have been changing the code so it can change the materials/texture of the model once loaded.
FinallyI made it. Click the picture below to see the demo
Click the ‘read more’ below to see the and download the code. It is still in very early version, buggy and some MQO models are not displayed correctly. I am still working on it. But if you want, feel free to use it
Note: The code is only work with the current trunk version of the Away3D version 2.4.0/3.4.0 FP10 (tested on rev. 2039)
Download
Just copy this file to folder Away3D\src\away3d\loaders
Loading model From File
var loader:Loader3D = Metasequoia.load(filename, {scaling:2.0, rotationX: -90});
Loading model From Embedded asset
var mainModel:ObjectContainer3D = Metasequoia.parse(EmbeddedModel, {scaling:2.0, rotationX: -90});
Overwrite Material when loading model
Both loading model (from file or embedded model) will automatically load the texture file. You can overwrite the materials by setting the property materials
var wireMaterial:WireColorMaterial = new WireColorMaterial(0x00aeef, {wirecolor: 0xcccccc}); var loader:Loader3D = Metasequoia.load(filename, {scaling:2.0, rotationX: -90,materials: { hair:wireMaterial, skin:wireMaterial, face:otherTextureMaterial }});
Code above is overwriting the materials named hair, skin, and face. Make sure you know the material name before.
Change the Material after loading
You can change the material after loading the model by using MaterialLibrary.
var targetMaterial:MaterialData = mainModel.materialLibrary.getMaterial("head"); if (targetMaterial != null) { targetMaterial.material = wireMaterial; }
Code above is changing the material ‘head’. All the faces which use this material will be changed to the new material.
Enjoy the code and feel free to ask question
Stay tuned since I am going to work on animation

Abiyasa loves to play and design game, especially designing the character and fun game play. His works are inspired by Anime and Japanese games.
No comments yet.