PDA

View Full Version : Loading .3ds-Files without interrupting Program flow


Stefan
05-12-2005, 05:30 AM
Hello everybody !

I am currently programing with Vizard 2.51. I want to load a number of 3ds-Files at runtime, without interrupting the program. I tried to use a seperate Thread for loading the files, but the program still stops when loading. (I created a new thread in Python and also tried to use a director function, it didnīt work out as I hoped)

Could anybody give me a hint ?

Thank you,
Stefan

farshizzo
05-12-2005, 11:11 AM
Hi,

The current version of Vizard blocks execution on file loads. The next version should fix this. If you need this functionality sooner let me know and I will create a plugin that implements it.

Stefan
05-13-2005, 06:19 AM
Hi farshizzo !
Thank you for your quick answer. How long will it take for the new version to be released ? I would be glad if I could get this functionality soon, so if you could create a plugin, that would be great. Have a nice day and thanks in advance,

Stefan

farshizzo
05-13-2005, 10:08 AM
Hi,

I'm not sure when the next release is going to be, so I'll just go ahead and build a plugin for you. I should have one ready by today.

farshizzo
05-13-2005, 02:17 PM
Hi,

I've attached a zip file to this post which contains the plugin delayload.dlc and a sample script testDelayLoad.py showing how to use it. Let me know if you have any problems with it.

Stefan
06-01-2005, 07:21 AM
Hi farshizzo !

I tried your plug-in and it works quite fine. Although I still have a problem with the blocking-version of the add-command. I will try it again later. But I have another question concerning the loading of 3ds-files. I use code that looks similar to this one:

tile = viz.add('myTile')
child = tile.getChild('childOfMyTile')
child.parent(tile)

Because I shuffle around large amounts of data, I might be forced to remove the object ( -> tile.remove() ) and load it again later, using the code above. When I load the object again, the function getChild produces an error (child not found).

Do you have an idea what might cause the error ?

Thanks,
Stefan

farshizzo
06-01-2005, 10:54 AM
Hi Stefan,

I tried your sample code on a model here and it worked fine. This is the code I used to test it:import viz
viz.go()

viz.move(0,0,-10)

def onkeydown(key):
global tile,child
if key == ' ':
tile = viz.add('testviz/reflect_logo.3ds')
child = tile.getchild('Sphere01')
child.parent(tile)
elif key == 'r':
tile.remove()

viz.callback(viz.KEYDOWN_EVENT,onkeydown)Let me know if I am doing anything different.

Also, why are you reparenting the child after you get it? When you get a child from a model Vizard retains its hierarchical structure.

Stefan
06-02-2005, 05:57 AM
Hi farshizzo !

You are doing exactly the same thing as I do. Thatīs quite funny. Your code works, mine not. Perhaps this might be related to the amount of objects I am loading ? Sometimes I load more than 1000 objects. I experienced other problems with Vizard 2.17, like objects disapearing or objects being at the wrong position and so on. Those things (mostly) happened when I loaded more than a specific number of objects.

Reparenting:
I do this because of the alignment of the object to the coordinate system. When the object is initally loaded, the object points upwards instead of forward (because y and z are exchanged in the local coordinate system). After the reparenting, the object is aligned correctly. Also I donīt know why. Is the child aligned to the coordinate system of the parent when you use the parent()-function ? If so, why isnīt this done when loading the file ? Iīm curious about this.

Another thing I just realized:
Currently the bottleneck of my application is the number of textures. When drawing with textures, the frame rate drops to 2 or 3 when all objects are visible. Without textures the framerate is 28 to 35. I guess the program is swapping textures in and out of the graphics card memory. Is there some way to work around this besides lowering the resolution or reducing the number of textures ?

Hm, that concludes my questions for today :D

Have a nice day, and thank you again,
Stefan

farshizzo
06-02-2005, 04:33 PM
Hi,

Have you tried out Vizard 2.51? This might fix these problems you are experiencing.

When you parent an object to another it will inherit the transformation of the parent. The same thing is done when loading files.

When your world is running click on the "Display Stats" button in the toolbar. It should print out some statistics of your simulation, including how much texture memory you are using. If this value is near the amount of memory on your graphics card then this is most likely your problem. How many textures do you have and how big are they? If you wish I could create a plugin to compress the textures of an object. This might help a little bit.

Stefan
06-08-2005, 12:28 AM
Hi farshizzo !

Is there a command to completely unload textures from memory, something like the remove-command just for images ? Also, if you find the time, a texture-compression plug-in would be nice.

Thanks,
Stefan

farshizzo
06-08-2005, 04:44 PM
Hi,

There is no command to remove textures. Also, when you load models, Vizard caches the textures so that other models can share the same textures. So even when you delete a model the texture is still in memory. The best solution would be to allow the user to clear the cache and free up the memory. This feature doesn't currently exist, but I will look into adding it to the next release.