Difference between revisions of "FF7/WorldMap Module"

From Final Fantasy Inside
< FF7
Jump to navigation Jump to search
my_wiki>Einherjar
my_wiki>Cyberman
(Mesh Structure)
Line 164: Line 164:
  
 
A worldmap mesh is recorded like this:
 
A worldmap mesh is recorded like this:
 
+
====Header====
 
Header:
 
Header:
 
{| border="1" cellspacing="1" cellpadding="3" style="border: 1px solid black; border-collapse: collapse;"
 
{| border="1" cellspacing="1" cellpadding="3" style="border: 1px solid black; border-collapse: collapse;"
Line 177: Line 177:
 
| Number of vertices
 
| Number of vertices
 
|}
 
|}
 +
 +
typedef struct
 +
{
 +
  uint16 NumberOfTriangles;
 +
  uint16 NumberOfVertices;
 +
} WorldMeshHeader;
  
 
For each triangle t in ''number of triangles'':
 
For each triangle t in ''number of triangles'':
Line 217: Line 223:
 
| Texture (see below)
 
| Texture (see below)
 
|}
 
|}
 +
 +
typedef struct
 +
{
 +
  uint8 Vertex0Index;
 +
  uint8 Vertex1Index;
 +
  uint8 Vertex2Index;
 +
  uint8 WalkabilityInfo;
 +
  uint8 uVertex0, vVertex0;
 +
  uint8 uVertex1, vVertex1;
 +
  uint8 uVertex2, vVertex2;
 +
  uint16 TextureInfo;
 +
} WorldMeshTriangle;
  
 
For each vertex v in ''number of vertices'':
 
For each vertex v in ''number of vertices'':
Line 236: Line 254:
 
| (Unknown: Coordinate w of vertex v?)
 
| (Unknown: Coordinate w of vertex v?)
 
|}
 
|}
 +
 +
typedef struct
 +
{
 +
  int16 X, Y, Z;
 +
  uint16 Unused; // fill to fit structure to 32bit boundry
 +
} VertexType;
  
 
For each vertex v in ''number of vertices'':
 
For each vertex v in ''number of vertices'':
Line 255: Line 279:
 
| (Unknown: Coordinate w of normal for vertex v? "Always 0")
 
| (Unknown: Coordinate w of normal for vertex v? "Always 0")
 
|}
 
|}
 +
 +
typedef struct
 +
{
 +
  int16 X, Y, Z;
 +
  uint16 Unused; // fill to fit structure to 32bit boundry
 +
} NormalType;
 +
 +
structures added by [[User:Cyberman|Cyberman]] 13:43, 10 Jan 2007 (CST)
  
 
=== Walkmap ===
 
=== Walkmap ===

Revision as of 22:43, 10 January 2007

Preamble

The following was originaly described by Tonberry, in qhimm's forum. It was completed by Ficedula sometimes later, who reversed texture data.

Two formats

BOT and MAP files are similar; BOT files are redundant and look like optimized versions of the corresponding MAP files.

Content

  • WM0 is the above water map.
  • WM2 is the underwater (submarine) map.
  • WM3 is the snowstorm map.

MAP Format

File Structure

A worldmap file is divided in sections of 0xB800 bytes, each section representing a square block of the map.

Map Block

Each block consists in 16 meshes, organized in a grid-like fashion:

Map Block mesh arrangement
0 1 2 3
4 5 6 7
8 9 10 11
12 13 14 15

A block is recorded following the structure (all pointers are expressed in bytes relative to offset 0 of block):

For each m in 16 meshes:

size description
4 bytes Pointer to compressed data for mesh m

Followed by, for each m in 16 meshes:

size description
variable Compressed data for mesh m

The data for each mesh is independently compressed using LZSS, so the first 4 bytes are the size in bytes of the compressed data and the rest is the compressed data itself.

WM0.MAP

wm0.map contains 68 blocks. The first 63 of them are arranged in a grid-like fashion, made of 7 rows of 9 columns, like this:

wm0.map block arrangement
0 1 2 3 4 5 6 7 8
9 10 11 12 13 14 15 16 17
18 19 20 21 22 23 24 25 26
27 28 29 30 31 32 33 34 35
36 37 38 39 40 41 42 43 44
45 46 47 48 49 50 51 52 53
54 55 56 57 58 59 60 61 62

The last 5 meshes 63, 64, 65, 66, 67 and 68 replaces meshes 50, 41, 42, 60, 47 and 48 (respectively), according to the story of the game.

Mesh Structure

A worldmap mesh is recorded like this:

Header

Header:

size description
2 bytes Number of triangles
2 bytes Number of vertices
typedef struct
{
  uint16 NumberOfTriangles;
  uint16 NumberOfVertices;
} WorldMeshHeader;

For each triangle t in number of triangles:

size description
1 byte Index of vertex 0 of triangle t
1 byte Index of vertex 1 of triangle t
1 byte Index of vertex 2 of triangle t
1 byte Walkmap status of triangle t (see below)
1 byte Coordinate u in texture for vertex 0
1 byte Coordinate v in texture for vertex 0
1 byte Coordinate u in texture for vertex 1
1 byte Coordinate v in texture for vertex 1
1 byte Coordinate u in texture for vertex 2
1 byte Coordinate v in texture for vertex 2
2 bytes Texture (see below)
typedef struct
{
 uint8 Vertex0Index;
 uint8 Vertex1Index;
 uint8 Vertex2Index;
 uint8 WalkabilityInfo;
 uint8 uVertex0, vVertex0;
 uint8 uVertex1, vVertex1;
 uint8 uVertex2, vVertex2;
 uint16 TextureInfo;
} WorldMeshTriangle;

For each vertex v in number of vertices:

size description
2 bytes Coordinate x of vertex v (signed)
2 bytes Coordinate y of vertex v (signed)
2 bytes Coordinate z of vertex v (signed)
2 bytes (Unknown: Coordinate w of vertex v?)
typedef struct
{
  int16 X, Y, Z;
  uint16 Unused; // fill to fit structure to 32bit boundry
} VertexType;

For each vertex v in number of vertices:

size description
2 bytes Coordinate x of normal for vertex v
2 bytes Coordinate y of normal for vertex v
2 bytes Coordinate z of normal for vertex v
2 bytes (Unknown: Coordinate w of normal for vertex v? "Always 0")
typedef struct
{
  int16 X, Y, Z;
  uint16 Unused; // fill to fit structure to 32bit boundry
} NormalType;

structures added by Cyberman 13:43, 10 Jan 2007 (CST)

Walkmap

code description
0x23 Deep sea (can't land highwind, water spray when flying low)
0x22 No sea spray from highwind, can't land
0x21 No sea spray from highwind, can't land
0x20 No sea spray, can land and walk

Observe that 0x21 and 0x22 describe the same status; it is thought that it may differentiate chocobos' behavior.

Texture

The lower 9 bits contain a texture number (0-511, but only 0-281 appear to be used). The text files in the Reeve download show how each number maps to one (or more) .TEX files within WORLD_US.LGP (see also LGP Archives). The upper bits have something to do with texture coordinate mapping.

BOT format

(FIXME)