PDA

View Full Version : optimizing the loading of .wrl files


dan12345
06-10-2008, 01:39 AM
Hi
I'm trying to program an enviorment that supports adding multiple
instances of a .wrl image ( around 100-150 , and dynamically, during
the run of the program ).
The problem is that it takes a very long time and disrupts the flow of the program

adding for example 50 such objects using the "node3d.add(nameOfWlr)" takes about 5 seconds - it just seems a bit wasteful, since it is always the same .wrl file, and each time it loads it anew from the file into vizard. Is there any way to optimize this?
thanks
dan

farshizzo
06-10-2008, 10:00 AM
The most optimal change would be to clone the existing model. However, changing the appearance of one object will affect all its clones. If you want to make unique appearance changes to each model, then the second best thing is to make a copy of the existing model. Here is sample code that will add 50 objects of the same file using the clone technique:for x in range(50):
model = viz.add('model.wrl',cache=viz.CACHE_CLONE)
Here is similar code that will add 50 objects of the same file using the copy technique:for x in range(50):
model = viz.add('model.wrl',cache=viz.CACHE_COPY)

dan12345
06-10-2008, 11:36 PM
perfect, thanks