Panda3D Manual: Loading the Grassy Scenery (C++)This page is not in the table of contents. With Panda3D running properly, it is now possible to load some grassy scenery. Update your code as follows: #include "pandaFramework.h" #include "pandaSystem.h" PandaFramework framework; int main(int argc, char *argv[]) { //load the window and stuff framework.open_framework(argc, argv); framework.set_window_title("My Panda3D Window"); WindowFramework *window = framework.open_window(); //load the environment model NodePath environ = window->load_model(framework.get_models(),"models/environment"); environ.reparent_to(window->get_render()); environ.set_scale(0.25,0.25,0.25); environ.set_pos(-8,42,0); //do the rest framework.main_loop(); framework.close_framework(); return (0); } The command Panda3D contains a data structure called the scene
graph. The scene graph is a tree containing all objects
that need to be rendered. At the root of the tree is an object named
To install the grassy scenery model into the scene
graph, we use the method Finally, we adjust the position and scale of the model.
In this particular case, the environment model is a little too large
and somewhat offset for our purposes. The Go ahead and run the program. You should see this: The rock and tree appear to be hovering. The camera is slightly below ground, and backface culling is making the ground invisible to us. If we reposition the camera, the terrain will look better. © Carnegie Mellon University 2010 |