bool MeshBase::deserialize(TinyXML::TiXmlElement &n) { TinyXML::TiXmlElement *l_child; int l_i; n.QueryFloatAttribute("rotation", &m_rotation); /* color */ l_child = n.FirstChildElement("color"); if (l_child) { l_child->QueryFloatAttribute("r", &m_color[0]); l_child->QueryFloatAttribute("g", &m_color[1]); l_child->QueryFloatAttribute("b", &m_color[2]); l_child->QueryFloatAttribute("a", &m_color[3]); } /* texture */ l_child = n.FirstChildElement("texture"); if (l_child) { const char *l_file = l_child->Attribute("id"); if (l_file) m_tdata->load(l_file); } /* texture coordinates */ for (l_child = n.FirstChildElement("tcoord"), l_i = 0; l_child; l_child = l_child->NextSiblingElement("tcoord")) { float l_u, l_v; l_child->QueryFloatAttribute("u", &l_u); l_child->QueryFloatAttribute("v", &l_v); if (!m_tcdata->set(l_i++, l_u, l_v)) { MMWARNING1("Failed to assign texture coordinate data."); break; } } /* vertexes */ for (l_child = n.FirstChildElement("vector"), l_i = 0; l_child; l_child = l_child->NextSiblingElement("vector")) { float l_x, l_y; l_child->QueryFloatAttribute("x", &l_x); l_child->QueryFloatAttribute("y", &l_y); if (!m_vdata->set(l_i++, l_x, l_y)) { MMWARNING1("Failed to assign vertex data."); break; } } return(true); }
bool VehicleRenderable::loadSceneNodes(TinyXml::TiXmlElement* ele) { TinyXml::TiXmlElement* nodeEle = ele->FirstChildElement("node"); while (nodeEle) { Ogre::String name = getAttrib(nodeEle, "name"); Ogre::SceneNode* node = NULL; if (name.empty()) node = mAttachNode->createChildSceneNode(); else node = mAttachNode->createChildSceneNode(name); mSceneNodes.push_back(node); Ogre::LogManager::getSingleton(). logMessage("VehicleRenderable : parsing <" + name + "> node..."); //process position TinyXml::TiXmlElement* pos = nodeEle->FirstChildElement("position"); node->setPosition(parseVector3(pos)); node->setInitialState(); //process scale TinyXml::TiXmlElement* scale = nodeEle->FirstChildElement("scale"); node->setScale(parseVector3(scale)); node->setInitialState(); //process rotate TinyXml::TiXmlElement* rotate = nodeEle->FirstChildElement("rotation"); node->setOrientation(parseQuaternion(rotate)); node->setInitialState(); //process entities TinyXml::TiXmlElement* entity = nodeEle->FirstChildElement("entity"); while (entity) { if (!loadEntity(entity, node)) return false; entity = entity->NextSiblingElement("entity"); } nodeEle = nodeEle->NextSiblingElement("node"); } return true; }
bool SceneBase::deserialize(TinyXML::TiXmlElement &n) { TinyXML::TiXmlElement *l_child; for (l_child = n.FirstChildElement("layer") ; l_child; l_child = l_child->NextSiblingElement("layer")) { const char *l_id = l_child->Attribute("id"); const char *l_type = l_child->Attribute("type"); SharedSceneLayer l_layer = FactoryBase::Instance()->createSceneLayer(l_type, l_id, *this); if (!l_layer) { MMWARNING("SceneLayer '%s' of type '%s' creation failed", l_id, l_type); continue; } if (!l_layer->deserialize(*l_child)) { MMWARNING("SceneLayer '%s' of type '%s' failed deserialization", l_id, l_type); continue; } pushLayer(l_layer); } return(true); }
bool EntityBase::deserialize(TinyXML::TiXmlElement &n) { TinyXML::TiXmlElement *l_child; for (l_child = n.FirstChildElement("component") ; l_child; l_child = l_child->NextSiblingElement("component")) { const char *l_id = l_child->Attribute("id"); const char *l_type = l_child->Attribute("type"); SharedComponent l_component = FactoryBase::Instance()->createComponent(l_type, l_id, *this); if (!l_component) { MMWARNING("Component '%s' of type '%s' creation failed", l_id, l_type); continue; } if (!l_component->deserialize(*l_child)) { MMWARNING("Component '%s' of type '%s' failed deserialization", l_id, l_type); continue; } pushComponent(l_component); } return(true); }
bool EngineBase::deserialize(TinyXML::TiXmlElement &n) { /* * Engine deserialization should ideally * take place BEFORE it has been started. */ TinyXML::TiXmlElement *l_element; l_element = n.FirstChildElement("scenes"); n.QueryFloatAttribute("fps", &m_fps); n.QueryFloatAttribute("ups", &m_ups); const char *l_suspendable = n.Attribute("suspendable"); m_suspendable = (l_suspendable && (l_suspendable[0] == 't' || l_suspendable[0] == 'T')); if (l_element && m_scene_manager) m_scene_manager->deserialize(*l_element); else if (l_element && !m_scene_manager) return(false); return(true); }
void GameElements::ConfigurationLoader::parseWeapons( TinyXML::TiXmlElement * root ) { ::std::cout<<"-- Loading weapons"<<::std::endl ; TinyXML::TiXmlElement * rootWeapons = root->FirstChildElement("weapons") ; for(TinyXML::TiXmlElement * element = rootWeapons->FirstChildElement("weapon") ; element!=NULL ; element = element->NextSiblingElement("weapon") ) { ::std::cout<<element->Attribute("name")<<::std::endl ; m_weaponsArchetypes.addArchetype(element) ; } }
void GameElements::ConfigurationLoader::parseMaps( TinyXML::TiXmlElement * root, Ogre::SceneManager * sceneManager ) { ::std::cout<<"-- Loading maps"<<::std::endl; TinyXML::TiXmlElement * rootUnits = root->FirstChildElement("maps") ; for(TinyXML::TiXmlElement * element = rootUnits->FirstChildElement("map") ; element!=NULL ; element = element->NextSiblingElement("map") ) { ::std::cout<<element->Attribute("name")<<::std::endl ; Map * map = new Map(sceneManager, element) ; m_maps.insert(::std::make_pair(map->getName(), map)) ; } }