progress bar while loading and streaming questions

hello!

i just found that nice DirectWaitBar.
i would like to use it at startup while loading all models and other stuff that i use in my scene.
i think it’s not possible, because while the “loadtime-hit” i can’t do anything in my program. nevertheless, do you have any ideas?

greets, kampfgnu

a bit more specific:
i am doing a virtual gallery.
you can move through rooms, click objects to get a detailed information about each object, you can zoom the object-images and so on.
i have several “screens” in my scene.
a searchmenu, detailsmenu, mainmenu and 2 or 3 other menus.
e.g. the searchmenuClass is (returns) a nodepath when created, all elements of the searchscreen (buttons, texts,…) are parented to that nodepath. i show()/hide() the nodepath when “search” is clicked.
every screen has more or less images and a big backgroundimage(1024x1024).
and of course i have my 3dview displayed on a region somwhere on the screen.

finally, loads of images, models, sound have to be loaded.
it takes about 5 seconds on my notebook (2 GB RAM, 2.2 dual core, nvidia 8600m gt).
ok, thats not that bad right now, but i have just 3 rooms with its objects loaded right now. it will be 21 rooms later on.

so i maybe i have to think about not loading all the stuff at the same time…and kind of stream later on…
do you have some tips?

i done at my demos a clustering methode of my rooms and streamed with distance measure between cam and object. everything depends how fast you can transfer between your harddisc and your graphix ram.

maybe try this way, try to use the distance to stream but use two steps, first stream on your ram and aftwards on the graphics card.

i think that would be not that much reducing your perfomance.

greetz
dirk

thanks dirk!
so while you are moving through the rooms, you load and unload your models depending on where you are moving?
doesn’t every loader.loadModel-call give you a loadtimehit (while loading the object, nothing will happen) ?

ok to the other “problem”, the preloader on startup:
i came to the conclusion, that i just do that manually.
i just initialise my classes (menus and 3dmodels) one after the other and while doing so, i add values to my waitbar.

self.menuMain = MainMenu()
self.waitbar['value'] += 5
base.graphicsEngine.renderFrame()
self.menuSearch = SearchMenu()
base.graphicsEngine.renderFrame()
self.waitbar['value'] += 5
base.graphicsEngine.renderFrame()
self.menuDetails = DetailsMenu()
self.waitbar['value'] += 5
base.graphicsEngine.renderFrame()

…and so on.

greetzzz

:smiley:

try do that parallel :wink: call your menus in one thread and your objects :smiley:

create a dictionary where all your models are in, and load them in your liked sorting without doing anything by hand.

then use a time value for checking your dictionary and your sort models :smiley:

from threading import Thread
....

Using threading in conjunction with Panda will be very bad, unless you have built a custom version of Panda that is thread-safe (the default Panda provided here is not compiled to be thread-safe, because enabling thread-safety causes additional overhead which makes it run overall a little bit slower).

But if you have a thread-safe panda, you can just use the callback parameter to loader.loadModel() to load your models in a sub-thread automatically, and call your function when it’s done. No need to spawn threads directly.

But you don’t need to use threading to solve this problem. Another approach is to call base.graphicsEngine.renderFrame() from time to time while you are loading models, so you can update the wait bar as you go.

David