[Papervision3D] Collada file component referencing
David Di Biase
dave.dibiase at gmail.com
Mon Jan 26 19:07:53 PST 2009
Aha, that makes complete sense. I ended up working out a different method
and it works here: http://eplant.mozzly.com/launch.html use the colour
swatches on the left hand side to change the material of the plant itself.
What I ended up doing was, in SketchUp, assigning a specific set of
materials to the model. In the DAE file I realised that it was creating a
material library reference as such:
<material id="material_0_0ID" name="material_0_0">
I then noticed I can reference the material directly and do this:
model.getMaterialByName('material_0_0').fillColor = 0x938472;
My plan was to pretty much just modify the material directly. The thing is
eventually in the future what if I wanted to perform other functionality on
a models child components ie. move the child or do something else with it.
In which case I think your methodology would make MUCH more sense.
Quite honestly, it would be absolutely fantastic if someone wrote a tutorial
or a blog post about everything you just brought up. It would definitely be
something useful to the community.
On Mon, Jan 26, 2009 at 6:07 PM, Admiral <admiral at nuclearpixel.com> wrote:
> The first thing that you need to understand about Collada files imported
> using the DAE class, is that you're not importing a single model, you're
> actually importing an entire scene. Your DAE instance is basically a
> DisplayObject3D with no mesh of it's own, that contains another no-mesh
> DisplayObject3D named 'COLLADA_Scene'. That 'COLLADA_Scene' DO3D contains
> all of the objects exported from your 3D app. The actual meshes of your
> objects may be parented to other no-mesh DO3Ds, but so long as you know the
> name of the object that you are looking for as your 3D app exported it, you
> can reference it and do with it as you like.
> Let's say that your DAE instance is named 'leaves', and I want to reference
> the object in that scene named 'mesh2'. Keep in mind that 'mesh2' may be a
> child of a child of a child in your Collada file, so things can start to
> messy there. Let's imagine that your scene is set up like this: 'leaves' is
> your DAE object. All DAEs have a child named 'COLLADA_Scene'. Let's say
> 3d app for some reason created a no-mesh parent object for your mesh named
> 'Rosette_Leaf_6'. That object will be a child of the no-mesh
> DO3D. The mesh-containing DO3D that you WANT to get at might be named
> 'mesh2', a child of 'Rosette_Leaf_6'.
> How do we navigate that and get at 'mesh2' then? There are two ways that I
> know of;
> The long way,
> and the short way.
> Here is an example of how I would access the 'mesh2' object the LONG way:
> theMeshIWantAccessTo =
> That's the long and painful way, and you need to know exactly the structure
> of how your 3d app exports it's Collada files in order to do that.
> Here's the short, and much less painful way.
> theMeshIWantAccessTo = leaves.getChildByName('mesh2', true);
> Notice the second perameter of the 'getChildByName' method that I use
> 'true'. That tells the method 'getChildByName' to search each of it's
> children recursively and return an object with the name 'mesh2'.
> The next most important but of information that you will need to be able to
> use this, is that you cannot use the 'getChildByName' method on your DAE
> object instance('leaves') until after the Collada file has been loaded and
> parsed. You'll want to put the above lines inside of your loadHandler
> function, and you'll assign your loadHandler function to your DAE object
> like this:
> leaves.addEventListener(FileLoadEvent.LOAD_COMPLETE, loadHandler);
> I hope this has been helpful!
> where 'Rosette_Leaf_6_1' is the name of the object you want to reference.
> David Di Biase wrote:
> > [...]
> > As I load the entire model into my instance, Console tells me that the
> > object was loaded and the separate elements are good to go.
> > INFO: DisplayObject3D: COLLADA_Scene
> > INFO: DisplayObject3D: Model
> > INFO: DisplayObject3D: Rosette_Leaf_6_1
> > INFO: DisplayObject3D: Rosette_Leaf_6
> > INFO: DisplayObject3D: mesh1
> > INFO: DisplayObject3D: Rosette_Leaf_12_1
> > INFO: DisplayObject3D: Rosette_Leaf_12
> > INFO: DisplayObject3D: mesh2
> > INFO: DisplayObject3D: Rosette_Leaf_4_1
> > INFO: DisplayObject3D: Rosette_Leaf_4
> > ...
> > The question is, how can I begin referencing these components? Are they
> > now
> > separate models or unique items in PV? All I'd really like to do is
> > dynamically modify each component on the DAE. I'm wondering if there is a
> > tutorial or if someone can give a brief piece of code to explain it to me
> > :-/ I couldn't find any tutorials specifically to help me out with this
> > one. Shucks!
> > Thanks,
> > Dave_osflash.org
> View this message in context:
> Sent from the Papervision3D mailing list archive at Nabble.com.
> Papervision3D mailing list
> Papervision3D at osflash.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Papervision3D