Let' me explain you.When you export obj with material on it from 3d
modelling program there is additional file being generated that is mtl .It
holds references to materials and textures.If you have one then the texture
will get loaded even automatically.That is the way .obj format works

2010/7/2 Paweł Stanisławczuk <[email protected]>

> Hi!
>
> I'm not using MTL, never did, they are not required. Don't think MTL
> have any connection with my problem.
>
> Paweł
>
>
>
> On 2 Lip, 12:01, Michael Iv <[email protected]> wrote:
> > Do you know that you need to have also MTL file with obj material
> > definitions?
> >
> > Sent from my iPhone
> >
> > On Jul 2, 2010, at 12:49 PM, Paweł Stanisławczuk
> <[email protected]
> >
> >
> >
> > om> wrote:
> > > What is the proper way to apply material on loaded obj model?
> >
> > > Obj loads good, everything works OK. I'm loading material this way:
> >
> > > initO:Object = {useGroups:false};
> > > var obj:Obj = new Obj(initO);
> > > obj.material = new BitmapFileMaterial("res/uv.jpg"); //this is the
> > > only one spot where the material can be applied
> >
> > > loader = new Loader3D();
> > > loader.addOnSuccess(onSuccess);
> > > loader.loadGeometry("res/my.obj", obj);
> >
> > > function onSuccess(event:Event):void {
> >
> > >  mesh = loader.handle as Mesh;
> > >  mesh.scale(100);
> > >  mesh.rotationY = 180;
> >
> > >  scene.addChild(mesh);
> > > }
> >
> > > The only place (AFAIK) to apply material on loaded obj file is the var
> > > obj:Obj parser. I tried to change material:
> >
> > > loader.handle.material = new WireframeMaterial(0xff0000);
> >
> > > But it does nothing.
> >
> > > I tried with:
> > > function onSuccess(event:Event):void {
> > >  initO:Object = {useGroups:true};
> > >  var obj:ObjectContainer3D = (event.target.handle as
> > > ObjectContainer3D);
> > >  mesh = obj.children[0] as Mesh;
> > >  mesh.material = new WireframeMaterial(0xff0000);
> > > }
> >
> > > Nothing.
> >
> > > I also have tried this:
> > > var meshfaces = _sceneMesh.faces;
> > > for each (var i:Face in meshfaces.faces) {
> > >    i.material = new ColorMaterial(0xFF00FF);
> > > }
> >
> > > Still nothing.
> >
> > > I always used:
> >
> > > var _objLoader:Object3DLoader = Obj.load(_resourceURL,
> > > {material:_material, name:"OBJ", scaling:10});
> >
> > > But now as I see its obsolete.
> > > I cannot use AWD because client would like to add models on his own.
> >
> > > Regards
> > > Paweł
>



-- 
Michael Ivanov ,Programmer
Neurotech Solutions Ltd.
Flex|Air |3D|Unity|
www.neurotechresearch.com
http://blog.alladvanced.net
http://www.meetup.com/GO3D-Games-Opensource-3D/
Tel:054-4962254
[email protected]
[email protected]

Reply via email to