有人可以解释每个像素的碰撞检测吗? [英] Can someone explain per-pixel collision detection?

查看:84
本文介绍了有人可以解释每个像素的碰撞检测吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以解释它的优缺点以及与此有关的任何数学运算吗?

Can someone explain the pros and cons of it and any math involved with it?

推荐答案

对于2D:
对于此问题,您不需要任何数学运算,只需要自定义bitblit例程。您可以通过将碰撞候选对象绘画在其上的碰撞蒙版并检查(如果要绘制的像素是否为(pixel!= 0)),将碰撞候选对象变为隐藏表面。然后,您将发生碰撞。当然,如果发生碰撞,您应该通过边界矩形进行预检查。

For 2D: You do not need any math for this problem, you need only a custom bitblit-routine. You will blit collision candidates into a hidden surface by painting their collisionmasks onto this surface and checking, if the pixels you just want to draw are (pixel != 0) . Then you will have a collision. Of course, you should precheck by bounding rectangles if an collision can occur.

对于3D:
您将需要很多数学运算!

For 3D: You will need math(a lot)!

基本上,您将对照敌人的每个表面检查演员的每个表面。
这将通过计算平面射线相交来完成。这里可以进行很多优化,但这取决于您的3D表示。 这也不是逐像素碰撞,而是逐顶点碰撞

basically you will check each surface of your actor against each surface of your enemy. This will be done by calculating a plane-ray intersection. There is a lot of optimization possible here, but it depends on your 3d representation. This is also no Per-Pixel-Collision, but Per-Vertex-Collision

这篇关于有人可以解释每个像素的碰撞检测吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆