[osg-users] Referencing loaded models

2009-05-23 Thread Sebastian Messerschmidt
Hi, This might be a total beginners question, but I didn't find any sufficient information in the forum nor in the documentation. Let's assume I have a scene composed of some models, let's say a trees/houses which are the same model. If I want to load the model once and use it multiple times

Re: [osg-users] Referencing loaded models

2009-05-23 Thread Paul Griffiths
I does this: const static osg::ref_ptr osg::Node staticNode = osgDB::readNodeFile(Shapes/Shape.osg); then for each required instance: const static osg::ref_ptr osg::Node nodeCopy = (osg::Node*)staticNode-clone(osg::CopyOp::DEEP_COPY_NODES); -- Read this topic online here:

Re: [osg-users] Referencing loaded models

2009-05-23 Thread Sebastian Messerschmidt
Hi Paul, but isn't this just cloning? With other words: is there something that is shared between the nodes? Plus, i would favour something not involving static data ;-) cheers Sebastian I does this: const static osg::ref_ptr osg::Node staticNode = osgDB::readNodeFile(Shapes/Shape.osg);

Re: [osg-users] Referencing loaded models

2009-05-23 Thread Paul Griffiths
Is the only way i worked out that works, though i belive there is a tutorial in the turorial section. Got to ask though, whats wrong with using static? -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=12812#12812

Re: [osg-users] Referencing loaded models

2009-05-23 Thread Kim C Bale
. From: osg-users-boun...@lists.openscenegraph.org on behalf of Sebastian Messerschmidt Sent: Sat 23/05/2009 14:42 To: OpenSceneGraph Users Subject: [osg-users] Referencing loaded models Hi, This might be a total beginners question, but I didn't find any sufficient information in the forum

Re: [osg-users] Referencing loaded models

2009-05-23 Thread Paul Griffiths
The reason i chose static is so the model is loaded only once when the first class instance is created. You could however create this node non-static but you must make sure you load it only once, like put it in another class and referance to it or something. -- Read this topic

Re: [osg-users] Referencing loaded models

2009-05-23 Thread Paul Griffiths
Kim C Bale wrote: Hi Sebastian, Unless you explicitly ask the osg to clone your model's geometry it will share the geometry by default. It simply stores a pointer to the loaded model's vertices etc. So the below code should work for you. You can also set osgDB to cache the model in

Re: [osg-users] Referencing loaded models

2009-05-23 Thread Kim C Bale
:39 To: osg-users@lists.openscenegraph.org Subject: Re: [osg-users] Referencing loaded models Kim C Bale wrote: Hi Sebastian, Unless you explicitly ask the osg to clone your model's geometry it will share the geometry by default. It simply stores a pointer to the loaded model's vertices

Re: [osg-users] Referencing loaded models

2009-05-23 Thread Paul Griffiths
Kim C Bale wrote: Could you not check the name of parent node to identify the instance of the child? I might be wrong I haven't used the picking functionality for a while. K. Tried that but it always gives the parent node of the first instance. -- Read this topic

Re: [osg-users] Referencing loaded models

2009-05-23 Thread Sebastian Messerschmidt
. From: osg-users-boun...@lists.openscenegraph.org on behalf of Paul Griffiths Sent: Sat 23/05/2009 15:39 To: osg-users@lists.openscenegraph.org Subject: Re: [osg-users] Referencing loaded models Kim C Bale wrote: Hi Sebastian, Unless you explicitly ask

Re: [osg-users] Referencing loaded models

2009-05-23 Thread Paul Speed
Then something else is wrong. The nodePath of your hits should be accurate to the specific node that was picked. This is pretty routine stuff as anyone using a scene graph is likely to have nodes scattered in at least dozens of places around their scene graphs. -Paul Paul Griffiths wrote:

Re: [osg-users] Referencing loaded models

2009-05-23 Thread Jean-Sébastien Guay
Hi Paul, Tried that but it always gives the parent node of the first instance. If that's the case, then you're probably using getParent(0) to go up in the graph, instead of using the intersection's node path. Remember, the model can have a whole hierarchy inside too, and the intersection

Re: [osg-users] Referencing loaded models

2009-05-23 Thread Paul Griffiths
Skylark wrote: If that's the case, then you're probably using getParent(0) to go up in the graph, instead of using the intersection's node path. Yes, i am going osg::Node* node = hitr-nodePath.back(); if (node node-getNumParents() 0) { node = node-getParent(0); ... } now im trying

Re: [osg-users] Referencing loaded models

2009-05-23 Thread Paul Griffiths
Found the fault, forgot to add hitr-nodePath.pop_back() at the end of each itteration -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=12825#12825 ___ osg-users mailing list

Re: [osg-users] Referencing loaded models

2009-05-23 Thread Jean-Sébastien Guay
Hi Paul, Yes, i am going osg::Node* node = hitr-nodePath.back(); if (node node-getNumParents() 0) { node = node-getParent(0); ... } Yes, well no wonder you're always getting the same parent... :-) now im trying this but its crashing: What you want to do is walk the path up from the