Hey Pawel
if you can't get an mtl file for your obj, then you can always try
overriding your materials with a single material for the entire obj file.
the material property on the Obj parse can be set before it is used on an
obj file. With this in place, all materials encountered in the file use this
material definition. So you can set it to BitmapMaterial, ColorMaterial...
whataver you want
Once an obj file is loaded, the materialLibrary property on the parser or
the returned away3d object hold the names of all materials defined in the
obj format. If you want, you can set the material of each individually by
doing something like:
myObject.materialLibrary.getMaterial("myMaterialName").material = myNew
Material
This approach will preserve multiple materials in an obj loaded file
hth!
Rob
On Fri, Jul 2, 2010 at 11:43 AM, Michael Iv <[email protected]> wrote:
> 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]
>
>
--
Rob Bateman
Flash Development & Consultancy
[email protected]
www.infiniteturtles.co.uk
www.away3d.com