Thanks Kim and Paul,
My problem seems to be elsewhere. Me stupid hasn't tried his own minimal
example.
In my application I sort of wrap certain scene elements (like models)
for an more abstract interface to loaded entities (as the models
geometrical/graphical representation is only one aspect). So I reckon,
there must be something wrong with my logic, rather than with the
sharing principle.
And yes, as far as picking is a concern, one could always put some top
node (like the transform is in my case) above the reference.
At least there are two lessons learned for me:
1. double check you stupid questions on behalf on a simple example, as I
didn't ;-)
2. ask questions to assure yourself ;-)
cheers & thanks
Sebastian
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.
________________________________
From: [email protected] on behalf of Paul Griffiths
Sent: Sat 23/05/2009 15:39
To: [email protected]
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 etc. So the below code should work for you.
You can also set osgDB to cache the model in memory so that if you ever call
osgDB::load() with the same path and filename it will just return a pointer to
the cached model rather than reloading it.
osg::Group* rootNode = new osg::Group;
osg::Node* loadedModel = osgDB::load(....);
osg::PositudeAttitudeTransfrom* instance_1 = new osg::PositudeAttitudeTransfrom
instance_1->setPosition( 10.f, 0.0, 0.0);
instance_1->addChild(loadedModel);
osg::PositudeAttitudeTransfrom* instance_2 = new osg::PositudeAttitudeTransfrom
instance_2->setPosition( 20.f, 0.0, 0.0);
instance_2->addChild(loadedModel);
osg::PositudeAttitudeTransfrom* instance_3 = new osg::PositudeAttitudeTransfrom
instance_3->setPosition( 30.f, 0.0, 0.0);
instance_3->addChild(loadedModel);
//now attach the instances to the graph
rootNode->addChild(instance_1);
rootNode->addChild(instance_2);
rootNode->addChild(instance_3);
viewer.setSceneData(rootNode);
Regards,
Kim.
That works fine unless your pickick with the mouse. Is you select any of the
nodes it always selects the first node :(
So i had to make a clone for each instance.
Guess it depense if your picking...
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=12815#12815
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
------------------------------------------------------------------------
*****************************************************************************************
To view the terms under which this email is distributed, please go to
http://www.hull.ac.uk/legal/email_disclaimer.html
*****************************************************************************************
------------------------------------------------------------------------
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org