什么是AABB-碰撞检测? [英] What is AABB - Collision detection?

查看:554
本文介绍了什么是AABB-碰撞检测?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用 Java 制作体素游戏,在研究我需要学习的所有不同知识的同时,我注意到很多游戏都使用 AABB 用于碰撞检测。然后我记得在Minecraft中也见过 AABB 。但是当我搜索 AABB 是什么时,它仅与其他人的代码或历史记录中的某些组织一起提供。 Stackoverflow,什么是 AABB

Hi I'm making a voxel game in Java and while researching all the different things I'd need to learn, I noticed that a lot of games use AABB for collision detection. And then I remembered seeing AABB in Minecraft also. But when I google what AABB is, it only comes up with other peoples code, or some organization out the history book. Stackoverflow, what is AABB?

推荐答案

AABB代表 与轴对齐的边界框

它是表示卷的一种相当节省计算和内存的方式,通常用于查看两个对象是否可能接触。

It is a fairly computationally- and memory-efficient way of representing a volume, typically used to see if two objects might be touching.

由于它是轴对齐的,所以它确实不一定非常适合您的真实3D对象。 AABB检查通常用作粗略的第一近似值,以查看对象是否可能发生碰撞。然后,如果AABB支票通过,则会进行更详细的支票。

Since it is axis-aligned, it does not necessarily "fit" your real 3D object very well. AABB checks are often used as a coarse first-approximation to see if objects might be colliding. Then, if the AABB check passes, more detailed checks are made.

示例:

想象一下您的世界是2D,然后将其绘制在一张方格纸上。
您在世界上有一些物体(球,树等等)。要为其中一个对象制作AABB,请在对象周围绘制一个矩形,使线条与纸上的网格线平行。

Imagine your world is 2D, and you draw it on a sheet of graph paper. You have some objects in the world (a ball, a tree, whatever). To make an AABB for one of the objects, you draw a rectangle around the object, making your lines parallel to the grid lines on the paper.

如果您有AABB对于两个对象,您可以做一些非常简单的数学运算来查看那些AABB是否重叠。如果它们不重叠,则这两个对象可能无法接触,因此对于您的碰撞算法而言,这很容易实现。

If you have the AABB for two objects, you can do some pretty simple math to see if those AABBs overlap. If they don't overlap, those two objects couldn't possibly be touching, so it's an easy early-out for your collision algorithm.

这可以推广到3D(并且more-Ds)。

This generalizes to 3D (and more-Ds) fairly easily.

您可能想查看 gamedev.stackexchange.com

这篇关于什么是AABB-碰撞检测?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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