Author Topic: get material _not_ by name, but by index  (Read 172 times)

Javier Rigondo   «   on: April 28, 2012, 08:29:36 AM »
Is it possible to get the list of materials in Mesh3D?
For example, if I set the material to the new plane by doing
var plane:Plane =  new Plane("plane" + i, 10, 10, 1, material.clone() );
how can I get its material?
In fact, it would be nice to have all the materials the Pivot3D has, by accessing it using, say, an array of materials, for example pivot.materials:Vector<Material3D>
Thanks!

Ivan Vodopiviz   «   Reply #1 on: May 02, 2012, 11:29:42 AM »
Hi Havier,

Mesh3D has a vector of Surface3D objects, and Surface3D holds the reference to its material. So you can access it like this:

for( var i:int=0; i < mesh.surfaces.length; i++)
{
    var material:Material3D = mesh.surfaces.material;
}

Pivot3D objects don't really store any mesh / material information, that's all managed by Mesh3D (that inherits from Pivot3D) and child classes like Cube, Sphere, etc.

Javier Rigondo   «   Reply #2 on: May 02, 2012, 11:38:58 AM »
Thanks a lot, Ivan!