Esempio n. 1
0
  EReturn getVector(const tinyxml2::XMLElement & xml_vector,
      Eigen::VectorXd & eigen_vector)
  {
    //!< Temporaries
    double temp_entry;
    int i = 0;

    if (!xml_vector.GetText())
    {
      INDICATE_FAILURE
      ;
      eigen_vector = Eigen::VectorXd(); //!< Null matrix again
      return PAR_ERR;
    }
    std::istringstream text_parser(xml_vector.GetText());

    //!< Initialise looping
    text_parser >> temp_entry;
    while (!(text_parser.fail() || text_parser.bad()))  //!< No commenting!
    {
      eigen_vector.conservativeResize(++i); //!< Allocate storage for this entry (by increasing i)
      eigen_vector(i - 1) = temp_entry;
      text_parser >> temp_entry;
    }
    return (i > 0) ? SUCCESS : PAR_ERR;
  }
Esempio n. 2
0
bool ChannelFavoritesSerializer::GetFavoritesResponseXmlDataDeserializer::VisitEnter(const tinyxml2::XMLElement& element, const tinyxml2::XMLAttribute* attribute)
{
    if (strcmp(element.Name(), "favorite") == 0)
    {
        std::string id = Util::GetXmlFirstChildElementText(&element, "id");
        std::string name = Util::GetXmlFirstChildElementText(&element, "name");

        //channels
        ChannelFavorite::favorite_channel_list_t channels;
        const tinyxml2::XMLElement* channels_element = element.FirstChildElement("channels");
        if (channels_element != NULL)
        {
            const tinyxml2::XMLElement* channel_element = channels_element->FirstChildElement();
            while (channel_element != NULL)
            {
                if (strcmp(channel_element->Name(), "channel") == 0)
                {
                    if (channel_element->GetText() != NULL)
                        channels.push_back(channel_element->GetText());
                }
                channel_element = channel_element->NextSiblingElement();
            }

        }

        ChannelFavorite cf(id, name, channels);

        m_favoritesList.favorites_.push_back(cf);

        return false;
    }

    return true;
}
Esempio n. 3
0
Vector3d<float> XMLHelper::parse(tinyxml2::XMLElement& elem)
{
	const auto x = elem.FloatAttribute("x");
	const auto y = elem.FloatAttribute("y");
	const auto z = elem.FloatAttribute("z");
	return Vector3d<float>(x, y, z);
}
Esempio n. 4
0
/**
 * Reads the attributed object id, comments, and artifacts.
 */
bool Translator::ReadAttributedObject( AttributedObject& aobj, 
		Context& ctxt, const tinyxml2::XMLElement & elem, bool bIdAttributeRequired )
{
	//Grab the ID.
	pcstr szid = elem.Attribute("id");
	if( szid == NULL)
	{
		if( bIdAttributeRequired )
			throw GnssMetadata::TranslationException( "Required id attribute not defined.");
	}
	else
		aobj.Id(szid);

	//Parse the comments.
	const XMLElement* pelem = elem.FirstChildElement("comment");
	for( ;pelem != NULL; pelem = pelem->NextSiblingElement("comment"))
	{
		const char* szFmt = pelem->Attribute("format");
		Comment::CommentFormat fmt = (strcmp(szFmt, "text") == 0)
			? Comment::text : Comment::html;
		Comment comment( pelem->GetText(), fmt);
		aobj.Comments().push_back( comment);
	}

	//Parse the Artifacts.
	pelem = elem.FirstChildElement("artifact");
	for( ;pelem != NULL; pelem = pelem->NextSiblingElement("artifact"))
	{
		AnyUri auri( pelem->GetText());
		aobj.Artifacts().push_back( auri);
	}

	return true;
}
Esempio n. 5
0
void Restaurant::decodeXML(tinyxml2::XMLElement & xml)
{
	Item::decodeXML(xml);
	variant = xml.IntAttribute("variant");
	open    = xml.BoolAttribute("open");
	updateSprite();
}
Esempio n. 6
0
/**
 * Writes the attributed object id, comments, and artifacts.
 */
void Translator::WriteAttributedObject(const AttributedObject& aobj, Context& ctxt, tinyxml2::XMLElement & elem, bool bIdAttributeRequired)
{
	//Write the ID.
	if( aobj.Id().length() > 0 )
		elem.SetAttribute( "id", aobj.Id().c_str());
	else if( bIdAttributeRequired )
		throw GnssMetadata::TranslationException( "Required id attribute not defined.");



	//Write the comments.
	CommentList::const_iterator citer = aobj.Comments().begin();
	for(; citer != aobj.Comments().end(); citer++)
	{
		XMLElement* pec = elem.GetDocument()->NewElement( "comment");
		const Comment& cmt = *citer;
		const char* szFormat = (cmt.Format() == Comment::text) ? "text":"html";
		pec->SetAttribute("format",szFormat);
		pec->SetText( cmt.Value().c_str());
		elem.InsertEndChild(pec);
	}

	//Write the Artifacts.
	AnyUriList::const_iterator aiter = aobj.Artifacts().begin();
	for(; aiter != aobj.Artifacts().end(); aiter++)
	{
		XMLElement* pec = elem.GetDocument()->NewElement( "artifact");
		pec->SetText( aiter->Value().c_str());
		elem.InsertEndChild(pec);
	}
}
bool GetObjectResponseSerializer::ItemXmlDataDeserializer::VisitEnter(const tinyxml2::XMLElement& element, const tinyxml2::XMLAttribute* attribute)
{
	Item * item;
	if (strcmp(element.Name(), "recorded_tv") == 0) 
	{     
		std::string objectId = Util::GetXmlFirstChildElementText(&element, "object_id");
		std::string parentId = Util::GetXmlFirstChildElementText(&element, "parent_id");
		std::string url = Util::GetXmlFirstChildElementText(&element, "url");
		std::string thumbnail = Util::GetXmlFirstChildElementText(&element, "thumbnail");
		std::string channelName = Util::GetXmlFirstChildElementText(&element, "channel_name");
		bool canBeDeleted = Util::GetXmlFirstChildElementTextAsBoolean(&element, "can_be_deleted");
		long size = Util::GetXmlFirstChildElementTextAsLong(&element, "size");
		long creationTime = Util::GetXmlFirstChildElementTextAsLong(&element, "creation_time");
		int channelNumber = Util::GetXmlFirstChildElementTextAsInt(&element, "channel_number");
		int channelSubnumber = Util::GetXmlFirstChildElementTextAsInt(&element, "channel_subnumber");
		RECORDEDTV_STATE state = (RECORDEDTV_STATE)  Util::GetXmlFirstChildElementTextAsInt(&element, "state");

		item = new RecordedTV(objectId, parentId, url,thumbnail,channelName,canBeDeleted,size,creationTime,channelNumber,channelSubnumber, state);

		tinyxml2::XMLElement * vElement = (tinyxml2::XMLElement*)(&element)->FirstChildElement("video_info");

		VideoInfoSerializer::Deserialize((XmlObjectSerializer<Response>&)m_parent, *vElement, ((RecordedTV*) item)->VInfo);
		
		m_items.push_back(item);
		return false;
	}

	if (strcmp(element.Name(), "video") == 0) 
	{     
		std::string objectId = Util::GetXmlFirstChildElementText(&element, "object_id");
		std::string parentId = Util::GetXmlFirstChildElementText(&element, "parent_id");
		std::string url = Util::GetXmlFirstChildElementText(&element, "url");
		std::string thumbnail = Util::GetXmlFirstChildElementText(&element, "thumbnail");
		std::string channelName = Util::GetXmlFirstChildElementText(&element, "channel_name");
		bool canBeDeleted = Util::GetXmlFirstChildElementTextAsBoolean(&element, "can_be_deleted");
		long size = Util::GetXmlFirstChildElementTextAsLong(&element, "size");
		long creationTime = Util::GetXmlFirstChildElementTextAsLong(&element, "creation_time");

		item = new Video(objectId, parentId, url,thumbnail,canBeDeleted,size,creationTime);
		m_items.push_back(item);
		return false;
	}

	if (strcmp(element.Name(), "audio") == 0) 
	{     
		item = new Audio();
		m_items.push_back(item);
		return false;
	}

	if (strcmp(element.Name(), "image") == 0) 
	{     
		item = new Image();
		m_items.push_back(item);
		return false;
	}

	return true;

}
	/**
	*	@brief This function takes the passed in SaveSlot, and writes it to the .xml file.
	*	@param This is the SaveSlot to be written.
	*/
	void WriteSaveSlot(SaveSlot s){
		string d = "SaveSlot" + std::to_string(s.m_id);
		const char * c = d.c_str();
		tinyxml2::XMLElement * saveSlot = xmlDoc.NewElement(c);

		//Inserts Values to the .xml file
		tinyxml2::XMLElement * pElement = xmlDoc.NewElement("TimePlayed");
		pElement->SetText(s.m_timePlayed);
		saveSlot->InsertEndChild(pElement);

		pElement = xmlDoc.NewElement("CurrentGold");
		pElement->SetText(s.m_currentGold);
		saveSlot->InsertEndChild(pElement);

		pElement = xmlDoc.NewElement("Levels");

		for (int i = 0; i < 7; i++){
			string level = "LVL" + std::to_string(i + 1);
			const char * c = level.c_str();
			tinyxml2::XMLElement * pListElement = xmlDoc.NewElement(c);
			pListElement->SetText(s.m_LVL_DATA[level]);

			pElement->InsertEndChild(pListElement);

			saveGame->InsertEndChild(saveSlot);
			saveSlot->InsertEndChild(pElement);
		}

		pElement = xmlDoc.NewElement("Achievements");
		for (int i = 0; i < 21; i++) {
			string ach = "ACH" + std::to_string(i + 1);
			const char * c = ach.c_str();
			tinyxml2::XMLElement * pListElement = xmlDoc.NewElement(c);
			pListElement->SetText(s.m_ACH_DATA[ach]);

			pElement->InsertEndChild(pListElement);

			saveSlot->InsertEndChild(pElement);
			saveGame->InsertEndChild(saveSlot);
		}

		pElement = xmlDoc.NewElement("Statistics");
		for (int i = 0; i < 10; i++) {
			string stat = "STAT" + std::to_string(i + 1);
			const char * c = stat.c_str();
			tinyxml2::XMLElement * pListElement = xmlDoc.NewElement(c);
			pListElement->SetText(s.m_ACH_DATA[stat]);

			pElement->InsertEndChild(pListElement);

			saveSlot->InsertEndChild(pElement);
			saveGame->InsertEndChild(saveSlot);
		}
	}
Esempio n. 9
0
  EReturn getMatrix(const tinyxml2::XMLElement & xml_matrix,
      Eigen::MatrixXd & eigen_matrix)
  {
    int dimension = 0;

    if (xml_matrix.QueryIntAttribute("dim", &dimension)
        != tinyxml2::XML_NO_ERROR)
    {
      INDICATE_FAILURE
      ;
      eigen_matrix = Eigen::MatrixXd(); //!< Null matrix again
      return PAR_ERR;
    }

    if (dimension < 1)
    {
      INDICATE_FAILURE
      ;
      eigen_matrix = Eigen::MatrixXd(); //!< Null matrix again
      return PAR_ERR;
    }
    eigen_matrix.resize(dimension, dimension);

    if (!xml_matrix.GetText())
    {
      INDICATE_FAILURE
      ;
      eigen_matrix = Eigen::MatrixXd(); //!< Null matrix again
      return PAR_ERR;
    }

    std::istringstream text_parser(xml_matrix.GetText());
    double temp_entry;
    for (int i = 0; i < dimension; i++) //!< Note that this does not handle comments!
    {
      for (int j = 0; j < dimension; j++)
      {
        text_parser >> temp_entry;
        if (text_parser.fail() || text_parser.bad()) //!< If a failure other than end of file
        {
          INDICATE_FAILURE
          ;
          eigen_matrix.resize(0, 0);
          return PAR_ERR;
        }
        else
        {
          eigen_matrix(i, j) = temp_entry;
        }
      }
    }

    return SUCCESS;
  }
Esempio n. 10
0
void Fruit::Load(tinyxml2::XMLElement const& element)
{
    char const* sprite = element.Attribute("Sprite");
    assert(sprite);
    m_Sprite.Load(sprite);
    m_Sprite.SetOriginToCentre();

    m_Score = element.IntAttribute("Score");
    m_Appear1 = element.IntAttribute("Appear1");
    m_Appear2 = element.IntAttribute("Appear2");
    m_Time = element.FloatAttribute("Time");
}
Esempio n. 11
0
void Elevator::decodeXML(tinyxml2::XMLElement & xml)
{
	clearCars();
	Item::decodeXML(xml);
	size.y = xml.IntAttribute("height");
	for (tinyxml2::XMLElement * e = xml.FirstChildElement("unserviced"); e; e = e->NextSiblingElement("unserviced")) {
		unservicedFloors.insert(e->IntAttribute("floor"));
	}
	for (tinyxml2::XMLElement * e = xml.FirstChildElement("car"); e; e = e->NextSiblingElement("car")) {
		Car * car = new Car(this);
		car->decodeXML(*e);
		cars.insert(car);
	}
	updateSprite();
}
Esempio n. 12
0
bool GetChannelsResponseSerializer::GetChannelsResponseXmlDataDeserializer::VisitEnter(const tinyxml2::XMLElement& element, const tinyxml2::XMLAttribute* attribute)
{
  if (strcmp(element.Name(), "channel") == 0) 
  {     
    long channelDvbLinkId = Util::GetXmlFirstChildElementTextAsLong(&element, "channel_dvblink_id");
    std::string channelId = Util::GetXmlFirstChildElementText(&element, "channel_id");
    std::string channelName = Util::GetXmlFirstChildElementText(&element, "channel_name");
    int channelNumber = Util::GetXmlFirstChildElementTextAsInt(&element, "channel_number");
    int channelSubNumber = Util::GetXmlFirstChildElementTextAsInt(&element, "channel_subnumber");
    Channel::DVBLinkChannelType channelType = (Channel::DVBLinkChannelType)Util::GetXmlFirstChildElementTextAsInt(&element, "channel_type");
    std::string channelLogoUrl = Util::GetXmlFirstChildElementText(&element, "channel_logo");

    Channel* channel = new Channel(channelId, channelDvbLinkId, channelName, channelType, channelLogoUrl, channelNumber, channelSubNumber);

    if (m_parent.HasChildElement(*&element, "channel_child_lock"))
    {
      channel->ChildLock = Util::GetXmlFirstChildElementTextAsBoolean(&element, "channel_child_lock");
    }

    m_channelList.push_back(channel);

    return false;
  }

  return true;
}
Esempio n. 13
0
bool XmlSaxHander::VisitExit( const tinyxml2::XMLElement& element )
{
    //log("VisitExit %s",element.Value());

    SAXParser::endElement(_ccsaxParserImp, (const CC_XML_CHAR *)element.Value());
    return true;
}
Esempio n. 14
0
/**
 * Processes the current element within the context of the attributed object.
 */
bool XmlProcessor::ReadElement( Context & ctxt, const tinyxml2::XMLElement & elem, AccessorAdaptorBase* pAdaptor)
{
	TranslatorId id = TE_END;
	const char* szNodeName = elem.Name();

	//Use the current translator if available to lookup appropriate
	//translator for the current element.   If not available,
	//do a global search.
	if( ctxt.pParent != NULL)
	{
		id = TranslatorIdFromElemName( szNodeName, ctxt.pParent->GetAllowedNodes() );	
	}
	else //Do a global lookup.  
	{
		for( int i = 0; i < COUNT_TRANSLATORS && id == TE_END; i++)
		{
			NodeEntry* pNodes = _Translators[i].translator.GetAllowedNodes();
			if(pNodes == NULL) continue;

			id = TranslatorIdFromElemName( szNodeName, pNodes);	
		}
	}

	//Get the translator and attempt to process the current
	//element.
	Translator& trans = TranslatorFromId( id);
	return trans.OnRead( ctxt, elem, pAdaptor);
}
Esempio n. 15
0
	void Animation2D::Read(const tinyxml2::XMLElement& el_ )
	{
		Animation::Read(el_);

		const tinyxml2::XMLElement *pElemFrame = el_.FirstChildElement("EventList")->FirstChildElement("Event");

		//float totalTime = 0.0f;

		while (pElemFrame != nullptr)
		{
			SetFrameEvent *pFrameEvent = NEW_AO SetFrameEvent();
			pFrameEvent->Read(const_cast<tinyxml2::XMLElement *>(pElemFrame));
			AddEvent(pFrameEvent);

			pElemFrame = pElemFrame->NextSiblingElement();

			/*unsigned int spriteID;
			pElemFrame->QueryUnsignedAttribute("spriteID", &spriteID);
			float time;
			pElemFrame->QueryFloatAttribute("time", &time);

			std::ostringstream str;
			str << spriteID;

			SetFrameEvent *pFrameEvent = NEW_AO SetFrameEvent();
			pFrameEvent->FrameID(str.str().c_str());
			pFrameEvent->Time(time + totalTime);
			AddEvent(pFrameEvent);

			pElemFrame = pElemFrame->NextSiblingElement();
			totalTime += time;*/
		}
	}
Esempio n. 16
0
void storeLight(
        tinyxml2::XMLElement& elt,
        const DirectionalLight& light) {
    storeVector(elt, light.m_IncidentDirection);
    storeColor(elt, light.m_Le);
    elt.SetName("DirectionalLight");
}
Esempio n. 17
0
void storeLight(
        tinyxml2::XMLElement& elt,
        const PointLight& light) {
    storeVector(elt, light.m_Position);
    storeColor(elt, light.m_Intensity);
    elt.SetName("PointLight");
}
Esempio n. 18
0
inline bool getValue(const tinyxml2::XMLElement& elt, Microseconds& microseconds) {
    uint64_t count;
    auto pChildElement = elt.FirstChildElement("Microseconds");
    if(pChildElement && getValue(*pChildElement, count)) {
        microseconds = Microseconds { count };
        return true;
    }
    return false;
}
Esempio n. 19
0
inline bool getValue(const tinyxml2::XMLElement& elt, std::unordered_map<std::string, T>& values) {
    values.clear();
    for(auto pChildElement = elt.FirstChildElement(); pChildElement; pChildElement = pChildElement->NextSiblingElement()) {
        if(!getValue(*pChildElement, values[pChildElement->Name()])) {
            return false;
        }
    }
    return true;
}
Esempio n. 20
0
inline bool getAttribute(const tinyxml2::XMLElement& elt, const char* name,
                         std::string& value) {
    auto ptr = elt.Attribute(name);
    if(ptr) {
        value = ptr;
        return true;
    }
    return false;
}
Esempio n. 21
0
void Box2D::Read(const tinyxml2::XMLElement& pEl_)
{
	//TODO


	const tinyxml2::XMLElement* pLocation_ = pEl_.FirstChildElement("Location");
	pLocation_->QueryFloatAttribute("x", &m_Center.x);
	pLocation_->QueryFloatAttribute("y", &m_Center.y);
	m_Center /= 100.0f; // TODO : to remove only for testing purpose
	//m_Center.x = -m_Center.x;
}
Esempio n. 22
0
		void XML::ParseTinyXmlElement(const tinyxml2::XMLElement& element)
		{
			//Parse this
			const char* text = element.GetText();
			if(text)
				m_data = text;

			//Parse attributes
			for(const tinyxml2::XMLAttribute* attribute = element.FirstAttribute(); attribute; attribute = attribute->Next())
			{
				m_attributes.insert(std::make_pair(string::ToLower(attribute->Name()), std::string(attribute->Value())));
			}

			//Parse children
			for(const tinyxml2::XMLElement* childElement = element.FirstChildElement(); childElement; childElement = childElement->NextSiblingElement())
			{
				XML* childNode = AddChild(childElement->Name());
				childNode->ParseTinyXmlElement(*childElement);
			}
		}
Esempio n. 23
0
inline void setValue(tinyxml2::XMLElement& elt, const TaskTimer& timer) {
    elt.DeleteChildren();

    auto taskDurations = computeTaskDurations<Microseconds>(timer);
    auto totalTime = std::accumulate(begin(taskDurations), end(taskDurations), Microseconds(0), std::plus<Microseconds>());
    setChildAttribute(elt, "TotalTime", totalTime);
    for(auto taskID: range(timer.getTaskCount())) {
        auto percentage = 100. * taskDurations[taskID].count() / totalTime.count();
        auto pChildElement = setChildAttribute(elt, timer.getTaskName(taskID).c_str(), taskDurations[taskID]);
        setAttribute(*pChildElement, "percentage", percentage);
    }
}
Esempio n. 24
0
bool Translator::ReadFirstElement( const char* pszelem, 
	const tinyxml2::XMLElement& container,  
	bool bRequired, bool bDefault)
{
	const XMLElement* pchild = container.FirstChildElement(pszelem);
	if( pchild == NULL)
	{
		if( !bRequired)
			return bDefault;
		else
		{
			char buff[256];
			sprintf( "Cannot find required boolean element %s in container %s", pszelem, container.Name());
			throw TranslationException(buff);
		}
	}
	else
	{
		return (strcmp( pchild->GetText(),"false")==0);
	}
}
Esempio n. 25
0
  EReturn getStdVector(const tinyxml2::XMLElement & xml_vector,
      std::vector<double> & std_vector)
  {
    //!< Temporaries
    double temp_entry;

    std_vector.resize(0);
    if (!xml_vector.GetText())
    {
      INDICATE_FAILURE
      return PAR_ERR;
    }
bool GetSchedulesResponseSerializer::GetSchedulesResponseXmlDataDeserializer::VisitEnter(const tinyxml2::XMLElement& element, const tinyxml2::XMLAttribute* attribute)
{

  if (strcmp(element.Name(), "schedule") == 0) 
  {    
	
    std::string scheduleId = Util::GetXmlFirstChildElementText(&element, "schedule_id");
    std::string userParam = Util::GetXmlFirstChildElementText(&element, "user_param");
    bool forceadd = Util::GetXmlFirstChildElementTextAsBoolean(&element, "force_add");

	tinyxml2::XMLElement* epg = (tinyxml2::XMLElement*)(&element)->FirstChildElement("by_epg");
	tinyxml2::XMLElement* manual = (tinyxml2::XMLElement*)(&element)->FirstChildElement("manual");

	 Schedule* s = NULL;
		
	if (epg->FirstChildElement("program_id") != NULL) //byEPG
	{
	
		std::string channelid = Util::GetXmlFirstChildElementText(epg, "channel_id");
		std::string programid = Util::GetXmlFirstChildElementText(epg, "program_id");

		bool repeat = Util::GetXmlFirstChildElementTextAsBoolean(epg, "repeat");
		bool newonly = Util::GetXmlFirstChildElementTextAsBoolean(epg, "new_only");
		bool recordseriesanytime = Util::GetXmlFirstChildElementTextAsBoolean(epg, "record_series_anytime");
		bool recordings_to_keep = Util::GetXmlFirstChildElementTextAsBoolean(epg, "recordings_to_keep");
		tinyxml2::XMLElement* pEl = (tinyxml2::XMLElement*)(epg)->FirstChildElement("program");
		Program* p = new Program();
		ProgramSerializer::Deserialize((XmlObjectSerializer<Response>&)m_parent, *pEl, *p);
		s = new Schedule(scheduleId,channelid,programid, p, recordings_to_keep,userParam,forceadd,repeat,newonly,recordings_to_keep);

	}else{

		std::string channelid = Util::GetXmlFirstChildElementText(epg, "channel_id");
		std::string title = Util::GetXmlFirstChildElementText(epg, "title");

		long starttime = Util::GetXmlFirstChildElementTextAsLong(epg, "start_time");
		int duration = Util::GetXmlFirstChildElementTextAsLong(epg, "duration");
		DayMask daymask = (DayMask)Util::GetXmlFirstChildElementTextAsInt(epg, "day_mask");
		bool recordings_to_keep = Util::GetXmlFirstChildElementTextAsBoolean(epg, "recordings_to_keep");
		s= new Schedule(scheduleId,channelid,title,starttime,duration,daymask,recordings_to_keep,userParam,forceadd);

	}
	
	if (s != NULL)
	m_scheduleList.push_back(s);

    return false;
  }

  return true;
}
Esempio n. 27
0
	void Animation::Read(const tinyxml2::XMLElement& el_)
	{
		IAssetable::Read(el_);

		const tinyxml2::XMLElement *pElemFrame = el_.FirstChildElement("EventList")->FirstChildElement("Event");

		while (pElemFrame != nullptr)
		{
			//get type event
			//EventFactory.Read()
			// 
			pElemFrame = pElemFrame->NextSiblingElement();
		}
	}
Esempio n. 28
0
DirectionalLight loadDirectionalLight(
        const Scene& scene,
        const tinyxml2::XMLElement& elt) {
    auto pExitantPower = elt.FirstChildElement("ExitantPower");
    if(pExitantPower) {
        Vec3f wi(0, 1, 0);
        getChildAttribute(elt, "IncidentDirection", wi);
        Vec3f exitantPower = zero<Vec3f>();
        getChildAttribute(elt, "ExitantPower", exitantPower);

        return DirectionalLight(wi, exitantPower, scene);
    }

    return { normalize(loadVector(elt)), loadColor(elt) };
}
Esempio n. 29
0
	void Sprite::Read( const tinyxml2::XMLElement& el_ )
	{
		Clear();
		IAssetable::Read(el_);

		const tinyxml2::XMLElement *pElem, *pChild;

		m_AssetFileName = el_.FirstChildElement("AssetFileName")->GetText();
		//m_Name = el_->Attribute("name");
		//m_Name = el_->Attribute("id");
		SetName(el_.Attribute("id")); // TODO : ID is not the name

		m_pTexture2D = Texture::loadTexture(m_AssetFileName.c_str());

		pElem = el_.FirstChildElement("PositionInTexture");
		int x, y, w, h;
		pElem->QueryIntAttribute("x", &x);
		pElem->QueryIntAttribute("y", &y);
		pElem->QueryIntAttribute("width", &w);
		pElem->QueryIntAttribute("height", &h);
		m_PositionInTexture.Set(x, y, w, h);

		pElem = el_.FirstChildElement("HotSpot");
		pElem->QueryIntAttribute("x", &m_Origin.x);
		pElem->QueryIntAttribute("y", &m_Origin.y);

		pElem = el_.FirstChildElement("CollisionList");
		pChild = pElem->FirstChildElement("Shape");

		while (pChild != nullptr)
		{
			IShape *pShape = IShape::LoadShape(*pChild);
			m_CollisionShapes.push_back(pShape);
			pChild = pChild->NextSiblingElement();
		}
	}
Esempio n. 30
0
inline bool getValue(const tinyxml2::XMLElement& elt, std::vector<T>& values) {
    values.clear();
    auto i = 0u;
    auto pChildElement = elt.FirstChildElement("v0");
    while(pChildElement) {
        T value;
        if(!getValue(*pChildElement, value)) {
            return false;
        }
        values.emplace_back(value);
        ++i;
        pChildElement = pChildElement->NextSiblingElement((std::string("v") + toString(i)).c_str());
    }
    return true;
}