Thanks for the help - appreciate it. Took me a while to get back to it, but looks like it's working, at least if I characterize the loaded object as a Mesh.
Thanks again, Scott On Feb 8, 7:36 pm, Li <[email protected]> wrote: > Hey Scott, > > I'm not an expert with this, but perhaps I could help a bit... > I see 2 scenarios for what you are wanting to do: > > 1) For a simple primitive like spheres, cubes, planes, etc, object.material > would return the instance of the IMaterial used for it. This could be a > BitmapMaterial, WireColorMaterial, ColorMaterial, etc... so you could test > to see what type of material it is with an "obj.material is > WireColorMaterial" sort of if, and assign to a variable of the proper kind > after knowing what it is. If you know it is a ColorMaterial, then: > > var mat:ColorMaterial = object.material as ColorMaterial; > trace(mat.color); > > 2) If the object is complex and comes from an external source, you might > have to look into its materialLibrary property instead of the material > property since it is likely to have more than one material assigned to its > faces. In such case, you would have to sweep through the material data > elements in its material library, something like this: > > for each(var mdata:MaterialData in obj.materialLibrary) > { > trace(mdata.type); > etc... > > } > > As always, this is just a suggestion and there might be a better, more > efficient way to do what you need. > Hope it helps! > > > > On Sun, Feb 8, 2009 at 9:10 PM, scott <[email protected]> wrote: > > > Tried to post this in response to another thread but doesn't seem like > > it took. > > > I'm new with Away3D and am trying to figure out how to access material > > properties of objects. I understand how to SET an object's material, > > either through the init array or just something like myObject.material > > = new BitmapMaterial(myBitmap). But I'm not clear on how to GET an > > object's material. Let's say there's an arbitrary object that I want > > to read out what material or color it's using - how would I do this? > > I tried things like materialVariable:BitmapMaterial = > > myObject.material, and colorVariable:uint = myObject.material.color, > > but got type errors in both cases. The object was loaded from an obj > > file, if that's relevant. If anyone can help that would be great. > > > Thanks, > > > Scott- Hide quoted text - > > - Show quoted text -
