Let me know when I'm getting close to being kicked out of group LOL I appreciate the explaination, Fabrice, thank you ... however ...
I must have one really screwed up .obj ... all traces return false ... LOL http://groups.google.com/group/away3d-dev/web/teapot_1.obj http://groups.google.com/group/away3d-dev/web/teapot_1.jpg Hear me out ... obj1 = Obj.load("assetts/teapot_1.obj", {material:"teapot_1.jpg"}); -> loads fine and renders fine obj1object3d = e.loader.handle; -> I assume this get's the handle to obj1 obj1mesh = (obj1object3d as ObjectContainer3D).children[0]; -> get's mesh obj1mesh = (obj1object3d as Mesh); -> pops error so assume ObjectContainer3D and use line above after lines above call traces: trace(obj1 is Mesh); -> "false" (makes sense) trace(obj1object3d is Mesh); -> "false" (makes sense) trace(obj1mesh is Mesh); -> "false" (does NOT makes sense) trace(obj1 is Object3D); -> "false" trace(obj1object3d is Object3D); -> "false" trace(obj1mesh is Object3D); -> "false" trace(obj1 is ObjectContainer3D); -> "false" trace(obj1object3d is ObjectContainer3D); -> "false" trace(obj1mesh is ObjectContainer3D); -> "false" What in the world does it imply if every single trace is false!?!?!? Every single variable above is called out private var ... Sorry be such a pain dude but things aren't jiving ... On Apr 27, 4:54 am, Fabrice <[email protected]> wrote: > Hi Joseph, > the children array is a property of an ObjectContainer3D. > but depending on the model structure, it can be that the child 0 is > also of the same type. > > simple traces as trace(mymodel is Mesh), is ObjectContainer3D etc... > can help you parse your model. > > if you however seek a more generic option consider codes like this: > > loadedsuccessEvent (e:LoaderEvent) > parse(e.loader.handle); > > private function parse(object3d:Object3D):void > { > > if(object3d is ObjectContainer3D){ > > var obj:ObjectContainer3D = (object3d as > ObjectContainer3D); > > for(var i:int =0;i<obj.children.length;++i){ > > if(obj.children[i] is > ObjectContainer3D){ > parse(obj.children[i]); --> > we go deeper > } else if(obj.children[i] is Mesh){ > doSomething( > obj.children[i]); --> do something with the Mesh > object > } > } > > } else if(object3d is Mesh){ > doSomething( object3d as Mesh); --> do > something with the Mesh > object > } > } > > Fabrice > > On Apr 27, 2009, at 12:29 PM, Joseph wrote: > > > > > > > The only problem is I have never been able to get > > object.children.length to work without an error. > > > I've tried it on the obj loader: > > var obj1:Object3DLoader = Obj.load("assetts/teapot_1.obj"); > > trace(obj1.children.length); > > and it results in child.length of 1 ... not sure what that implies for > > just the loader ... > > > tried grabbing the handle and then doing it: > > obj1object3d = e.loader.handle; > > trace(obj1object3d.children.length); > > 1119: Access of possibly undefined property children through a > > reference with static type away3d.core.base:Object3D. > > > and tried converting to mesh: > > obj1mesh = (obj1object3d as ObjectContainer3D).children[0]; > > trace(obj1mesh.children.length); > > 1119: Access of possibly undefined property children through a > > reference with static type away3d.core.base:Mesh. > > > I changed code (since only have 1 child apparently) to: > > > for ( var j : Number = 0; j < obj1mesh.faces.length; j++ ) { > > obj1mesh.faces[j].material = texture3;} > > > and error popped: > > > TypeError: Error #1034: Type Coercion failed: cannot convert > > Test67_texture3$ to away3d.materials.ITriangleMaterial. > > > On Apr 27, 2:49 am, routine <[email protected]> wrote: > >> just try this one: > > >> var texture1 : BitemapFileMaterial = new > >> BitmapFileMaterial( yourURL); > > >>>>>> for ( var i : Number = 0; i < object.children.length; i++ ) { > >>>>>> for ( var j : Number = 0; j < > >>>>>> object.children[i].faces.length; j++ ) { > >>>>>> object.children[i].faces[j].material = texture1; > >>>>>> } > > >> this probably should work. > > >> Roland- Hide quoted text - > > - Show quoted text -
