Cannot access ColorMaterials via AssetLibrary in model loaded via AWD parser

Software: Away3D 4.x

Sean72, Newbie
Posted: 15 April 2013 05:11 AM   Total Posts: 28

I’ve been trying to set the shadow properties of existing materials (not textures) loaded with my AWD file by traversing the AssetLibrary.  Clearly these would be ColorMaterials?

The 15 or so materials are displaying fine on the correct mesh; but with this code:

for each (var model_submesh:SubMesh in model_loader_mesh.subMeshes)
{
    trace(model_submesh.material.name);
}

I only get the repeated text ‘material’ as a trace except for two materials that have .jpg textures, whose names I do get.

However, if I run the following text, it applies ‘mycolor:ColorMaterial’ successfully to all the mesh:

for each (var model_submesh:SubMesh in model_loader_mesh.subMeshes)
{
    model_submesh.material = mycolor;
}

I have also tried just telling a single mesh’s material to show shadows like this:

discMesh = AssetLibrary.getAsset(‘Disc’) as Mesh; //one imported object
trace(discMesh.material.name); //returns ‘material’
var colmat:ColorMaterial = discMesh.material as ColorMaterial;
trace(colmat.name); //still returns ‘material’
colmat.shadowMethod = new SoftShadowMapMethod(mydlight,5);

The last line indeed does set the shadow up for what appears to be a nameless ColorMaterial… unless I am missing something?

As a last point, I have tested AWD2 files exported via the C4D-AWD2-Bridge as well as loading said file into Prefab3D and exporting from there as AWD2 and neither approach provides material ‘names’.

I wondered if it could be an error similar to the one in this thread, but in the AWD2 parser…

https://github.com/away3d/away3d-core-fp11/issues/358

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X