Hello
Here is my problem I have a model loaded and I want to change some textures by clicking on images.
I can change the texture while loading but not after.
How can I access the material library of an object loaded?
Thanks
How to change textureSoftware: Away3D 4.x |
||
yannliep, Newbie
Posted: 23 July 2012 03:24 PM Total Posts: 6 Hello Here is my problem I have a model loaded and I want to change some textures by clicking on images. I can change the texture while loading but not after. How can I access the material library of an object loaded? Thanks |
||
|
||
Richard Olsson, Administrator
Posted: 24 July 2012 08:05 AM Total Posts: 1192 [ # 2 ] Shegl’s suggestion is correct provided that you have access to the mesh (called object in Shegl’s example.) If you’re using Loader3D to load your assets, I would suggest that you listen for MESH_COMPLETE and save the mesh to a private class variable (or any other persistent state) so that you can access it later, or alternatively do the same for the material. I would also suggest that you dont use the “as” casting keyword, but instead use regular casting which is faster and in this case has more or less the exact same side-effects should the material not be a texture material.
TextureMaterial(mesh.material).texture = myNewTexture;
|
||
|
||
Richard Olsson, Administrator
Posted: 24 July 2012 08:58 AM Total Posts: 1192 [ # 4 ] Yes, that sounds like the following bug. I’ll try to solve it today. |
||
|
||
Richard Olsson, Administrator
Posted: 25 July 2012 10:16 AM Total Posts: 1192 [ # 6 ] I see. So all materials were actually coming in from the parser? It sounded as if you were saying that only on material was being returned by the parser. In any case, the issue that could have been causing such problems (the link to which was mentioned above) has now been fixed. |