如何从夹具中取回b2PolygonShape? [BOX2d]

发布于 2024-10-10 15:31:57 字数 224 浏览 0 评论 0原文

你好 在 BOX2d 中,我有一个固定装置,我通过以下方式知道它是一个多边形:

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

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

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

赠我空喜 2024-10-17 15:31:57

如果您知道它是多边形,请将其转换为 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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文