为字母生成 b2Body

发布于 2024-12-10 18:16:02 字数 494 浏览 0 评论 0 原文

我想编写一个小游戏,处理字体和字母。我想让它们在 2d 空间中移动,我使用 box2dweb 作为物理引擎,这实际上做得非常出色。目前我正在努力解决的问题是为信件构建 b2Body 的问题。 Box2d 只能处理原始的凸形状,要构建更复杂的碰撞箱,我必须组合其中的一些形状。在图像中,我试图找出我想要达到的目标,一种算法,它采用字母的 svg 路径并生成一系列代表碰撞盒的 b2shapes。

黑色大写字母 A,一系列蓝色 b2Shapes,带有绿色描边

总而言之,我不知道在哪里可以如果有一个库能够做到这一点,请找到一些有关此的信息。即使这个库在 Javascript 中不可用,我也可以在服务器上完成这项工作。 我知道有 paper.js 和 raphalel,一些聪明的矢量库,但我还没有找到任何提示如何解决这个问题。 我很乐意提供任何形式的帮助、资源链接或数学意义上问题的正确名称。

提前致以问候和感谢... 菲利普

I want to code a little Game, dealing with fonts and letters. I want to make them move arround in 2d space and i am using box2dweb as physics engine, what is actually doing a very great job. At the moment all I am struggling with, is the problem of building the b2Body for a Letter. Box2d can only handle primitive, convex shapes and to build an more complex hitbox I have to combine some of them. In the image I tried to figure out what i would like to reach, an algorithm, that takes an svg-path of a letter and generates a series of b2shapes which represent the hitbox.

capital letter A in Black, a series of b2Shapes in blue, with green stroke

All in all i have no Idea where i could find some Information about this, if there is a library that is capable of doing this. Even if this Library is not available in Javascript, i could do the job on Server.
I know that there is paper.js and raphalel, some clever vector libraries, but i have not found any hint how to solve this yet.
I would be happy for any kind of help, links to ressources, or the correct name of the problem in mathematical sense.

Greetings and thanks in advance...
Philipp

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

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

发布评论

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

评论(1

や莫失莫忘 2024-12-17 18:16:02

我只是想把调查结果留在这里,也许有人会帮忙。最初的想法是基于“切穗”、“剔穗”或“剪穗”。 此处的演示将对此进行描述。但是该算法产生的多边形较少,但 box2d 合适的多边形在演示中显示 此处。这个想法是合并尽可能多的三角形,只要它们是凸的,并且在这种情况下,没有超过八条边。如果可以在三角形中找到两个具有相同 x 和 y 坐标的点,并在多边形中找到两个形容词点,则适合将三角形添加到多边形中。

I just want to leave the result of investigation here, maybe someone will help it. The initial idea is based on »ear cutting«, »ear culling«, or »ear cropping«. A demo here will describe this. But the algorithm, which produces less, but box2d suitable polygons is shown in a demo here. The idea is to merge as much triangles as possible, as long as they are convex and this case, do not have more than eight edges. A triangle is suitable to be added to a polygon, if one can find two points in the triangle and two adjective points in the polygon, with the same x and y coordinates.

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