Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * A modified version of the Panda Hello World to
- * try Panda's Multifiles with TinyXML library.
- */
- // Panda3D
- #include "pandaFramework.h"
- #include "pandaSystem.h"
- #include "virtualFile.h"
- #include "virtualFileSystem.h"
- // TinyXML
- #define TIXML_USE_STL
- #include "tinyxml.h"
- PandaFramework framework;
- /*
- First of all, create the multifile:
- multify -ep "password" -cf asdf.mf demo.xml panda-model.egg
- Where
- password -> The password
- asdf.mf -> The multifile name
- panda-model.egg -> The panda
- demo.xml -> This XML file:
- <?xml version="1.0" encoding="UTF-8" ?>
- <foo>
- <asd>Hello world</asd>
- <fgh />
- <bar></bar>
- </foo>
- */
- int main(int argc, char *argv[]) {
- //open a new window framework
- framework.open_framework(argc, argv);
- //set the window title to My Panda3D Window
- framework.set_window_title("My Panda3D Window");
- //open the window
- WindowFramework *window = framework.open_window();
- //here is room for your own code
- VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr();
- if(vfs->mount("./asdf.mf", "./mount", VirtualFileSystem::MF_read_only, "password"))
- {
- TiXmlDocument doc;
- doc.Parse(vfs->read_file("./mount/demo.xml", false).c_str(), 0, TIXML_ENCODING_UTF8);
- TiXmlElement * root = doc.RootElement();
- root->SetAttribute("parsed", "yes");
- doc.SaveFile("demo2.xml");
- NodePath environ = window->load_model(framework.get_models(), "mount/panda-model.egg");
- // Reparent the model to render.
- environ.reparent_to(window->get_render());
- // Apply scale and position transforms to the model.
- environ.set_scale(0.25, 0.25, 0.25);
- environ.set_pos(-8, 42, 0);
- }
- //do the main loop, equal to run() in python
- framework.main_loop();
- //close the window framework
- framework.close_framework();
- return (0);
- }
Advertisement
Add Comment
Please, Sign In to add comment