Splicing of warcraft Landform

Source: Internet
Author: User

First look at the image

Http://hi.csdn.net/attachment/201109/7/979141_1315404194Eh6m.jpg

 

The image of each block is calculated by the landform of 4 surrounding 4 feet.

AlgorithmAs follows.

1. the terrain number ranges from 0 to 5. The low-encoding type can be overwritten by the High-encoding type.

2. For each topographic map, the encoding is set to 1-15. (0 is retained, and 15 is actually the same.) Warcraft also contains a random filling block of 16-31, which is simplified here.

Uses bits to represent the angle covered by the block. For example, the upper left, upper right, lower left, and lower right are encoded as, and 8.

As a result, 1-15 represents various terrain coverage directions.

3. Calculate the layer of the block.

Sort the four corners, remove the repeated numbers, and save them as array A. At this time, n different landform numbers are left. (N = 1 to 4)

For (INT I = 0; I <n; ++ I)

Calculate the sum of the codes equal to the [I] and save them to tile [I];

4. Draw 0-N layers for each tile.

For example, the upper left (0, 0) block, and the surrounding 4 corners of the block are encoded

0, 0

5, 5

Therefore, tile [0] = 0x00 + 0; Tile [1] = 0x500 + 12

 

You can calculate the encoding at the bottom layer. I am doing this to prevent the underlying layer from being completely hidden and leave holes. Therefore, the underlying layer is fully filled.

 

Because each block has only four corners, the number of textures for each block is from 1 to 4. For d3d, Layer 4 textures can be used.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.