Judgment of the occlusion angle game

xiaoxiao2021-03-06  46

The judgment of the occlusion is a very cumbersome project in the game, but it is indispensable. Otherwise, every time you have something to move, you have to scribble the entire screen, so it seems that it is a bit not paid. In 3D technology, there is a lot of blanking methods such as the painter algorithm, the Z-Buffer algorithm, and BSP trees. In this case, we don't have to be so annoyed. We divide the map into one TILE, which does not only save space, which is much easier to judge the object's occlusion. Of course, this requires a way to take a little speculation. As shown in the figure, in a tide corner game, each object is included in a six-sided body (the upper left corner part of the left), we take a skill, that is, the unit height of this six-sided body, projected to our game plane, just tile Height, then this unit volume of six-sided painting is the six-side shape in the upper left corner of the left, very rule! The part blocked by this hexagon is the range of this unit height object. According to the TILE arrangement method we said before (see the picture below, put the picture again!), The coordinates of this cube are [2, 2], this cube is blocked by the 3 Tile coordinates [1 , 1], [1, 2] and [1, 3] (At this time our Tile arrangement shows a little ill, if the cubic coordinates are [2, 3], then the three Tile coordinates that are blocked are [2, 2], [1, 3] and [2, 4], there is a difference between the parity - although there is a little advantage in the Tile's location judgment. Who can give a better arrangement method? ). If the elf (the object of sports) has come to these places, it is possible to block, and then you need to draw a wizard and then heely retire the object before. This is only an object of the unit, and if the height of the object is 2 units (just like the part of the upper right corner of the left), it is still assumed that the coordinates of the object is [2, 2] (remember to have a parity difference), then it) The blocked Tile is [1, 1], [1, 2], [1, 3], [0, 1], [0, 2], and [0, 3]. If the range of objects accounted for (like the part below the left), the object coordinates are [2, 1] and [1, 2], then the moving coordinates are [2, 0], [1, 1). ], [1, 2] and [1, 3], that is, the panegroup of [2, 1] and [1, 2].

If you need to further reduce the range of heavy draws, this involves the operation of cutting a class. I also hate this cumbersome thing, in fact, the principle is not complicated, everyone will understand the graphics.

This time, here, you will see you next time. Judgment of the oblique angle game (continued)

Last time I said that the occlusion of the angle game was judged by the unit height of the object. The principle is such, but actually follow this, it seems to be a little bit a little - the person takes a step, it has to be very good to find At present, all objects can be displayed on the screen to judge - the beauty does not matter, just bitterly programmed, but also on the valuable CPU time.

So how can you make this steps that you have to do? There is a simple way - is the pretreatment of the map. This is also an activity that is going to programmaking. It is to generate a map data when making a map editor. When you create a simplified role of the map data, save a simple CPU time when actual game Yes.

Let's first define some of the formats of map data. (Note: It is not necessary to define this, here just provide a thinking, everyone will discuss it.)

We can join a BIT in the data structure (the reason is a BIT because I don't know how many bits needed now), this paragraph Tile is highly attribute, this Bit is what we want to discuss To determine the data requiring pretreatment required. Let's take a look at the schematic diagram of the left. The middle of this figure is an object with a bottom edge of 3x3 units, a height of 3 units. The part has a total of 21 TILE (where 6 Tiles on the vertical edge are only blocked). The number marked on the TILE is this Tile's occlusion height. It is actually the height of the object minus TILE distance from the bottom of the object. The so-called occlusion height is that the height of the object is blocked in this TILE. It seems that I still don't understand, and I will have more examples. For example, a height of 2 units stands on a TILE, assuming that this Tile's occlusion height is greater than or equal to 2, then, this person is completely blocked, this person actually disappeared on the screen, no need Draw this one again. If this tile is less than 2, this person is only blocked, and we must draw this person, and you have to draw this thing. Ok, now there is a small problem, what should I do if there is 6 TILE on the vertical edge? No matter how high things, it is likely to reveal a small face. But this place is different from the Tile (green) that is not blocked around: Others do not cover Tile, people stand above only need to draw people, don't need to find any object to block him, don't consider heavy painting The problem; and these half-green Tiles, half of it is blocked, it is necessary to redraw. Then, this requires special circumstances to treat, and then take a bit to record whether the Tile has blocking properties, or simply set the occlusion height member to all 1, put this as a shaped property, so that A bit, put it in other useful places. This is to see the highest object in the game is defined to be high (if a city wall is drawn from 100 units, then this screen is more convenient - nothing to call up.) .

There is still a problem, what should I do if there is a hole in an object? For example, a branch of the branches of the branches will definitely expose some body in the shadow of the branches, this is to set these TILE's occlusion properties to the TILE of the vertical edge, so OK. . However, this will have to suffer the programmer who makes the map editor. When the map data is generated, it is necessary to judge from transparent color. Which TILE is set to which occlusion property - because the object is not It's all right, such as a tree, is large.

The above discussion is a solid object, which is relatively simple (see the tones of the angle angle, it is still simple). We will then discuss another situation - hollow objects. The hollow object is not a thing of the box jar. It is actually some intermediates to stand, and it can also reveal things, such as: a pavilion. The pavilion, the wind house, the wind, people can stand in the middle, so people blocked the column fences behind, while being blocked by the front pillars fence and the top of the top. Now the above method is not applicable, isn't it? What can I do if there is no such thing as the thing on the previous discussion?

转载请注明原文地址:https://www.9cbs.com/read-51570.html

New Post(0)