WindBell
Hired Hero
|
posted December 23, 2009 03:22 AM |
|
|
GroundTerrain.bin Format Analysis and Tool
Hello everyone.
I spend some days on analysis groundterrain.bin format and have some interesting result.
This is a Terrain Viewer
http://www.boxcn.net/shared/oi2pi1hak5
(with source code , written in C# , .net framework 2.0 needed. Localized in English and Chinese. The executable file is put in bin/debug folder)
Each block contains a block size information.
All size with a 1-Byte prefix , All base length with a 2-Byte prefix.
All data represent a VERTEX but not a GRID
Assume it is a 72*72 map:
1 Head. With File size, Base length
2 Texture. Consist of some textures . Each has a block size, and base length (73 = 72+1 , 73 vertex for 72 grid) , an array of 73*73 8-bit unsigned byte (represent opaque) , a string represent the path of the texture dds.
3 Height. 32-bit unsigned float. Only visualible effect in the map. represent height in visual . 0.0 is water , 2.0 in default.
4 Plateau. 8-bit unsigned byte. Only move-block effect in the map. 0x10 is normal , 0x00 is water ( it is automatically , you needn't have water texture for 0x00 Plateau and 0.0 Height terrain grid to show water ).
5 Ramp. 73*73 8-bit unsigned . 0x0 as default. Connect diffrent level in Plateau. If 1 grid with 4 ramp of vertex is 0x1 and connect 2 grid with different Plateau ( cannot pass normally ), then this grid is passible with both side.
A typical ramp on the map:
Height 4 3 2 Plateau 20 18 10 Ramp 01 01 01
4 3 2 20 18 10 01 01 01
6 Water Depth. 8-bit unsigned. 0x0 default, 0xFF for deepest. represent the depth of water texture. It can also create water on the map - no need for plateau and height adjustment.
7 Passible . 8-bit unsigned. 0x0 for block. "Mask" in Map Editor manipulate this block.
8 End block. just a series of data (it is an arithmetic sequence in 8-bit unsigned), it keeps same in all different map(in 30 maps I only found ONE exception in a undergroundterrain , BUT replace it with normal one didn't affect anything as what I see)
In the source code I have implement a class represent the terrain file, with create new one with any size (must be square), can be load from file , and after any edit it can be correctly saved to a terrain.bin file which can be put into a h5m file and works . I'd like to add function like import bitmap to terrain next.
But I cannot continue my work because I will be busy in next month. So I public this only partially finished work and hope that some one can use this to do something better than me.
|
|