Changes between Initial Version and Version 1 of PMP_File_Format


Ignore:
Timestamp:
Feb 23, 2008, 4:18:59 AM (16 years ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • PMP_File_Format

    v1 v1  
     1PMP files store a map's elevation and terrain types for each tile. Each map also has an associated XML file that stores objects on the map (entities and actors) as well as environment information (currently, lighting parameters).
     2
     3PMP file format (version 4), described in something a bit like C:
     4
     5Basic types:
     6 * char = 8-bit character
     7 * u32 = 32-bit unsigned int
     8 * u16 = 16-bit unsigned int
     9
     10All types are stored in little-endian format. Text is always ASCII.
     11
     12{{{
     13 PMP {
     14     char magic[4]; // == "PSMP"
     15     u32 version; // == 4
     16     u32 data_size; // == filesize-12
     17     
     18 
     19     u32 map_size; // number of patches (16x16 tiles) per side
     20 
     21     u16 heightmap[(mapsize*16 + 1)^2]; // (squared, not xor) - vertex heights
     22 
     23     u32 num_terrain_textures;
     24     String terrain_textures[num_terrain_textures]; // filenames (no path), e.g. "cliff1.dds"
     25 
     26     Patch patches[mapsize^2];
     27 }
     28 
     29 Patch {
     30     Tile tiles[16*16];
     31 }
     32 
     33 Tile {
     34     u16 texture1; // index into terrain_textures[]
     35     u16 texture2; // index, or 0xFFFF for 'none'
     36     u32 priority; // ???
     37 }
     38 
     39 String {
     40     u32 length;
     41     char data[length]; // not NUL-terminated
     42 }
     43}}}
     44
     45Other data is stored in XML format (with a filename matching the PMP's, except with ".pmp" replaced by ".xml"), with the following structure:
     46
     47{{{
     48    <?xml version="1.0" encoding="utf-8" standalone="no"?>
     49    <Scenario>
     50        <Environment>
     51            <SunColour r="1" g="1" b="1" /> &lt;!-- range 0..1, though out-of-range values are allowed -->
     52            <SunElevation angle="0.785398" /> &lt;!-- elevation above horizontal, in radians -->
     53            <SunRotation angle="4.71239" /> &lt;!-- angle clockwise from positive-z axis (north), in radians -->
     54            <TerrainAmbientColour r="0" g="0" b="0" />
     55            <UnitsAmbientColour r="0.4" g="0.4" b="0.4" />
     56        </Environment>
     57   
     58        <Entities>
     59            <Entity>
     60                <Template>Name</Template>
     61                <Player>1</Player> &lt;!-- 0 = gaia, higher numbers for other players -->
     62                <Position x="1.2" y="3.4" z="5.6" />
     63                <Orientation angle="1.2" />
     64            </Entity>
     65            ...
     66        </Entities>
     67   
     68        <Nonentities>
     69            <Nonentity>
     70                <Actor>Name</Actor>
     71                <Position x="1.2" y="3.4" z="5.6" />
     72                <Orientation angle="1.2" />
     73            </Nonentity>
     74            ...
     75        </Nonentities>
     76    </Scenario>
     77}}}
     78
     79(This structure is not rigidly enforced (e.g. by a DTD) - many elements are optional, to preserve backward compatibility with older map formats. However, it should be generated in this latest version of the format whenever possible.)