awd, doesn't support materialLibrary.
onSuccess just access the Object3D
which is correct in your code as event.loader.handle
you need then to check if its a type ObjectContainer3D or Mesh
a single object is returned in awd as Mesh while more than 1 as
ObjectContainer3D
if its a Mesh, apply as mesh else access its children
if you have more write a recursive routine like this: (which I just did for you
:)) )
onSuccess
parse(loader.handle);
private function parse(object3d:Object3D):void
{
if(object3d is ObjectContainer3D){
var obj:ObjectContainer3D = (object3d as
ObjectContainer3D);
for(var i:int =0;i<obj.children.length;++i){
if(obj.children[i] is
ObjectContainer3D){
parse(obj.children[i]);
} else if(obj.children[i] is Mesh){
applyMyCustomMaterial(obj.children[i] as Mesh);
}
}
} else if(object3d is Mesh){
applyMyCustomMaterial(object3d as Mesh);
}
}
in the applyMyCustomMaterial(m.Mesh)
switch(m.name){
case "bla":
m.material = myBlaMaterial;
break;
Fabrice
On May 31, 2010, at 6:38 PM, KarmaKat wrote:
> My code was a little jumbled there with my adieu mixed in...
> SInce I can't seem to edit that post here is the code again a little
> cleaner:
>
> public function loadMyAWD ():void {
>
> var loaderAWD:Loader3D = new Loader3D();
>
> loaderAWD.addEventListener(Loader3DEvent.LOAD_SUCCESS, onSuccess);
>
> var awd:AWData = new AWData();
>
> loaderAWD.loadGeometry("assets/belizeMesh.awd", awd);
>
> }
>
> public function onSuccess(e:Loader3DEvent):void {
>
> var myObject3D:Object3D = e.loader.handle;
>
> var myMesh:Mesh = myObject3D as Mesh;
>
> trace ( myMesh.material);
>
> for each (var materialData:MaterialData in
> myObject3D.materialLibrary)
> {
>
> materialData.material = belizeMainlandMat;
>
> }
>
> for each (var i:Face in myMesh.faces) {
> i.material= belizeMainlandMat;
> }
>
> myMesh.material = belizeMainlandMat;
>
> this.view.scene.addChild(myMesh);
> trace (myMesh.material);
> }