Panda3D Manual: Loading ModelsThe BasicsLoading static geometry is done using NodePath m = window->load_model(framework.get_models(), "mymodel.egg"); The path name specified in the loadModel can be an absolute path, or a relative path. Relative is recommended. If a relative path is used, then Panda3D will search its model path to find the egg file. The model path is controlled by panda's configuration file. Inserting the Model into the Scene GraphDo not forget that loading the model does not, by itself, cause the model to be visible. To cause Panda3D to render the model, you must insert it into the scene graph: m.reparent_to(window->get_render()); You can read more about The Scene Graph. Panda Filename SyntaxThe path used in the load_model call must abide by Panda3D's filename conventions. For easier portability, Panda3D uses Unix-style pathnames, even on Microsoft Windows. This means that the directory separator character is always a forward slash, not the Windows backslash character, and there is no leading drive letter prefix. (Instead of a leading drive letter, Panda uses an initial one-letter directory name to represent the drive.) There is a fairly straightforward conversion from Windows filenames to panda filenames. Always be sure to use Panda filename syntax when using a Panda3D library function, or one of the panda utility programs: # WRONG: Panda uses the To convert a Windows filename to a Panda pathname, use code similar to the following: #include "filename.h" To convert a Panda filename into a Windows filename, use code not unlike this: #include "filename.h" The Filename class can also be used in combination with Panda's ExecutionEnvironment utility class. Let's say, for instance, that you want to load a model, and the model is in the "model" directory that is in the same directory as the main program's executable file. Here is how you would load the model: #include "filename.h" You need to keep in mind that the Operating System's standard functions work with OS specific paths. So do not forget to convert your OS Generic paths back to OS Specific paths when using built-in functions. In cases that Panda offers equivalent functions through the Filename class, it is recommended to use that instead. © Carnegie Mellon University 2010 |