예제 #1
0
bool CollidableTemplate::ConfigureEdge(const TiXmlElement *element, b2PolygonShape &shape)
{
	// process child elements
	for (const TiXmlElement *child = element->FirstChildElement(); child != NULL; child = child->NextSiblingElement())
	{
		const char *name = child->Value();
		switch (Hash(name))
		{
		case 0x154c1122 /* "vertex1" */:
			child->QueryFloatAttribute("x", &shape.m_vertices[0].x);
			child->QueryFloatAttribute("y", &shape.m_vertices[0].y);
			break;

		case 0x144c0f8f /* "vertex2" */:
			child->QueryFloatAttribute("x", &shape.m_vertices[1].x);
			child->QueryFloatAttribute("y", &shape.m_vertices[1].y);
			break;
		}
	}

	shape.SetAsEdge(shape.m_vertices[0], shape.m_vertices[1]);

	return true;
}