loadingscreen during smgr->getMesh

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.
Post Reply
mark01
Posts: 32
Joined: Sat Sep 08, 2007 1:27 am

loadingscreen during smgr->getMesh

Post by mark01 »

how is it possible to do a loadscreen animation during the getMesh Process.
I only have one big mesh and I want to display a loadinganimation (think the best way is to work with a timer) during the texture loads.

If I put the smgr->getMesh Call in a While loop it will stuck on that call until the whole thing is loaded, so I only may display a frozen picture.

Im not an expert in programming, so perhaps you have some ideas how to do a loading screen with a small animation during the getMesh Process
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Doing an actual animation during loading is pretty hard.. I've tried personally in raw OpenGL and never managed to get it perfect as you need multi-threading (a loading thread and a rendering thread) but things like texture loading are not thread safe so you get some strange behaviour going on like textures being overwritten.

It's easy to just do a loading bar showing how far through loading the application is. Something like this:

Code: Select all


void updateProgress(int prog) {
  
  device->run(); // This may or not be necessary, not sure
  driver->beginScene();
  renderProgBar(prog);
  driver->endScene();

}

int main() {
  
  // Setup irrlicht

  // Start loading stuff:
  loadMesh1();
  updateProgress(50);
  loadMesh2();
  updateProgress(100);

  // Finished loading, now render whatever you were loading
  while (device->run()) {
    //render
  }
  
}
What updateProgress() does is to draw to the backbuffer a progress bar, as defined by the renderProgBar() function you'd implement yourself and then switch the buffers to put it on the screen. It then stays on the screen until the next call to updateProgress() which will then update the screen with the next amount of progress made.
Image Image Image
mark01
Posts: 32
Joined: Sat Sep 08, 2007 1:27 am

Post by mark01 »

thanks for the answer. The problem is that I have only one big mesh. I think the loadingbar thing only makes sense with more meshes cause you have to put the drawing calls inbetween the several mesh loadings.

think the problem with the one big mesh is that its only possible to display an animation in a seperate loop with multithreading like you said.

Is it perhaps possible to load a avi file before the smgr->getmesh call or something
FuzzYspo0N
Posts: 914
Joined: Fri Aug 03, 2007 12:43 pm
Location: South Africa
Contact:

Post by FuzzYspo0N »

my suggestion is create a animated sprite (there is one on the forums that works really well and is so easy)

That way, the animation can run off the time. And possible to load a mesh (ill try got to a example its just time is pushing this weekend.The other option is to break down your mesh into textures and stuff, or to make your own weird callback inside the mesh loader.

load texture1
load texture2
load texture3
load texture4
load texture5

apply model texture (texture1)
apply model texture (texture2)
apply model texture (texture3)
apply model texture (texture4)
apply model texture (texture5)


that breaks it into piecces to show a progress bar. The other option, multithreading :>?
mark01
Posts: 32
Joined: Sat Sep 08, 2007 1:27 am

Post by mark01 »

could you get a little bit more detailed about the animated sprite thing?
how do I make a animated sprite? Think a Loadingbar with about 10 images would be enough. How do I get a animated sprite out of it?

with the well working thing on the forum I think you mean the animatedsprite-class from arras, right? How do I load my animated sprite when I have one?

sorry bout the stupid questions, never did something like that before
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

Animated sprite thing won't work. Like JP said you can't draw the scene and load a texture at the same time.
Best option is the wierd callback route- copy and edit the mesh loader, make it pause during loading at regular intervals, and call your program to update the loading bar. You then use your modfied mesh loader to load the mesh instead of using smgr->getMesh
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
mark01
Posts: 32
Joined: Sat Sep 08, 2007 1:27 am

Post by mark01 »

hmm think thats too complicated for me :(
don't know where to find the loading function for smgr->getmesh()
and where I have to put the code
Post Reply