Tes2Mod:WOODS.WLD format

This is a description of the format of the WOODS.WLD file found in the ARENA2 directory of Elder Scrolls: Daggerfall by Bethesda. The information here is not complete or 100% percent accurate, although the basic format appears to be well understood.
thumb|500px|250px|False-colour output of WOODS.WLD

Header
The first 0x90 (144) bytes of the file are composed of a Header structure.  



Data Offsets
Immediately following the Header, is a contiguous list of UInt32 values.  There should be Header.Width * Header.Height (500000) elements.  Each element is an offset (relative to the start of the file) to a PixelData structure.  Each element corresponds by ordinal to an Elevation Map element; that is to say the tenth offset in this contiguous list describes the tenth pixel in the Elevation Map array.  Daggerfall expects these elements to be stored in left-to-right, top-to-bottom order.  Editors should follow this convention.  This does not mean element   must specify a disk location which precedes  ; it merely means element   specifies a row which is "above" row   in the output bitmap.

Data Section 1
This section contains unknown data.  It may be related to the Elevation Map Data.  The section is 1024 bytes in size (0x0400).  



Elevation Map
As the name suggests, this section contains elevation data for a small, 1000x500 pixel, map of the Iliac Bay.  Each byte represents one pixel, with Header.Width * Header.Height pixels in total.  Low values are low elevations, high values are high elevations, with 0x00 through 0x02 considered water.  There are no pixels with an elevation of 0x03.

These values are further modified by the PixelData.ElevationNoise array, which (if considered) expands the map into 5000x2500 pixels.

The values are stored in left-to-right, top-to-bottom order.  That is to say the first 1000 elements describe the first (top-most) row of the map, and the second 1000 elements describe the second row of the map, and so on.

Pixel Data
For each of the pixels in the Elevation Map, there is a corresponding PixelData element (0x2F, 47 bytes in size).  Offsets to each PixelData structure is found immediately following the Header as a contiguous list of UInt32 offsets.  

{| class="wikitable" 
|+ PixelData structure
!Offset
!Type
!Name
!Description
|-
!0-1
| UInt16
| Unknown1
| Unknown Purpose.
|-
!2-5
| UInt32
| NullValue1
| Always 0x00000000.  
|-
!6-7
| UInt16
| FileIndex
| Valid values are defined by the FileIndex Enumeration, below. 
|-
!8
| UInt8
| Climate
| Valid values are defined by the Climate Enumeration, below.
|-
!9
| UInt8
| ClimateNoise
| This field is used to provide variance to the weather specific to that pixel.  Observed values are {0x20, 0x40, 0x60, 0x80, 0xa0, 0xc0}.  
|-
!10-21
| UInt32[ 3 ]
| NullValue2
| Each element is always 0x00000000.  
|-
!22-46
| Int8[ 5 ][ 5 ]
| ElevationNoise
| Each signed byte element of this two-dimensional array provides noise for the pixel's Elevation field, thus giving the overland hills, valleys, etc.  For some reason the resultant 5000x2500 pixel map has a strange grid-like pattern imposed on it by this field.  The ElevationNoise elements are stored in left-to-right, top-to-bottom order.  
|}

FileIndex Enumeration
The FileIndex enumeration does not identify the texture file to use when displaying the ground for that specific map pixel.  It is a decoy.  This data is actually in CLIMATE.PAK.  



Climate Enumeration
The Climate enumeration is not used by Daggerfall when generating weather and seasons for the pixel.  Weather and seasons are determined by the data within the CLIMATE.PAK file.  



Working with WOODS.WLD
Everything one needs to create the Iliac Bay in a 3D environment, such as DirectX or OpenGL, is present.  

Building the Map
One can use the data present in WOODS.WLD to generate an almost complete map for the Iliac Bay.  This documentation will assume the standard 3D coordinate format of (X, Y, Z), where X represents the east-west axis, Y represents the elevation axis, and Z represents the north-south axis.  Daggerfall World Units are proportionate to the United States Inch, and the valid domain for each axis is defined as: Dom(X) &equiv; (51200, 32753664), Dom(Y) &equiv; (-80, 1228), and Dom(Z) &equiv; (16384, 16367616).

First one reads the ElevationMap to retrieve the base elevation for the location.  Each element within the ElevationMap refers to a PixelData element, so one must then next read the PixelData.  One then adds to each element of the PixelData.ElevationNoise array the value reported by the pixel's corresponding entry in the ElevationMap.  One now has the base elevation for every location within the game.  

The next step is a matter of scaling.  Each pixel in this resultant 5000 x 2500 bitmap equal to 6467.584 inches by 6516.736 inches.  This places the Iliac Bay's total area  at 135240.22691037170846039793070852 square miles (between California and Nevada in total size, with the defined land area about 1.6 times that of England).

Adding Locations
To determine which of these map pixels a Location from MAPS.BSA (or the player's character for that matter) occupies one must simply translate from Daggerfall World Units to the above Map Units.  

First, one must subtract 51200 from the location's X coordinate, and 16384 from the location's Y coordinate.  The next step is then to divide the X coordinate by 32702.464 and divide the Y coordinate by 32702.464.  One now has the specific pixel location in 1000x500 scale.

At this point one has the location for the lower-left corner of the location's first Block, as defined by the location's  ExteriorData Block* arrays.  Blocks are stored in west-to-east, south-to-north order.  Each Block has a uniform size.

Textures
The specific textures to load for the ground planes, the flats, and the structures is determined by the CLIMATE.PAK file.

See Also
# Land creation notes