我想编写一个小游戏,处理字体和字母。我想让它们在 2d 空间中移动,我使用 box2dweb 作为物理引擎,这实际上做得非常出色。目前我正在努力解决的问题是为信件构建 b2Body 的问题。 Box2d 只能处理原始的凸形状,要构建更复杂的碰撞箱,我必须组合其中的一些形状。在图像中,我试图找出我想要达到的目标,一种算法,它采用字母的 svg 路径并生成一系列代表碰撞盒的 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.
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
发布评论
评论(1)
我只是想把调查结果留在这里,也许有人会帮忙。最初的想法是基于“切穗”、“剔穗”或“剪穗”。 此处的演示将对此进行描述。但是该算法产生的多边形较少,但 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.