Ejemplo n.º 1
0
bool
MeshBase::serialize(TinyXML::TiXmlElement &n) const
{
	n.SetAttribute("type", type().str().c_str());
	n.SetDoubleAttribute("rotation", m_rotation);

	/* color */
	TinyXML::TiXmlElement l_color("color");
	l_color.SetDoubleAttribute("r", m_color[0]);
	l_color.SetDoubleAttribute("g", m_color[1]);
	l_color.SetDoubleAttribute("b", m_color[2]);
	l_color.SetDoubleAttribute("a", m_color[3]);
	n.InsertEndChild(l_color);

	/* texture */
	if (m_tdata->isLoaded()) {
		TinyXML::TiXmlElement l_texture("texture");
		l_texture.SetAttribute("id", m_tdata->id().str().c_str());
		n.InsertEndChild(l_texture);
	}

	/* texture coordinates */
	for (int i = 0; i < m_tcdata->count(); ++i) {
		float l_u, l_v;
		if (m_tcdata->get(i, l_u, l_v)) {
			TinyXML::TiXmlElement l_vector("tcoord");
			l_vector.SetDoubleAttribute("u", l_u);
			l_vector.SetDoubleAttribute("v", l_v);
			n.InsertEndChild(l_vector);
		} else MMWARNING("Failed to serialize text coord %d", i);
	}

	/* vertexes */
	for (int i = 0; i < m_vdata->count(); ++i) {
		float l_x, l_y;
		if (m_vdata->get(i, l_x, l_y)) {
			TinyXML::TiXmlElement l_vector("vector");
			l_vector.SetDoubleAttribute("x", l_x);
			l_vector.SetDoubleAttribute("y", l_y);
			n.InsertEndChild(l_vector);
		} else MMWARNING("Failed to serialize vertex %d", i);
	}

	return(true);
}
Ejemplo n.º 2
0
bool
SceneBase::serialize(TinyXML::TiXmlElement &n) const
{
	n.SetAttribute("id", id().str().c_str());
	n.SetAttribute("type", type().str().c_str());

	SceneLayerList::const_reverse_iterator l_i;
	SceneLayerList::const_reverse_iterator l_c = m_layers.rend();
	for (l_i = m_layers.rbegin(); l_i != l_c; ++l_i) {
		TinyXML::TiXmlElement l_element("layer");
		if ((*l_i)->serialize(l_element))
			n.InsertEndChild(l_element);
	}
	
	return(true);
}
Ejemplo n.º 3
0
bool
EntityBase::serialize(TinyXML::TiXmlElement &n) const
{
	n.SetAttribute("id", id().str().c_str());
	n.SetAttribute("type", type().str().c_str());

	ComponentList::const_reverse_iterator l_i;
	ComponentList::const_reverse_iterator l_c = m_components.rend();

	for (l_i = m_components.rbegin(); l_i != l_c; l_i++) {
		TinyXML::TiXmlElement l_element("component");
		if ((*l_i)->serialize(l_element))
			n.InsertEndChild(l_element);
	}
	
	return(true);
}
Ejemplo n.º 4
0
bool
EngineBase::serialize(TinyXML::TiXmlElement &n) const
{
	n.SetDoubleAttribute("fps", m_fps);
	n.SetDoubleAttribute("ups", m_ups);
	n.SetAttribute("suspendable", m_suspendable ? "t" : "f");

	if (m_scene_manager) {
		TinyXML::TiXmlElement l_element("scenes");

		if (!m_scene_manager->serialize(l_element)) {
			MMWARNING1("Scene Manager serialization failed");
			return(false);
		}

		n.InsertEndChild(l_element);
	}

	return(true);
}