等距深度排序深度

2023-09-11 06:35:22 作者:Pamper(娇纵)

我已经写了使用Java 2D等距引擎的开端。我已经得到了最基础的覆盖,例如瓷砖订单和对象深度在地图上的排序。不过,我碰到一个我不能似乎没有让我的方法非常的混乱,以解决问题。

I've written the beginnings of a 2D isometric engine using Java. I've got most of the basics covered such as tiling orders and object depth sorting on the map. However, I've run into a problem which I can't seem to solve without making my methods really messy.

的问题在于,在我的等距的世界里,每个对象时瓦片的对象基是在屏幕上呈现渲染。然而,一些对象有一个大的高度(如建筑物),它可以从非渲染屏幕外的区域延伸到所呈现的屏幕区域,我也没有办法检测出这是我的发动机,到目前为止依赖于对象基地是present来渲染图像。

The problem is that, in my isometric world, each object is rendered when the tile that the object base is on is rendered on the screen. However, some objects have a large height (such as a building) which can extend from a non-rendered off-screen area into the rendered screen area, and I have no way to detect this as my engine so far relies on object bases being present to render images.

我的问题是,如何将我发现一个对象具有较大的高度值应为present中所呈现的区域,而其基础是在离屏幕区域?我真的不希望只呈现整个地图(包括离屏幕区域),因为这是非常CPU密集型的,所以我在寻找一种算法或方法,让我发现这个问题的领域。

My question is, how would I detect that an object with a large height value should be present in the rendered area while its base is in the off-screen area? I really don't want to be just rendering the whole map (including the off-screen area) as this is very CPU-intensive, so I'm looking for an algorithm or method which allows me to detect this problematic area.

编辑:更新的问题直观地重present下面的问题

Updated the question to visually represent the problem below.

推荐答案

您可以修改你的'砖'的概念,包括像一个信封......定界的最大高度和宽度的矩形?例如在创建大的高度对象时/分配给瓦,则可以提高其包络线的高度。 然后,你只需要渲染的瓷砖,其信封画面重叠。

Can you modify your concept of 'tile' to include something like an 'envelope'...a rectangle that delimits the maximum height and width? e.g. when the 'large height' object is created / assigned to a tile, you could increase the height of its envelope. Then you only need to render for tiles whose envelopes overlap with the screen.