0
votes

Hi In BOX2d I have a fixture I know its a polygon through:

b2Shape *sh = fixture->GetShape();
NSLog(@"Type %d", sh->GetType());
//this returns 1, means its a polygon.

Now how to get the vertices in order to know exactly what shape it has i.e. rectangle square etc.

1

1 Answers

0
votes

If you know it's a polygon, cast it to a b2PolygonShape and call GetVertices().

if(sh->GetType()==1)
{
    b2PolygonShape* poly = (b2PolygonShape*)sh;
    b2Vec2* verts = poly->GetVertices();
}

Docs: http://www.linuxuser.at/elements/doc/box2d/classb2_polygon_shape.htm#0e8a0b73c98b3e57f26772d14f252e8b