コード例 #1
0
bool
ComponentBase::serialize(TinyXML::TiXmlElement &n) const
{
	n.SetAttribute("id", id().str().c_str());
	n.SetAttribute("type", type().str().c_str());
	return(true);
}
コード例 #2
0
bool
Box2DComponent::serialize(TinyXML::TiXmlElement &n) const
{
    if (!ComponentBase::serialize(n))
        return(false);

    switch (m_body_type) {
    case b2_staticBody:
        n.SetAttribute("body", "static");
        break;
    case b2_kinematicBody:
        n.SetAttribute("body", "kinematic");
        break;
    case b2_dynamicBody:
        n.SetAttribute("body", "dynamic");
        break;
    }

    n.SetDoubleAttribute("width", m_size.width());
    n.SetDoubleAttribute("height", m_size.height());

    n.SetDoubleAttribute("density", m_density);
    n.SetDoubleAttribute("friction", m_friction);

    return(true);
}
コード例 #3
0
ファイル: scenebase.cpp プロジェクト: creichert/marshmallow_h
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);
}
コード例 #4
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);
}
コード例 #5
0
ファイル: meshbase.cpp プロジェクト: creichert/marshmallow_h
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);
}
コード例 #6
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);
}