Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

Tags in this Discussion

need advice on how to create loading progressbar or a HUD
  • Hi,

    I am creating a software that will load a lot of 3D objects into the scene.
    I would like to show a progressBar indicator on top of the scene to show to the user the progress of the loading.
    What is the best way to do that with scenix?
    - to create just one Scene and work adding and removing 2D nodes to the tree?
    - or perhaps is possible to have 2 separate Scenes being drawed at same time? (one for the 3D aspect and other for the 2D)

    Extending this idea, would be nice if i could create a HUD to show runtime information of the objects in the corner of the scene, perhaps when user pass with the mouse over the 3D objects.

    How can i accomplish that?

  • 3 Comments sorted by
  • Vote Up1Vote Down Detlef Roettger
    Posts: 330 Accepted Answer
    Please have a look into the small example code I prepared for a very simple HUD rendering which doesn't need to touch the scene graph contents (which would be bad for performance).
    http://forums.developer.nvidia.com/devforum/discussion/2991/scenix-7.2-simple-hud-text-rendering

    Rendering runtime information of objects the mouse hovers over would just need to identify that object somehow (and very quickly!).
    You could use the RayIntersectTraverser for that kind of picking, but be warned it's pure CPU code, which is not really fast on bigger geometry blobs (even slower in debug mode), because it needs to check every primitive inside the geometry which bounding sphere it intersected.
  • Hi Detlef,

    Thank you very much for the code you provided. It openned my mind with better understanding of SceneRenderer class and it's use.

    However, i think that placing the HUD inside the SceneRender makes it a little hard to fill variables to be drawn, let's say for example the amount of objects already being loaded in the case of the progressbar, or the text to be drawn over the scene or even a selectionBox following the mouse when the user want's to select various objects at the same time.

    So, in conjuction with your code, i studied the way the Viewer sample makes to write text on screen and ended up with a bit diferent approach. It's not so elegant as yours, unfortunatelly :)
    Also, i think that the way the Viewer sample uses to build fonts and use it has a bad quality in the looks of the fonts rendered (and is too limited because don't work with Ç and accents ÓÉÍ. Outside U.S we use it a lot). I tested the ones native to the QGLWidget and found it very impressive, so i wanted to use it instead.

    To accomplish all that i created a HUDRenderer class, put a pointer to it inside my VisualWidget (which extend from ScenixQGLRendererWidget) and called the draw code of the HUD in the PaintGL, like this:

    void VisualWidget::paintGL() {
    SceniXQGLSceneRendererWidget::paintGL();
    m_hud->doRender();
    //physics->update(); // will work in the near future, i hope :)
    }

    also, i had to make some ugly stuff like this:
    void VisualWidget::renderText( int x, int y, const QString & str, const QFont & font, int listBase ) {
    m_glWidget->renderText(x, y, str, font, listBase);
    }
    because QGLWidget is held private inside ScenixQGLWidget.
    But in the end the result was pretty amazing UTF8 fonts, separated HUD code (which can be optimized for not changing projections so often like Viewer does in case of two "print" calls and is multi O.S as it uses QT renderText.
    The m_hud->doRender() code looks like this:

    void HUDRenderer::doRender() {
    beginHudRender(); // setup ortho projection

    if ( m_showFPS ) {
    m_parentWidget->renderText( 2, 12, QString("FPS: %0").arg((unsigned int)floor( m_fps + 0.5 )), *m_font);
    }
    //draw HUD with immediate mode here (argh)
    // ..progessbar, selectionbox, etc
    //
    endHudRender(); // go back to perspective projection
    }

    I'm guessing that the "correct way" of doing the HUD was to put it inside the SceneRenderer like you did, but than i would need an intermediate class to hold the hud-scene-tree to be drawed in the SceneRender. Can we vote for this feature in Scenix 8.0? ;)

    Again, thank you very much for your time. It helped a lot!

    best regards,
    - Luís Eduardo.
  • Agreed, the font rendering for the continuous rendering performance number isn't a beauty and I know about such additional characters, we have ÄÖÜäöüß in Germany. ;-)

    When not using Qt: Inside the very old NVSG 4.0 based VisSim application source (SceniX archive pages: http://developer.nvidia.com/scenix-archive ), there is a font rendering part using FreeType.
    (Warning, that code is pretty far away from the SceniX 7 API, but the basic OpenGL functionality of getting text printed is the same.)

    If rendering a scene as HUD, the Viewer SceneRendererPipeline was the correct example code to look at. Please look inside my "SceniX 7.2 HUD" post again where I answered some more questions about these things just recently

    There is no need to make any of that a SceniX core feature if there are ways to achieve the same using the available mechanisms. The flexibility of the SceneRenderer and RenderTarget was explicitly designed to allow for easier multipass algorithms.