Esempio n. 1
0
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);
}
bool
PositionComponent::deserialize(TinyXML::TiXmlElement &n)
{
	if (!ComponentBase::deserialize(n))
	    return(false);

	n.QueryFloatAttribute("x", &m_position[0]);
	n.QueryFloatAttribute("y", &m_position[1]);
	return(true);
}
Esempio n. 3
0
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);
}
Esempio n. 4
0
bool
Box2DComponent::deserialize(TinyXML::TiXmlElement &n)
{
    if (!ComponentBase::deserialize(n))
        return(false);

    const char *l_body = n.Attribute("body");

    m_body_type = b2_staticBody;
    if (l_body && l_body[0] == 'k')
        m_body_type = b2_kinematicBody;
    if (l_body && l_body[0] == 'd')
        m_body_type = b2_dynamicBody;

    n.QueryFloatAttribute("width", &m_size[0]);
    n.QueryFloatAttribute("height", &m_size[1]);

    n.QueryFloatAttribute("density", &m_density);
    n.QueryFloatAttribute("friction", &m_friction);

    return(true);
}