How to change texture

Software: 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

   

Shegl, Sr. Member
Posted: 23 July 2012 06:55 PM   Total Posts: 134   [ # 1 ]

(object.material as TextureMaterial).texture

   

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
   

yannliep, Newbie
Posted: 24 July 2012 08:56 AM   Total Posts: 6   [ # 3 ]

Thanks

But the problem is when I’m listing all the materials there’s only one material even for mesh with another material. I think it may be the bug from the   collada parser.

   

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.
https://github.com/away3d/away3d-core-fp11/issues/358

   

yannliep, Newbie
Posted: 25 July 2012 06:56 AM   Total Posts: 6   [ # 5 ]

I finally found it, the correct texture is on the submeshes of the mesh so i changed the submeshes texture and it worked

   

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.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X