0

嗨,在 BOX2d 中,我有一个夹具,我通过以下方式知道它的多边形:

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

现在如何获取顶点以便确切地知道它具有什么形状,即矩形正方形等。

4

1 回答 1

0

如果您知道它是一个多边形,请将其转换为 b2PolygonShape 并调用 GetVertices()。

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

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

于 2011-01-06T14:18:59.097 回答