Eureka!

I looked around the core classes some more and found out how you can access the 
materials without knowing their names. This should be especially useful when 
you are using objects which you know only contain one material:


for each (var materialData:MaterialData in object3D.materialLibrary) {
        
        trace (materialData.name);
        trace (materialData.material);
        
}


The MaterialData class is "away3d.loaders.data.MaterialData"

I don't know why I never thought to try a "for each" loop.




On Mon, 04 Jan 2010 14:07:48 -0800, Stephen Hopkins <[email protected]> 
wrote:

I found this kind of annoying. Heres a dirty fix. What i did in maya,
was assign all of my materials a new lambert called "lam". I then used
that id to change the material for the shape group. You can also look
up your material id name in the dae file. it will look like this. The
other thing you could do is just keep track of all the material id's
your model uses and put them in a class as a string. So if you have a
vehicle with multiple pieces, assign each piece a different material,
the type doesn't matter, just keep their id unique like wheelMaterial,
tireMaterial. Store their names in  your class that makes the
object3d.

<material id="lam" name="lam">
      <instance_effect url="#lam-fx"/>
</material>

use the id/name attribute

On Jan 4, 8:41 am, "Joshua Granick" <[email protected]> wrote:
I have a series of models which each use a single UV for their materials. 
During parsing, I can pass a single material with the init parameters and it 
loads great.

I want to be able to swap out the texture again after I have already created an 
instance of one of my models. The only access I have to the materials of my 
model is the MaterialLibrary object, which operates with name/value pairs. I 
have no idea what name I would be looking for, and there seems to be no way to 
simply list all of the materials or to get the names.

How do I swap it out with a single material, like I would do during parsing?

Reply via email to