I am currently doing the SceneGraph tutorial, and I copy all the files to a folder which I have set aside for Panda3D, something like c:\programming\panda3d\scenegraph.
However, when I run the tutorial, I keep getting the error that the models and texture files cannot be found. I have to fix this with:
mydir = os.path.abspath(sys.path)
mydir = Filename.fromOsSpecific(mydir).getFullpath()
self.sky = loader.loadModel(mydir + "/models/solar_sky_sphere")
What really puzzles me is for the bvwdemo and the official tutorials, I do not need to do this at all load in the files! All they need is
panda = loader.loadModel("panda")
The bvwdemo and the helloworld tutorial are also in the folder c:\programming\panda3d (in folders of their own).
Why is this happening?
If you look in the “etc” directory you will find a file named Config.prc. This defines various configurations of Panda, including where to look for models. If you open the config file with a text editor, you will find this line:
This is one of the lines that tells panda where it can look for models. You can add more model-path configurations in this file, which Panda will use when searching for models. This is also why they only need to use the model file name without using any sort of path. It is already defined in the Config file.
Panda can also search the directory you are running your script from. For example, if your sky_sphere is in a folder “models” which is located in the same directory as your script, you can use:
self.sky = loader.loadModel("models/solar_sky_sphere")
without having to explicitly append the full path.