void Animation::ReadXml(const char* filename) { m_animationParts.clear(); // clear our parts list first // create a new xml document XmlDocument doc; doc.Load(filename); TiXmlHandle * hdoc = doc.Handle(); TiXmlElement * root = hdoc->FirstChildElement().Element(); if(root != 0) { TiXmlElement * child = root->FirstChildElement(); // loop through children while(child) { // whats the name of this part string partName = (string)child->Value(); // add this part to the part map m_animationParts[partName] = new AnimationPart(child); // move to the next game object child = child->NextSiblingElement(); } } }
void MaterialManager::Initialise(char *materialXMLFile) { // read through the xml file and load all materials XmlDocument doc; doc.Load(materialXMLFile); TiXmlHandle * hdoc = doc.Handle(); TiXmlElement * root = hdoc->FirstChildElement().Element(); TiXmlElement * child = root->FirstChildElement(); // loop through our materials while(child) { // get the name of the material const char * matName = XmlUtilities::ReadAttributeAsString(child, "", "name"); // create the new material Material* mat = new Material(matName); mat->ReadXml(child); // read the properties m_materialMap[matName] = mat; // add to the material map // move to the next material child = child->NextSiblingElement(); } }
void LoadAllBlockTypeInfo() { XmlDocument blockXML; blockXML.Load("blocks.xml"); for (unsigned int i = 0; i < blockXML.DocumentElement->SubElements.count(); i++) { XmlElement *typeElem = blockXML.DocumentElement->SubElements[i]; TypeInfo *typeInfo = new TypeInfo(); typeInfo->Name = typeElem->getNode("Name")->Text; typeInfo->ID = typeElem->getNode("ID")->Text.toInt(); typeInfo->Destructability = typeElem->getNode("Destructability")->Text.toInt(); typeInfo->TheTexture = new Texture(); typeInfo->TheTexture->ImgFile = new File(typeElem->getNode("Filename")->Text); LoadedTypeInfo.Add(typeInfo); } Log::Msg("Successfully loaded all block type info.", Log::Info); }