static void set_polygon_shape( const World& trans, const float l, const float t, const float r, const float b, b2PolygonShape& out) { const b2Vec2 lt = trans.Ci2BoxTranslation(ci::Vec3f(l, t, 0.0f), nullptr); // using nullptr for the sprite will make the polygon be in world space const b2Vec2 rb = trans.Ci2BoxTranslation(ci::Vec3f(r, b, 0.0f), nullptr); b2Vec2 vtx[4]; vtx[0].Set(lt.x, lt.y); vtx[1].Set(rb.x, lt.y); vtx[2].Set(rb.x, rb.y); vtx[3].Set(lt.x, rb.y); out.Set(vtx, 4); }
bool CollidableTemplate::ConfigurePoly(const TiXmlElement *element, b2PolygonShape &shape) { // process child elements for (const TiXmlElement *child = element->FirstChildElement(); child != NULL; child = child->NextSiblingElement()) { ConfigurePolyItem(child, shape); } // update other properties shape.Set(shape.m_vertices, shape.m_vertexCount); return true; }