//--------------------------------------------------------- void DocumentXML::finalize() { assert(NodeStack.size() == 1 && "not completely backtracked"); addSubNode("ReferenceSection"); addSubNode("Types"); for (XML::IdMap<QualType>::iterator i = Types.begin(), e = Types.end(); i != e; ++i) { if (i->first.hasLocalQualifiers()) { writeTypeToXML(i->first); addAttribute("id", getPrefixedId(i->second, ID_NORMAL)); toParent(); } } for (XML::IdMap<const Type*>::iterator i = BasicTypes.begin(), e = BasicTypes.end(); i != e; ++i) { writeTypeToXML(i->first); addAttribute("id", getPrefixedId(i->second, ID_NORMAL)); toParent(); } toParent().addSubNode("Contexts"); for (XML::IdMap<const DeclContext*>::iterator i = Contexts.begin(), e = Contexts.end(); i != e; ++i) { addSubNode(i->first->getDeclKindName()); addAttribute("id", getPrefixedId(i->second, ID_NORMAL)); if (const NamedDecl *ND = dyn_cast<NamedDecl>(i->first)) addAttribute("name", ND->getNameAsString()); if (const TagDecl *TD = dyn_cast<TagDecl>(i->first)) addAttribute("type", getPrefixedId(BasicTypes[TD->getTypeForDecl()], ID_NORMAL)); else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(i->first)) addAttribute("type", getPrefixedId(BasicTypes[FD->getType()->getAs<FunctionType>()], ID_NORMAL)); if (const DeclContext* parent = i->first->getParent()) addAttribute("context", parent); toParent(); } toParent().addSubNode("Files"); for (XML::IdMap<std::string>::iterator i = SourceFiles.begin(), e = SourceFiles.end(); i != e; ++i) { addSubNode("File"); addAttribute("id", getPrefixedId(i->second, ID_FILE)); addAttribute("name", escapeString(i->first.c_str(), i->first.size())); toParent(); } toParent().toParent(); // write the root closing node (which has always subnodes) Out << "</" << NodeStack.top() << ">\n"; }
void World::init() { addAction("update", &World::update); std::map<std::string, SunResource *> meshMap; SunResourceService *resource = services.get<SunResourceService>(); resource->getResourceManager("models")->addResource("player", new SunModelResource("res/Graphics/Models/Player.dae", &meshMap)); resource->getResourceManager("meshes")->addResources(meshMap); meshMap.clear(); resource->getResourceManager("models")->addResource("cube", new SunModelResource("res/Graphics/Models/Cube.dae", &meshMap)); resource->getResourceManager("meshes")->addResources(meshMap); meshMap.clear(); resource->getResourceManager("textures")->addResource("skin", new SunTextureResource("res/Graphics/Textures/skin.png")); SunTextureResource *skinTexture = (SunTextureResource *)resource->getResourceManager("textures")->getResource("skin"); resource->getResourceManager("materials")->addResource("skin", new SunMaterialResource(skinTexture, 4.0f)); resource->getResourceManager("textures")->addResource("grass", new SunTextureResource("res/Graphics/Textures/grass.png")); SunTextureResource *grassTexture = (SunTextureResource *)resource->getResourceManager("textures")->getResource("grass"); resource->getResourceManager("materials")->addResource("grass", new SunMaterialResource(grassTexture, 4.0f)); resource->getResourceManager("sounds")->addResource("sound", new SunAudioBufferResource("/home/jonathan/fluidsynth.wav")); std::shared_ptr<Chunk> chunk = std::make_shared<Chunk>(); chunk->init(); addSubNode(chunk); std::shared_ptr<SunObject> player = std::make_shared<SunObject>("player"); player->addTag("textured"); player->newMesh("player", "Player", "skin"); player->setPosition(glm::vec3(8.0f, 8.0f, 8.0f)); player->init(); addSubNode(player); std::shared_ptr<SunShadowDirectionalLight> _dir = std::shared_ptr<SunShadowDirectionalLight>(new SunShadowDirectionalLight(glm::vec3(1.0f, 1.0f, 1.0f), glm::vec3(0.0f, -1.0f, 0.6f))); _dir->setResolution(glm::ivec2(4096, 4096)); _dir->setDistance(40.0f); _dir->setSize(glm::vec2(15.0f, 15.0f)); _dir->setCenter(glm::vec3(8.0f, 0.0f, 8.0f)); _dir->setTarget(this); _dir->addTag("shadow_directional_light"); _dir->init(); addSubNode(_dir); }
//--------------------------------------------------------- void DocumentXML::writeDeclToXML(Decl *D) { DeclPrinter(*this).Visit(D); if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { if (Stmt *Body = FD->getBody()) { addSubNode("Body"); PrintStmt(Body); toParent(); } } toParent(); }