> So, how would I null out the material at face level? I assume if face > material is nulled, if I assign mesh.material it will work... There are two ways in Away to assign a material top a mesh. In most cases when a mesh uses one single material, the generators or importers do set the material at Mesh level. Mesh.material = somematerial;
but a mesh may hold more than one. In this case, even if only one is define, the code of parser will assign at face level. Face.material = some material; This is the case with Obj. They are also rendered by default, setting a Mesh.material doesn't overwrite the faces material(s) You can also access the materialLibrary dictionary like materialLibrary.getMaterial("name"); look at doc + Loader3D/AsbtractParser for more details and replace, alter the material directly into the dictionary. There are some discussion going on at the away garage about that baby, me being hostile to this system because I do not find it very usefull and its annoying me most of the time more than helping me. Many are finding it handy tho. That's mostly due to the way I do use Away. Most of the time using it more as generator/editor than a player. In my own code, I have simply overrided it. To get back to your question. if you do want to clear or alter at face level. you can access the mesh faces with Mesh.faces[index].material. so if you know you have only one per mesh, altering the face[0].material would alter the whole mesh. if you want to set another one, you need to loop over the faces array and set per face. or if you need to do it more time, loop once and nullify all Faces material property, and apply the material at Mesh level. This applies to all meshes. Fabrice On Mar 3, 2010, at 8:22 AM, mwk wrote: > Hi Fabrice, can you explain this comment a bit more? > >> access the materiaLiibrary or nullify thematerialat face level and apply. >> materialLibrary.getMaterial("name"); > > I also need to change the material on a Mesh I read via Obj: > material = new BitmapFileMaterial("test.jpg"); > var objParser:Obj = new Obj({material:material}); > etc. > But I need to assign a new texture at run time (can't just change > the .obj file). Even with your comment above I can't figure it out > (sorry!) > > So, how would I null out the material at face level? I assume if face > material is nulled, if I assign mesh.material it will work... > > And what do you mean about doing it through the materialLibrary? The > material library has a single MaterialData in it that just shows > ambientColor and diffuseColor as 0. I tried setting that key to a new > material but it had no effect. I'm think I'm not understanding > something about how materials work. > > Thanks! > > On Feb 4, 12:19 pm, Fabrice3D <fabric...@gmail.com> wrote: >> access the materiaLiibrary or nullify thematerialat face level and apply. >> materialLibrary.getMaterial("name"); >> >> but since its anObjfile, you also can alter by hand theobjfile, remove the >> "mtllib mtlname.mtl" line at top file and >> remove all the "usemtl matname" most of the time located between VT and F >> tags. in this case your code will work. >> >> Fabrice >> >> On Feb 4, 2010, at 9:02 PM, Flo711 wrote: >> >>> Hello, >> >>> I have loaded a mesh by doing : >> >>> object3DLoader =Obj.load("model.obj", {material:bitmapMaterial, >>> name:"crist", scaling:30, x:0, y:0, z:0, loadersize:200}); >> >>> object3DLoader.addOnSuccess(onLoaderSuccess); >> >>> private function onLoaderSuccess(e:Loader3DEvent):void { >> >>> if(e.loader.handle is Mesh){ >> >>> mesh = e.loader.handle as Mesh; >>> mesh.material= new ColorMaterial(); >> >>> } else { >> >>> } >>> } >> >>> But I can't figure how o acces thematerialto change it within the >>> function onLoaderSuccess. >>> when I trace(mesh.material) I get null before doing : mesh.material= >>> new ColorMaterial();