Two problems with P3D files

Hi everyone,
I have an application written in Python and I want to distribute it using a P3D file. In this application I am using a C++ library that comes as a PYD which should also be included in the P3D file. One problem is that the library needs to load an XML file which is also contained in the P3D file.

My first question now is, how can I make the library aware of Panda3Ds virtual file system to access the XML file inside the C++ library? I would like to avoid reading the data with Python and open() and passing it to the library.

The second problem I encountered concerns the custom shaders I am using. I load *.sha files which are including other Cg shaders and this doesn’t seem to be working. I checked the content of my P3D file and the shaders are definitely there, but the Cg compiler is as far as I understand it also not aware of the virtual file system and thus #include should not work. Is there a way around it besides manually doing the including?

Thanks in advance


If you can pass an istream pointer to your library, then you can use vfs->open_read_file() to get a handle to the file via Panda’s VFS that you can pass in. Otherwise, you’ll have to pre-read the file and pass in the data.

Hmm, the include of .sha files is an issue I hadn’t thought of. We’ll have to see if there are hooks in the Cg compiler so we can make callbacks into Panda to find and read such files. In the meantime, you might need to fall back to explicitly copying the code into each shader file. Perhaps you could write a script to generate the fully-specified shader files for packaging.