thats because the handle of your obj is not a mesh but an ObjectContainer3D
parse the e.loader.handle and loop over children, if child type is Mesh --> 
apply material

Fabrice
On Mar 4, 2011, at 7:44 PM, mika wrote:

> Hi list
> 
> I'm starting with away3d and I find mysel blocked at the beginning og my 
> project.
> 
> I can load an obj, with its associated texture : 
> 
> protected override function _createScene():void 
>         {
>             loader = new Loader3D();
>             loader.addOnSuccess(_onSuccess);
>             
>             loader.loadGeometry("ballon_HiRes_ok1.obj", obj);
>         }
> 
> no problem, if i set another material on load, no problem :
>     
>         protected function _onSuccess(e:Loader3DEvent):void
>         {
>             trace('Finished Loading: ' + e.currentTarget)
>              mesh = loader.handle as Mesh;
>              mesh.scale(25)
>              mesh.y = 0;
>              mesh.bothsides = false
>              mesh.material = _wireMat
>             _view.scene.addChild(mesh);
>         }
>     
> But, if I try to change the material after the obj is added to scene, no 
> success :
> 
>         public function changeMaterial(texture:Bitmap)
>         {
>             var newMat:BitmapMaterial = new BitmapMaterial(texture.bitmapData)
>             obj.material = newMat
>         }
> 
> I have try to access the material like this :
> 
> mesh.materialLibrary.getMaterial("1_uv-test-position.jpg").material = _wireMat
> 
> but without any success.
> 
> Help would be greatly appreciated

Reply via email to