Re: [osg-users] osg::ProxyNode and osg::ComputeBoundsVisitor
Am 25.07.2011 17:15, schrieb Oren Fromberg: Hey Sebastian! Thanks for the interesting reply. So, I guess that explains why the dimensions of my bounding box are tending to infinity! I have some questions though: 1) what do you mean by "load the proxy node at least once"? does that mean to add the proxy node as a child in the scene or just to add a reference to that node? The proxynode usually references an actual file. So simply load it via osgDB::readNodeFile. You can then retrieve its bounds. If you're only interested in the bounds, put them to the proxyNode or simply store them elsewhere. The loaded node will be deleted in case you don't reference it further (see osg::ref_ptr for this) 2) what do you mean by "hook up in the load callbacks"? OSGDb allows you to hook up into its loading callbacks. For this you'll have to create a callback class and derive it from osgDB::Registry::ReadFileCallback. See the Callback example for more info. This way you can control/check what is loaded, or modify the loaded node before putting it into the scenegraph. 3) what does your database compiler do? Basically I have to load big databases from openflight. In order to handle certain models differently I hook up into the loading, load the node, check some of its properties and put into a own datastructure. Later on, I can save those models without including it into the resulting .ive file, as it wouldn't fit there really. If you use osgconv it usally will put all referenced nodes (i.e. proxynodes) into the resulting export, which gives poor control over instancing, optimization etc. If you maybe elaborate what you are trying to achive, there might be more useful input of others ;-) cheers Sebastian Thanks so much! Sincerely, Oren -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=41609#41609 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osg::ProxyNode and osg::ComputeBoundsVisitor
Hey Sebastian! Thanks for the interesting reply. So, I guess that explains why the dimensions of my bounding box are tending to infinity! I have some questions though: 1) what do you mean by "load the proxy node at least once"? does that mean to add the proxy node as a child in the scene or just to add a reference to that node? 2) what do you mean by "hook up in the load callbacks"? 3) what does your database compiler do? Thanks so much! Sincerely, Oren -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=41609#41609 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osg::ProxyNode and osg::ComputeBoundsVisitor
Hello Oren, It seems that the node isn't loaded at all. As I do something similar in my database compiler, I think you will have to actually load the proxy node at least once to calculate the correct bounds for it: You code is correct, but as you defer loading of the real model, the ComputeBoundsVisitor will end up having a no children to traverse. What I do is to hook up in the load callbacks and to load every model once to be able to set the correct bounds (and other stuff) to the ProxyNodes that reference it. (They get written by the compiler if references are encountered) Hope that help Sebastian Howdy friends, I'm loading a model using an osg::ProxyNode like this: Code: std::map > model_db_map; ... if (model_db_map[name] == NULL) { osg::ref_ptr pn = new osg::ProxyNode; pn->setLoadingExternalReferenceMode (osg::ProxyNode::DEFER_LOADING_TO_DATABASE_PAGER); pn->setFileName (0, name + ".ive"); model_db_map[name] = pn; } shortly after this I compute the bounding box like this: Code: osg::ref_ptr node = model_db_map[name]; osg::ComputeBoundsVisitor bb; node->accept(bb); problem is I then get this for bb.getBoundingBox()._min: Code: (gdb) p bboxMin $1 = {_v = {3.40282347e+38, 3.40282347e+38, 3.40282347e+38}} and this for bb.getBoundingBox()._max: Code: (gdb) p bboxMax $2 = {_v = {-3.40282347e+38, -3.40282347e+38, -3.40282347e+38}} and my stdout gets repeatedly bombed with this: Code: CullVisitor::apply(Geode&) detected NaN, depth=nan, center=(0 0 0), matrix={ nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan } Why is this so? The bounding box is computed correctly when using osgDB::readNodeFile instead of osg::ProxyNode. Thanks in advance. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=41522#41522 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] osg::ProxyNode and osg::ComputeBoundsVisitor
Howdy friends, I'm loading a model using an osg::ProxyNode like this: Code: std::map > model_db_map; ... if (model_db_map[name] == NULL) { osg::ref_ptr pn = new osg::ProxyNode; pn->setLoadingExternalReferenceMode (osg::ProxyNode::DEFER_LOADING_TO_DATABASE_PAGER); pn->setFileName (0, name + ".ive"); model_db_map[name] = pn; } shortly after this I compute the bounding box like this: Code: osg::ref_ptr node = model_db_map[name]; osg::ComputeBoundsVisitor bb; node->accept(bb); problem is I then get this for bb.getBoundingBox()._min: Code: (gdb) p bboxMin $1 = {_v = {3.40282347e+38, 3.40282347e+38, 3.40282347e+38}} and this for bb.getBoundingBox()._max: Code: (gdb) p bboxMax $2 = {_v = {-3.40282347e+38, -3.40282347e+38, -3.40282347e+38}} and my stdout gets repeatedly bombed with this: Code: CullVisitor::apply(Geode&) detected NaN, depth=nan, center=(0 0 0), matrix={ nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan } Why is this so? The bounding box is computed correctly when using osgDB::readNodeFile instead of osg::ProxyNode. Thanks in advance. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=41522#41522 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osg proxynode
Hi Christian, On 30/3/09 12:33 PM, Christian Sam wrote: could someone tell me in a few sentences what a proxynode (or is it just proxy?) in osg is, and what it is used for? It's a node that references external model files. The files will be loaded asynchronously via DatabasePager once the proxy node becomes visible. Since the proxy node cannot know the position/dimension of the model it references you have to specify those manually. I don't think it's ever unloaded. Hope this helps, /ulrich ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] osg proxynode
Hi, could someone tell me in a few sentences what a proxynode (or is it just proxy?) in osg is, and what it is used for? thanks in advance, christian -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=9434#9434 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org