Hey Paweł would it be possible to send over the file that was causing problems so that we can test and upload the patch?
cheers Rob 2010/7/12 Paweł Stanisławczuk <[email protected]> > Hi! > > Thanks for answer, problem is RESOLVED. > > Downloaded the latest version from SN trunk. Problem with > materialLibrary = null on loaded obj disapeared, but there was still > problem with finding the material. > So, I used Ian's code and now everything works fine. > > Should have downloaded the latest version from SVN, so Rob would not > waste time, sorry for that. > Ian, thanks for help, I wouldn't figure out that one. > > Paweł > > On 11 Lip, 16:39, ian pretorius <[email protected]> wrote: > > HI Pawel , Hi Rob > > > > Not sure if this will help but when I posted concerning the > > "myObject.materialLibrary = null" issue I also noted that I had a > > problem with the material names been stored with hidden characters . > > MY OBJ files were also exported with Lightwave. > > > > I fixed this by adding some string manipulation into the > > prepareData method on the Obj class : > > > > <code> > > > > for (var ii:int = 0; ii < trunk.length; ii++) { > > trunk[ii] = > > trunk[ii].split("\n").join("").split("\r").join("").split("\n > > \r").join("") > > > > } > > > > </code> > > > > I added this in after line 57 where trunk value is set > > > > Try see if this resolves your issue? > > > > On 7/10/10, Rob Bateman <[email protected]> wrote: > > > > > > > > > hmm, are you sure you have the right material name strings? sometimes > they > > > are altered in the file on export. > > > > > to check material names, you can switch Away3D into debug mode by > writing: > > > > > Debug.active = true; > > > > > at the top of your class. The trace output window should list all > attributes > > > of the imported obj file, including all material names. > > > > > the myObject.materialLibrary = null has been fixed in a recent revision > > > > > cheers > > > > > Rob > > > > > 2010/7/5 Paweł Stanisławczuk <[email protected]> > > > > >> Hi Rob! > > > > >> I'm setting the material as you are saying, on the Obj parse before it > > >> is used on an > > >> obj file. And everything works fine. > > > > >> Once the obj file is loaded I cannot change the material. > > > > >> This is what I do: > > > > >> private function loadModels(matURL:String):void { > > > > >> objParser = new Obj(); > > >> objParser.material = new BitmapFileMaterial(matURL); // works good, > > >> there is material on loaded obj file > > > > >> loader = new Loader3D(); > > >> loader.addOnSuccess(onSuccess); > > >> loader.loadGeometry("my.obj", objParser); > > > > >> } > > > > >> function onSuccess(event:Event):void { > > > > >> _sceneMesh = loader.handle as Mesh; > > >> _sceneMesh.scale(100); > > >> _sceneMesh.rotationY = 180; > > >> _sceneMesh.ownCanvas = true; //all props work > > >> scene.addChild(_sceneMesh); > > > > >> loader.removeOnSuccess(onSuccess); > > > > >> MonsterDebugger.trace(this, _sceneMesh.material); // > > >> WireColorMaterial (say what? ;) ) > > >> MonsterDebugger.trace(this, _sceneMesh.materialLibrary); //null > > > > >> MonsterDebugger.trace(this, objParser.material); // > > >> BitmapFileMaterial > > >> MonsterDebugger.trace(this, objParser.materialLibrary); // > > >> MaterialLibrary (matFileName = null; mtlLoadRequired = false;, > > >> textureLoadRequired = false; texturePath = null) only these props, > > >> nothing more > > > > >> _sceneMesh.material = new WireframeMaterial(0xff0000); //does > > >> nothing > > >> objParser.material = new WireframeMaterial(0xff0000); //does nothing > > > > >> } > > > > >> I cannot do: > > >> myObject.materialLibrary.getMaterial("myMaterialName").material = > > >> myNew Material > > >> because myObject.materialLibrary = null > > > > >> Also, this is null: > > >> objParser.materialLibrary.getMaterial("myMaterialName") = null > > > > >> I'm using Lightwave as exporter of obj, maybe here is the problem? > > >> maybe my obj are incorrect? > > > > >> Greetz > > >> Paul > > > > >> On 2 Lip, 14:13, Rob Bateman <[email protected]> wrote: > > >> > 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] > > > > > -- > > > Rob Bateman > > > Flash Development & Consultancy > > > > > [email protected] > > >www.infiniteturtles.co.uk > > >www.away3d.com > -- Rob Bateman Flash Development & Consultancy [email protected] www.infiniteturtles.co.uk www.away3d.com
