@Matt, I suppose the way I set up my code sidestepped the cloning of meshes within meshes. I have groups of OBJ files with no mesh children, and I simply clone those. In order to logically associate those OBJ meshes I implemented the AssetManifest to map them to "game objects," conceptually (so the barrel game object in the AssetManifest is made up of a barrel_rings OBJ, barrel_top OBJ, and barrel_body OBJ). Also, in Broomstick you can only have 1 material per OBJ file and my game objects have multiple materials each. I don't know if this is true of other model file types, but it figured largely in how I wrote these classes.
Anyway, my code is cumbersome as a result, but it does obviate the need to clone ObjectContainer3Ds or Meshes with Mesh children. I trust that a more robust clone process is in Broomstick's future, and hasn't been written yet as a matter of relative priority. On Wed, Jun 22, 2011 at 3:30 PM, Matt Przybylski <m...@reintroducing.com>wrote: > Sorry, don't mean to spam the list, but even odder, this works if you > replace the newChair line: > > var newChair:Mesh = Mesh(tempContainer.getChildAt(0).clone()); > > It just doesn't work when you try to clone containers as opposed to > the Meshes that live inside those containers by themselves. Very, > very odd. > > On Jun 22, 2:27 pm, Matt Przybylski <m...@reintroducing.com> wrote: > > Actually, look at this, as it doesn't work either: > > > > var tempContainer:Mesh = new Mesh(); > > tempContainer.addChild(AssetLibrary.getAsset(Constants.CHAIR) as > > Mesh); > > var newChair:Mesh = Mesh(tempContainer.clone()); > > var newContainer:ObjectContainer3D = new ObjectContainer3D(); > > newContainer.addChild(newChair); > > > > chairContainer.addChild(newContainer); > > > > So, if I access the AssetLibrary directly and pull the mesh out of > > there, clone it, it works. If I put it inside another Mesh (which in > > my case is necessary because I have 3 Meshes that go into the > > container and then the container is to be cloned), clone that Mesh, it > > no longer works. Very odd... > > > > Matt > > > > On Jun 22, 2:22 pm, Matt Przybylski <m...@reintroducing.com> wrote: > > > > > > > > > > > > > > > > > Ross, > > > I simplified your code to apply to my app and got this to work: > > > > > var original:Object = AssetLibrary.getAsset(Constants.CHAIR); > > > var newChair:Mesh = Mesh(original.clone()); > > > var newContainer:ObjectContainer3D = new ObjectContainer3D(); > > > newContainer.addChild(newChair); > > > > > This was great, however, when I substitute the Mesh that has 3 other > > > meshes for original it no longer works: > > > > > chairSingleContainer = new Mesh(); > > > chairSingleContainer.addChildren(chairCover.mesh, chairTie.mesh); > > > > > var original:Object = chairSingleContainer; > > > var newChair:Mesh = Mesh(original.clone()); > > > var newContainer:ObjectContainer3D = new ObjectContainer3D(); > > > newContainer.addChild(newChair); > > > > > The reason why the addChildren call has chairCover.mesh and > > > chairTie.mesh is because I've got another class that handles loading/ > > > parsing of the assets and puts them in there and it's then accessed by > > > calling instance.mesh (which normally works, it displays fine on > > > screen). > > > > > So the conclusion here is that it seems you can only clone a single > > > Mesh not a container with other Meshes inside of it. Is this true for > > > your experience as well? > > > > > Matt > > > > > On Jun 22, 1:59 pm, Matt Przybylski <m...@reintroducing.com> wrote: > > > > > > Great, thanks a ton Ross. I'll take a look at the code now. > > > > > > Matt > > > > > > On Jun 22, 1:40 pm, Ross Smith <evolution...@gmail.com> wrote: > > > > > > > I gotcha. You may find my AssetFactory more useful than I thought. > It > > > > > wasn't meant to be library code so it has some hard-coded stuff > pertaining > > > > > to OBJ parsing in it, but that's a simple fix. Check it out. > > > > > > >http://www.evolutioneer.com/away3d/AssetFactory_OBJ.zip > > > > > > > HTH, > > > > > Ross > > > > > > > On Wed, Jun 22, 2011 at 2:25 PM, Matt Przybylski < > m...@reintroducing.com>wrote: > > > > > > > > Ross, > > > > > > That would be very helpful if you could send it along. I > switched my > > > > > > OC3Ds to Meshes actually because I saw the Mesh class had a clone > > > > > > method but was still unable to get it to work properly. I'd > really be > > > > > > interested in looking at your code if at all possible. > > > > > > > > What I'm doing is loading 3 3ds files, parsing the models and > sticking > > > > > > them into a mesh container, then trying to clone that mesh > container > > > > > > into four other meshes. I also need to retain mouse events if > > > > > > possible but if not I suppose I can re-assign those to the > children > > > > > > meshes after the cloning takes place. > > > > > > > > Matt > > > > > > > > On Jun 22, 10:47 am, Ross Smith <evolution...@gmail.com> wrote: > > > > > > > Matt, what does your clone operation need to accomplish? I > noticed this > > > > > > > function missing as well from ObjectContainer3D. > > > > > > > > > I got around it (and some other issues) by writing asset > management > > > > > > classes > > > > > > > to walk a target "asset bundle", clone each of its mesh > children, and > > > > > > > perform an update method on each mesh's textures for lighting, > etc. The > > > > > > > code could be adapted to walk an ObjectContainer3D instead of > my custom > > > > > > > asset bundle object. > > > > > > > > > I will send the code to this list if you want to check it out. > The code > > > > > > > as-is only clones meshes. It does not recursively clone child > non-mesh > > > > > > > ObjectContainer3Ds. I don't know what your app needs in this > sense. > > > > > > > > > Best, > > > > > > > Ross > > > > > > > > > On Wed, Jun 22, 2011 at 11:35 AM, Matt Przybylski < > > > > > > m...@reintroducing.com>wrote: > > > > > > > > > > anyone? :( > > > > > > > > > > really need this for a project i'm working on right now, > would > > > > > > > > appreciate if a core developer can take a look at this asap. > > > > > > > > > > Matt > > > > > > > > > > On Jun 21, 9:17 pm, Matt Przybylski <m...@reintroducing.com> > wrote: > > > > > > > > > Hey guys, > > > > > > > > > I'm trying to clone an ObjectContainer3D in Broomstick and > I noticed > > > > > > > > > that method is not implemented yet. It's in Object3D but > you can't > > > > > > > > > use it with ObjectContainer3D. A quick scan of the code > reveals this > > > > > > > > > comment in Object3D's clone() method: > > > > > > > > > > > // todo: implement for all subtypes > > > > > > > > > > > Any idea when this will be implemented for > ObjectContainer3D? I > > > > > > tried > > > > > > > > > to write a clone method for ObjectContainer3D but was > unsuccessful in > > > > > > > > > getting it to work. > > > > > > > > > > > Conversely, if anyone has run into this issue already and > has a > > > > > > > > > clone() method they used with ObjectContainer3D, please do > post it if > > > > > > > > > you could. It would be greatly appreciated. > > > > > > > > > > > Thanks, > > > > > > > > > Matt > > > > > > > > > -- > > > > > > > Ross Smith > > > > > > > evolution...@gmail.com > > > > > > > -- > > > > > Ross Smith > > > > > evolution...@gmail.com > -- Ross Smith evolution...@gmail.com