What is happening when an .irr scene file is loading?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
ibax
Posts: 193
Joined: Thu Jun 21, 2007 8:56 am
Location: hungary
Contact:

What is happening when an .irr scene file is loading?

Post by ibax »

Hi,

I'm loading my scene file using the

Code: Select all

smgr->loadScene("myscenefile.irr");
function.

In this case, during the scene loading (approx. 10 seconds), nothing happens, there is no interaction with the user. That is OK, there is nothing to do, interrupt the scene loading, etc...
What I would like to achieve, is to show the user that the scene loading progress is ongoing...

For example, to draw the actually loaded texture filename into the screen. Or just start a counter and each time a texture is loaded into the memory, the counter increases by one, and this 'change' is visible also on the screen.
So the user will definitely know, that something is happening...

Or what other solutions should I take into consideration?

Thank,
ibax
REDDemon
Developer
Posts: 1044
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Re: What is happening when an .irr scene file is loading?

Post by REDDemon »

Actually what you are requesting is not possible, the loading is not asynchronous and has no hooks/callbacks to know advance progress.

I think it is possible embedding your irrlicht window into another window (like GTK as shown in some tutorials) so you can display a "rotating circle" over the 3D view using a 2nd thread (but in that case you cannot show a "progress bar").
Junior Irrlicht Developer.
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me
Cube_
Posts: 1010
Joined: Mon Oct 24, 2011 10:03 pm
Location: 0x45 61 72 74 68 2c 20 69 6e 20 74 68 65 20 73 6f 6c 20 73 79 73 74 65 6d

Re: What is happening when an .irr scene file is loading?

Post by Cube_ »

you could do some hacky stuff to get approximate loading done, but without modifying the io routines to be async you can't do it properly - if you want to do it this way you'd typically create your window externally and hook the render context to draw irrlicht's output, this way you can draw your loading screen using OpenGL or whatever (have a nice perpetual loading animation (like a spinning circle) and a filename) and simply swap the render context we need for when the loading starts/stops and bob's your uncle.

This is easy on paper, it's actually a bit tricky to do reliably in practice (esp. when accounting for cross platform support and whatnot)
"this is not the bottleneck you are looking for"
CuteAlien
Admin
Posts: 9634
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: What is happening when an .irr scene file is loading?

Post by CuteAlien »

Yeah, don't think it's possible yet without modifying engine. We have added a IMeshTextureLoader interface for such callbacks for the meshloaders recently (some using it already, some not yet), but not yet for the scene-loader (would need a change in CTextureAttribute or maybe in CNullDriver::loadTextureFromFile). In theory it might somehow be possible by writing an archive-filesystem which wraps the normal file-system, but I never experimented with that - so no guarantees.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
ibax
Posts: 193
Joined: Thu Jun 21, 2007 8:56 am
Location: hungary
Contact:

Re: What is happening when an .irr scene file is loading?

Post by ibax »

Hi! Thanks for replies...

I was able to catch the texture loading event, and I'm writing it into a textfile.

Code: Select all

if ( event.EventType        == EET_LOG_TEXT_EVENT)
        {   
            ExAll_pic_load_counter++;
            textLog.writeLogString( "IRRLICHT LOG: " , (char*)event.LogEvent.Text );
        }
I extended this part of code with a simple

Code: Select all

env->addStaticText()
function with the value of 'ExAll_pic_load_counter', but unfortunately did not work.
CuteAlien
Admin
Posts: 9634
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: What is happening when an .irr scene file is loading?

Post by CuteAlien »

Also slightly risky as logs depend on the log-level. Thought in theory... sending events for that might not be a bad idea (relative low cost).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
ibax
Posts: 193
Joined: Thu Jun 21, 2007 8:56 am
Location: hungary
Contact:

Re: What is happening when an .irr scene file is loading?

Post by ibax »

Ok, so you think should this work? When I put the addMessageBox where the log event is written into the text file?! I tried it, but I saw only one number (the sum of loaded textures) after the whole irr file is loaded.

Or should I put the env->addStaticText part into the main() part, somewhere here?

Code: Select all

while(device->run())
    {
        driver->beginScene(true, true, SColor(0,200,200,200));
        smgr->drawAll();
CuteAlien
Admin
Posts: 9634
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: What is happening when an .irr scene file is loading?

Post by CuteAlien »

You might have the problem that the gui is not updated. That only happens when you render. So you would have to update rendering in the event-receiver when you get those messages. Not entirely sure if that is safe - but it might work.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
ibax
Posts: 193
Joined: Thu Jun 21, 2007 8:56 am
Location: hungary
Contact:

Re: What is happening when an .irr scene file is loading?

Post by ibax »

Hello,

What does this update rendering mean in practice?
Executing an smgr->drawAll() function call?
CuteAlien
Admin
Posts: 9634
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: What is happening when an .irr scene file is loading?

Post by CuteAlien »

Yeah. Or for gui it's guienvironment->drawAll(). Also needs driver->beginScene() and endScene().
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
ibax
Posts: 193
Joined: Thu Jun 21, 2007 8:56 am
Location: hungary
Contact:

Re: What is happening when an .irr scene file is loading?

Post by ibax »

CuteAlien wrote:Yeah. Or for gui it's guienvironment->drawAll(). Also needs driver->beginScene() and endScene().
Thanks for the help. I will try this today...
ibax
Posts: 193
Joined: Thu Jun 21, 2007 8:56 am
Location: hungary
Contact:

Re: What is happening when an .irr scene file is loading?

Post by ibax »

Unfortuntaly this code is causing error:

Code: Select all

if ( event.EventType        == EET_LOG_TEXT_EVENT)
        {   
            admin.ExAll_pic_load_counter++;
            textLog.writeLogString( "IRRLICHT LOG: " , (char*)event.LogEvent.Text );
 
            char* _text = new char[16];
            sprintf_s ( _text , 15 ,"%d %d" , admin.ExAll_pic_load_counter , admin.ExAll_pic_load_counter );
            stringw tmp( _text );
 
            driver->beginScene(true, true, SColor(0,192,192,192));
            device->getGUIEnvironment()->addStaticText( tmp.c_str() ,rect<s32>( 400 , 500 , 600 , 800 ), false, false, 0, -1);
            smgr->drawAll();                
            driver->endScene();
 
        }

Error:

Code: Select all

20:59:1244   IRRLICHT LOG:  Loaded texture: load_hd_01.jpg
20:59:1245   IRRLICHT LOG:  DIRECT3D9 begin scene failed.
20:59:1245   IRRLICHT LOG:  DIRECT3D9 begin scene failed.
20:59:1246   IRRLICHT LOG:  DIRECT3D9 begin scene failed.
....
If I change the smgr->drawAll(); to env->drawAll(); the same is happening. Error.


My original device was created as a Direct3D9 device

:(
MartinVee
Posts: 139
Joined: Tue Aug 02, 2016 3:38 pm
Location: Québec, Canada

Re: What is happening when an .irr scene file is loading?

Post by MartinVee »

Did you call beginScene() while already inside another beginScene()?
Cube_
Posts: 1010
Joined: Mon Oct 24, 2011 10:03 pm
Location: 0x45 61 72 74 68 2c 20 69 6e 20 74 68 65 20 73 6f 6c 20 73 79 73 74 65 6d

Re: What is happening when an .irr scene file is loading?

Post by Cube_ »

there is insufficient code to determine why the beginScene() command failed.
MartinVee's suggestion is probably the cause if I'd have to guess though.
"this is not the bottleneck you are looking for"
ibax
Posts: 193
Joined: Thu Jun 21, 2007 8:56 am
Location: hungary
Contact:

Re: What is happening when an .irr scene file is loading?

Post by ibax »

What I would like to achieve is to refresh the screen with my 'static text', which is loaded when a texture is loaded into memory... Another suggestion was to refresh the screen...
But I tried also simply calling the env->drawAll() and smgr->drawAll() functions, withous positive results.... :(
Post Reply