Adding billboards with different names under the same geometry?

20 views
Skip to first unread message

Rodrigo Dias

unread,
May 20, 2020, 6:28:16 PM5/20/20
to OpenSceneGraph Users
Hi,

I'm displaying icons over the terrain as billboards (always facing the user). These icons represent structures and landmarks (hydroelectric dams, national parks, mountain peaks, mining projects...), so I'll load some tens of thousands of them, and show some hundred or a few thousand at a time. To save memory, I've learned that I must use a single geometry per class of icon. So, for hydroelectric dams (hidrelétricas, in Portuguese), I'm doing once:

            geodeHidreletrica = new osg::Billboard;
            geodeHidreletrica->setMode( osg::Billboard::POINT_ROT_EYE );
            osg::Geometry* quadHidreletrica = createQuad("icons/hidreletrica.png","QuadHidrelétrica");

and for each icon I do:

            geodeHidreletrica->addDrawable( quadHidreletrica, osg::Vec3( lon, lat, alt ) );

So far so good, the icons appear where they should. "QuadHidrelétrica" is the name of the quad (using setName). However, I want to have a different name for each icon, or somehow identify them by name when the mouse is over them. Is that possible using this strategy? Or should I do things differently? If so, what's the best approach, regarding performance?

Thanks,
Rodrigo.

OpenSceneGraph Users

unread,
May 21, 2020, 2:30:32 AM5/21/20
to OpenSceneGraph Users
If the approach is producing good enough performance then I'd stick with it.  It's a long way from the most optimal way you could do this type of task, but all the alternatives are more complicated and require deeper understanding of OSG/OpenGL/shaders. I'll not attempt to make suggestions as you should only ever make solutions more complicated if you really have to.

As for giving the objects different names, all objects in the scene graph support setName/getName, if you are reuse the same subgraph the node above the reused part like the osg::Billboard is what is unique so put your unique name on that nodes.  The intersection traversal will return the whole NodePath to the intersected drawable so you just need to check the NodePath to find all the associated names.

Robert.

Rodrigo Dias

unread,
May 21, 2020, 4:12:00 AM5/21/20
to OpenSceneGraph Users
Thank you for your reply, Robert, but one of us is not understanding the other.

"if you are reuse the same subgraph the node above the reused part like the osg::Billboard is what is unique so put your unique name on that"

Actually, I have only one osg::Billboard (geodeHidreletrica) for hundreds of hydroelectric dam icons (thus hundreds of different names). Should I have hundreds of billboards? Hundreds of quads/geometries? I don't quite get how addDrawable copies the icons to different places using (what seems to be) a single osg::Geometry. In which object exactly should I put each different name?

Thanks again,
Rodrigo.

OpenSceneGraph Users

unread,
May 21, 2020, 4:48:32 AM5/21/20
to OpenSceneGraph Users
Hi Rodrigo,

from my understanding the number of Billboards, each an individual instance, is not
the problem in OSG. The cull traversal has to handle it independant of being an individual
instance or being a single instance, reused after a transform. So you can create them and give names to them.
The important point is the resource of the icons. You should load them externally and assign them to the billboards
by using their pointers. This will ensure OSG will keep only one instance of each kind of icon.

- Werner -


Am 21.05.2020 um 10:11 schrieb OpenSceneGraph Users:
Thank you for your reply, Robert, but one of us is not understanding the other.

"if you are reuse the same subgraph the node above the reused part like the osg::Billboard is what is unique so put your unique name on that"

Actually, I have only one osg::Billboard (geodeHidreletrica) for hundreds of hydroelectric dam icons (thus hundreds of different names). Should I have hundreds of billboards? Hundreds of quads/geometries? I don't quite get how addDrawable copies the icons to different places using (what seems to be) a single osg::Geometry. In which object exactly should I put each different name?

Thanks again,
Rodrigo.

On Thursday, May 21, 2020 at 3:30:32 AM UTC-3, OpenSceneGraph Users wrote:
--
You received this message because you are subscribed to the Google Groups "OpenSceneGraph Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osg-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/osg-users/2f1ac1bd-fc93-4001-89cc-039e4554324e%40googlegroups.com.

_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Rodrigo Dias

unread,
May 21, 2020, 6:15:07 AM5/21/20
to OpenSceneGraph Users
Ah, right, now I see it!

Thank you both! It's working now.

On Thursday, May 21, 2020 at 5:48:32 AM UTC-3, OpenSceneGraph Users wrote:
Hi Rodrigo,

from my understanding the number of Billboards, each an individual instance, is not
the problem in OSG. The cull traversal has to handle it independant of being an individual
instance or being a single instance, reused after a transform. So you can create them and give names to them.
The important point is the resource of the icons. You should load them externally and assign them to the billboards
by using their pointers. This will ensure OSG will keep only one instance of each kind of icon.

- Werner -

Am 21.05.2020 um 10:11 schrieb OpenSceneGraph Users:
Thank you for your reply, Robert, but one of us is not understanding the other.

"if you are reuse the same subgraph the node above the reused part like the osg::Billboard is what is unique so put your unique name on that"

Actually, I have only one osg::Billboard (geodeHidreletrica) for hundreds of hydroelectric dam icons (thus hundreds of different names). Should I have hundreds of billboards? Hundreds of quads/geometries? I don't quite get how addDrawable copies the icons to different places using (what seems to be) a single osg::Geometry. In which object exactly should I put each different name?

Thanks again,
Rodrigo.

On Thursday, May 21, 2020 at 3:30:32 AM UTC-3, OpenSceneGraph Users wrote:
If the approach is producing good enough performance then I'd stick with it.  It's a long way from the most optimal way you could do this type of task, but all the alternatives are more complicated and require deeper understanding of OSG/OpenGL/shaders. I'll not attempt to make suggestions as you should only ever make solutions more complicated if you really have to.

As for giving the objects different names, all objects in the scene graph support setName/getName, if you are reuse the same subgraph the node above the reused part like the osg::Billboard is what is unique so put your unique name on that nodes.  The intersection traversal will return the whole NodePath to the intersected drawable so you just need to check the NodePath to find all the associated names.

Robert.
--
You received this message because you are subscribed to the Google Groups "OpenSceneGraph Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osg-...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages