Box2D 建模灵活的头发状物体

发布于 2024-11-16 02:59:14 字数 776 浏览 1 评论 0原文

我正在寻找一些瘦瘦的模型。 Box2D 中的柔性线/毛发/刺/线,我想知道最好的方法是什么。我用谷歌搜索并看到了一种叫做线段的东西(http:// /www.box2d.org/forum/viewtopic.php?f=8&t=1437),但它似乎只是 Flash 端口的扩展 - 我希望在与平台无关的方式。

我猜我必须用一串薄盒子来做这件事,但是有人有任何建议或需要注意的事情吗?

更新:感谢下面的反馈,到目前为止的选项是:

  • 通过跟踪角度和设置电机速度来制作弹性旋转关节 - Box2D 论坛上有一个关于此问题的帖子: http://www.box2d.org/forum/viewtopic。 php?f=3&t=1007

  • 在各段之间连接弹性距离接头(见图 - 类似于人们接触软体的方式)。

    距离关节示例

  • 如果需要最少的碰撞,则使用 Drop Box 2D 并使用 verlet/粒子系统(不幸的是,这对我来说不可能) )。

I am looking to model some thin & flexible strands/hairs/spines/lines in Box2D and am wondering what the best way to go about this is. I've Googled and seen something called line segments (http://www.box2d.org/forum/viewtopic.php?f=8&t=1437) but it seems to be just an extension for the Flash port - I was hoping to do it in a platform-agnostic way.

I am guessing I'll have to do it with chains of thin boxes, but does anyone have any advice or things to watch out for?

Update: Thanks to the feedback below the options so far are:

  • Make springy revolute joints by tracking the angle and setting motor speed - there is a thread on this at the Box2D forum:
    http://www.box2d.org/forum/viewtopic.php?f=3&t=1007

  • Attach springy distance joints between the segments (see diagram - similar to how people approach soft bodies).

    Distance joint example

  • Drop Box 2D and use verlet/particle system if there's minimal collision necessary (not possible for me unfortunately).

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

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

发布评论

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

评论(3

我要还你自由 2024-11-23 02:59:14

这取决于它们需要成为物理世界的一部分,以及您想要与“头发”的所有部分碰撞的精确度。如果碰撞不是最重要的,您可以使用链中减少数量的盒子进行近似,并根据其位置的样条线进行渲染。如果涉及的碰撞很少,您甚至可以使用 verlet 集成,它非常容易编码并且对 CPU 的占用更小。

虽然只有 10 个,但我希望你可以用旋转关节完全模拟它们,尽管我不会限制它们,而是控制它们,以便它们不断尝试拉直链条,但调整每个关节的最大扭矩,使它们没有足够的扭矩完全伸直的力量。如果采用这种方式,需要记住的一点是,它有助于使靠近底部的部分变重,并逐渐向末端变轻。尖端处的运动强度也需要减弱。

It depends how much a part of the physics world do they need to be, and how accurately you want to collide with all parts of the 'hair'. If collision is not paramount you could approximate with a reduced number of boxes in the chain, and render based on a spline of their locations. If very little collision is involved you could probably even use verlet integration which is pretty easy to code and lighter on CPU.

With just 10 of these though I expect you could simulate them fully with revolute joints although rather than limits I would control them so that they continually try to straighten their chain, but adjust the max torque of each joint so that they don't have enough power to straighten fully. One point to bear in mind if you go this way is that it helps to make the segments near the base heavier, and gradually lighter towards the ends. The motor strength will need to be weaker at the tips too.

妄司 2024-11-23 02:59:14

哇...可以想象,您可以使用许多旋转关节,并对其运动(旋转)设置限制,但我认为您的 CPU 和内存使用量很快就会失控。其他人可能有更好的答案,但您可能希望研究使用一些预渲染/预动画对象。您也可以使用粒子系统来做到这一点。它不会在物理模拟中渲染太多,但如果这就是你想要的,它看起来可能很酷。

也许我最好的建议是结合使用这些东西。如果我觉得我真的必须这样做,并且确实必须至少在物理模拟中完成一些工作,我会将旋转关节与粒子结合起来。我会根据物体移动的方式绘制不同的粒子文件。

抱歉,我无法给您具体的例子,因为我从来没有需要做这样的事情。

Wow... Conceivably you could use many revolute joints with limits set on their movement (rotation), but I would think that your CPU and memory usage would quickly spiral out of control. Someone else may have a better answer but you may wish to look into using a handful of prerendered/preanimated objects. Also you could probably do this with the particle system. It wouldn't be so much rendered in a physics simulation but it could look cool if that is what you are going for.

Probably my best suggestion is to use a combination of these things. If I felt I really had to do this and really had to have it at least somewhat done in the physics simulation, I would combine the use of revolute joints with particles. I would draw a different particle file depending on which way the bodies are moving.

Sorry I can't give you specific examples as I have never had a need to do such a thing.

归属感 2024-11-23 02:59:14

你们提出了关于性能的重要观点。

尝试模拟每条链的成本非常高。
您可以做的是模拟少量的股线均匀分布在表面上。
然后使用这些股线作为参考来绘制股线之间的内容。

加入一点随机性可能会产生很好的效果。

我写了一篇关于模拟树干的文章,该文章相关并且可能对某些人有用:http://aaronfarr.com/coding/simulated-a-tree-in-box2dweb/

更新:我使用这个想法制作了一个草地模拟演示:http://aaronfarr.com/coding/simulated-grass-using-box2d/

Box2D 中模拟草的示例

You guys bring up great points about performance.

Trying to simulate each strand would be very costly.
What you could do is simulate a small number of strands spread evenly across a surface.
Then use these strands as a reference to draw in-between strands.

Throwing in a bit of randomness could give a nice effect.

I wrote an article about simulating a tree trunk that is related and might be useful to some folks out there: http://aaronfarr.com/coding/simulating-a-tree-in-box2dweb/

Update: I have put together a demo of a grass simulation using this idea: http://aaronfarr.com/coding/simulating-grass-using-box2d/

Example of simulated grass in Box2D

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