You are right it's something I have done ... didn't mean to offend by
not using code ...
It gave all false because I was being fancy with the traces doing:
trace("Is obj1mesh a mesh?"+obj1mesh is Mesh);
and should have been
trace("Is obj1mesh a mesh?"+(obj1mesh is Mesh));
Now I see the "parsing" ... thanks for help and the code which I will
impliment.
Any advice on getting texture swapping done on an .obj file?
tried:
for ( var j : Number = 0; j < obj1mesh.faces.length; j++ ) {
obj1mesh.faces[j].material = texture3;}
popped error on use:
TypeError: Error #1034: Type Coercion failed: cannot convert
Test67_texture3$ to away3d.materials.ITriangleMaterial.
for ( var j : Number = 0; j < obj1object3d.faces.length; j++ ) {
obj1object3d.faces[j].material = texture3;
}
failed on compile:
1119: Access of possibly undefined property faces through a reference
with static type away3d.core.base:Object3D.
On Apr 27, 5:55 am, Fabrice <[email protected]> wrote:
> I do not see entire code here, but I will have here to presume, you
> override or do something wrong.
> because if handle is a valid Object3D, if your object is correctly
> displayed on screen, then it's either a Mesh or an ObjectContainer3D.
>
> so if you do not want use the code I gave you on previous reply
> I suggest you just new AS3Exporter(e.loader.handle, "classname",
> "packagename"); in the loadedSuccess method.
> then you import this class and just do var class:Class = new Class();
> then you can acess all meshes by
>
> class.meshes --> array of meshes
> class.containers --> array of ObjectContainer3D
>
> Fabrice
>
> On Apr 27, 2009, at 2:43 PM, Joseph wrote:
>
>
>
>
>
> > 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 -- Hide quoted text -
>
> - Show quoted text -