Changing the loader root

Greetings all!

I’m attempting to create an interface building utility that will allow me to essentially build the geometry of an interface live using Panda3d. To this end, I’m trying to better understand the model loader system.

I know that when loader loads a file with a relative path, it will attempt to load it from the loader path and also from the ‘.’ location (wherever the command line was located when ppython was run). After I start running, is there a way to change this location (i.e. what does the loader consider this location to be… is it the current working directory or does it come from somewhere else)?

On a related note, when I use the NodePath.writeBamFile method, are the texture references absolute or relative (and if relative, relative to what)?

Thank you for the help!
-Mark

To answer the first question: you can change the load-path. Check out this manual page:

panda3d.org/manual/index.php/Acces … _a_Program

The config-variable you want is “model-path”

But, personally, I feel it’s better not to mess around with search paths. I just think it’s error prone. So in all the code I write, I load files explicitly from a specific path. Here’s the template I use. In the main program, near the top, I put this code:

Figure out what directory this program is in.

MYDIR=os.path.abspath(sys.path[0])
MYDIR=Filename.fromOsSpecific(MYDIR).getFullpath()

Then, when I want to load a model, I do this:

loader.loadModel(MYDIR+’/nik-dragon’)

OK, second question: writing bam files. This is a little complicated. Every texture object in the scene graph contains two paths: one called _fullpath, which is the fully qualified absolute pathname of the texture, and one called _filename, which is usually the path as it appeared in the egg file. I say “usually” because you can access this path and change it at will.

The config variable “bam-texture-mode” controls what gets written to disk. The possible values are:

fullpath: write the _fullpath to disk
unchanged: write the _filename to disk
relative: convert _fullpath to a path that’s relative to the BAM file’s directory.
basename: strip the directory off of _filename, and write the basename.