unity

[Unity 3d] unity-delaunay(delaun

2019-08-12  本文已影响17人  雨落随风

实现基于 Delaunay 网格分割算法的破碎效果。

GitHub 上的工程多如繁星,有些好的仓库,但凡不经意间错过了就很难找回,故稍作采撷,希望能帮助到有心人。

简介:

笔者今天推荐的仓库叫 unity-delaunay。 - delaunay网格分割算法 for Unity

功能:

实现基于 Delaunay 网格分割算法的破碎效果。

使用:

I’m generating the Delaunay triangulation using the incremental algorithm (Bowyer-Watson), and generating the voronoi diagram from the delaunay triangulation. You can also clip the voronoi diagram to any convex shape (it uses Sutherland-Hodgman clipping, adapted to voronoi diagrams).

The fact that you can clip to any convex shape is neat, because it means you can “recursively” generate voronoi diagrams, so you can shatter already generated voronoi shards.

All the “generator” classes (the delaunay generator, the voronoi generator, and the voronoi clipper) are designed in such a way as to not generate any garbage if they are reused (though I’m currently not doing that in the example code). If you were to do this in a real game, it would be suitable to run the generators on background threads, though they’re certainly performant enough to run in real time in a single-threaded environment.

I was going to develop this a bit further, but the limiting factor in this kind of destruction effect is the physics. If you generate these kinds of shards and let them pile up, the physics engine basically implodes. Given that that was the limitation, I sort-of lost interest in the project. As such, the non-Delaunay/Voronoi parts of the code are super-unoptimized and kind of a mess :)

哈哈,自己翻译。。。

演示:

Delaunay

链接:

OskarSigvardsson/unity-delaunay: A Delaunay/Voronoi library for Unity, and a simple destruction effect

结语:

本文集持续更新ing,喜欢记得点赞关注哦!

上一篇 下一篇

猜你喜欢

热点阅读