Hi All ,

I was searching on replacing materials for loaded obj models ,I didnt
find much and had a look into the API again to see how it all works.

I found a materialLibrary property in Object3D and the comments above
the declaration states it is populated via Obj loaders etc.. but this
never happens , it traces as null on all files I tested, SO I set the
reference now in Loader3D notifySuccess method :

"_result.materialLibrary = materialLibrary"

and added it in the clone method of Object3D as well :

"object3D.materialLibrary = materialLibrary"

This worked well , but then I had problems calling  "getMaterial"
method on MaterialLibrary class and found another weird problem..

when "addMaterial" is called in MaterialLibrary , the "name"
argument's value is coming through with hidden "\n"  characters.

I fixed this now 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>

So now its all working and im able to call getMaterial on the
MaterialLibrary  of all models to return the MaterialData object and
set its material propery to any new material.

IM using CS4 , Away3D fp10 branch and models are exported via
lightwave .. here are the obj and mtl files..

http://www.prezencenewmedia.com/ian/away3d/new_08split.obj
http://www.prezencenewmedia.com/ian/away3d/new_08split.mtl

the only other means I found to access the bitmaps of the loaded
models was to loop Object3D.geometry.materialDictionary but this was
not an as good a solution as having materialLibrary property working
which seems to be the logical means to do it.

Why is the materialLibrary property on the Object3D never set? Is this
a bug?

Thanks
Ian



I










Reply via email to