A couple ideas ...

If you want to apply one material to everything (like if you have a UV map), you can pass 
it in as "material" in the init properties.

If you want to iterate through all of the materials, you can run a for loop 
over the material library:


for each (var material:IMaterial in myObject.materialLibrary) {
        
        trace (material);
        
}


In Maya, at least, objects have a default lambert material applied which is a 
solid color. When I load Collada models into Away3D, they can come through grey 
because this is the correct material for the model.

You can try passing { material: new WireColorMaterial () } as the init 
properties, you can try embedding instead of loading (using FlashDevelop or 
FlexBuilder) or you can try iterating over the material library after it is 
loaded. These are all methods that might help you troubleshoot and work with 
your model. I haven't tried passing material in as an object, but you can 
always give it a try with one of your material names to see if it works


On Wed, 20 Jan 2010 07:27:03 -0800, bastien merindol (ASF) 
<[email protected]> wrote:

Hi there, long post beneath, take a breath

I had a simple dae file with 3 nodes, and this one I could load its
geometry with only
loader3d = Collada.load("thing.dae", { scaling:1, autoLoadTextures:false} );
and then on load success, associate any sub-mesh to a correct away
material this way :
((event.loader.handle).getChildByName("ID25") as Mesh).material = material1;
or even let it alone, and the engine would pick up a random
wirecolormaterial for every object.

(actually the autoLoadTextures never worked there so I used to let it off)

#

Here is the problem part :)
I now have a much bigger collada file with many nodes & subnodes, and
trying to load it the same way leads to every mesh having a grey
colormaterial.

I can specify loader3d = Collada.load("buildings.dae", { scaling:1,
autoLoadTextures:false, material:new WireColorMaterial(0xFF0000)} );
all meshes get red just fine.
But I CAN'T have specific materials for each children of the collada
model like I did before :
((event.loader.handle).getChildByName("ID25") as Mesh).material = material1;
or (((model.getChildByName("ID746") as
ObjectContainer3D).getChildByName("ID747") as
ObjectContainer3D).getChildByName("ID748") as Mesh).material =
material1;
in case of long family of nodes.

Well actually I can specify them, and the material properties gets
updated just fine.. it just never appears on the model.
Using autoLoadTextures=true do not change anything in a good way -> no
more materials at all.

I read that collada loadings usually need something like
var loader:Object3DLoader = Collada.load("resources/test02.dae",
{materials:{wood:WoodMaterial, metal:MetalMaterial}});
to be associated with the correct Away materials.It has not been
tested yet, since having 85 materials I'd like to check other ways
first..

I mostly wonder why at first I can't get it loaded & added to my scene
just as wireframecolor (no mat at all) as usual.
Any idea of what could cause this ?

- Colladas are exported from cinema4D, I join both.
- I checked both collada files (little old one & big new) and except
the number of elements I couldn't spot any differences,
is there a maximum number of elements for Collada.loader() to work properly ?

Many thanks for any idea, point to look for or anything else I could
check/test !
Cheers

bastien

Reply via email to