Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

2. Creating the Universe: Loading Terrain > Loading files into Panda3D

Loading files into Panda3D

Loading files into a game is pretty easy with Panda3D, but there are some things to talk about now that we've seen it happen. We'll start by going over the path that Panda3D searches for files, and then we'll talk about a few file types we'll be using.

The model path

Panda3D searches a few different places for files when they are loaded, and these locations are controlled by the configuration file. There are a couple default folders in the Panda3D installation directory that are searched, but using them isn't really recommended. The best path to make use of is the most dynamic one, the path to the python file that's being run.

That means that when loading a file, it's best to use a relative path from the file that is launching the Panda3D application. Right now, that file is chp02_03.py. In that file, we used the path "../Models/Track.egg" to point to our model file. Our chp02_03.py file is located in "/BGP3D/Chapter02" and our model is located in "/BGP3D/Models". Thus, the "../" at the start of the path takes us out of the Chapter02 folder and puts us in the BGP3D folder. Then we enter the Models folder, and that's where we find Track.egg.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint