Difference between revisions of "FF7/Field/Walkmesh"

From Final Fantasy Inside
< FF7‎ | Field
Jump to navigation Jump to search
my_wiki>Cyberman
(Section 5 Header)
my_wiki>Cyberman
(Section 5: Walkmesh (Kero))
Line 7: Line 7:
 
Section 5 of field files is a stored walkmesh. A walkmesh is a mesh of polygons on which characters move, telling the engine for example how high it is, and using this the character can, for example, cross bridges with the real feeling that in the middle he is at a higher place than on the sides. It has very simple structure.  
 
Section 5 of field files is a stored walkmesh. A walkmesh is a mesh of polygons on which characters move, telling the engine for example how high it is, and using this the character can, for example, cross bridges with the real feeling that in the middle he is at a higher place than on the sides. It has very simple structure.  
  
 +
{| border="0" cellspacing="1" cellpadding="3" style="background: rgb(0,0,0)" align="center"
 +
! style="background:rgb(0,255,0)" align="center" | Offset
 +
! style="background:rgb(0,255,0)" align="center" | Name
 +
! style="background:rgb(0,255,0)" align="center" | Data Type
 +
! style="background:rgb(0,255,0)" align="center" | Description
 +
|-
 +
|style="background:rgb(0,255,0)" | 0x0000
 +
|style="background:rgb(0,255,0)" | NoS
 +
|style="background:rgb(0,255,0)" | DWORD [0x04]
 +
|style="background:rgb(0,255,0)" | Number of Sectors
 +
|-
 +
|style="background:rgb(0,255,0)" | 0x0004
 +
|style="background:rgb(0,255,0)" | Sector Pool (SP)
 +
|style="background:rgb(0,255,0)" | WORD [3][4] * NoS
 +
|style="background:rgb(0,255,0)" | The data pool of Secots
 +
|-
 +
|style="background:rgb(0,255,0)" | 0x0004 + 24 * NoS
 +
|style="background:rgb(0,255,0)" | Sector Access Pool (SAP)
 +
|style="background:rgb(0,255,0)" | WORD [3] * NoS
 +
|style="background:rgb(0,255,0)" | Gate movement across Mesh Edges
 +
|}
 
==== Section 5 Header ====
 
==== Section 5 Header ====
  
 
Startofs 0x00 Length 0x04
 
Startofs 0x00 Length 0x04
The walkmesh is preceeded by a DWORD (4 bytes) unsigned int, named '''NoS''' (Number of Sectors).
+
 
 +
The walkmesh information is preceeded by a DWORD (4 bytes) unsigned int, named '''NoS''', short for the Number of Sectors in the walkmesh.
  
 
==== Sector pool ====
 
==== Sector pool ====
Line 17: Line 39:
  
 
  typedef struct {
 
  typedef struct {
     short x,z,y,res; // short is 2 bytes long integer
+
     short x,z,y,res; // short is a 2 byte signed integer
  } vertex_3s; // 3 short
+
  } vertex_3s; // 3s == 3 short although there are 4 this is for 32 bit data alignment in PSX
  
 
  typedef struct {
 
  typedef struct {
     vertex_3d v[3];
+
     vertex_3s v[3]; // a triangle has 3 vertices
  } sect_t;  
+
  } sect_t; // Sector Type
  
In sector pool are sectors, in fact just triangles and its position. For each sector you have three vertex_3s. Just store them. It seems that res and z are very often same, but not always, I don't know why. It seems that all polygons are clockwise. I didnt check it, but it is probably in order to know wheather point is in triangle. If you give it in other direction, point will be detected outside if it is inside and vice versa.
+
The pool of pool consists of sectors, which are in fact triangles with there vertex position. For each sector you have 3 vertexs (3 vertex_3s). Res and z values are often the same, for z this is expected (think planes of data), more study is needed as to what res might be being used for. The polygons are 'wound' clockwise, likely it is used for determining if a point is in said triangle.
  
 
==== Access pool ====
 
==== Access pool ====
Line 34: Line 56:
 
  }
 
  }
  
In access pool you have ID of poly, you should go into if you cross line.
+
The access pool is an array of access data (ID's of triangles in the Mesh) in the mesh, the ID is the triangle you should be in if you cross that edge.
  
 
acces1 is for line from vertex 0 to 1
 
acces1 is for line from vertex 0 to 1
Line 40: Line 62:
 
acces3 is for line from vertex 2 to 0
 
acces3 is for line from vertex 2 to 0
  
If acces1/2/3 is FFFF then you are not allowed to cross this line. Acces pool and sector pool are same size (NoT), so you will just use same index for both pools. If access don't translate you, it just says, you should be here, if you are not, then there is a problem. If you design polymesh where you cross line and access tells you that you should be in poly 12, but you are god know where then FF7 stops.
+
If the edge value is 0xFFFF, than this edge cannot be crossed (it's blocked). The access pool and sector pool have the same number of entries, thus you use the same index value for both pools of data to access the data for the same triangle. The access data merely informs one that if the PC object crosses this line the object should be in the indentified triangle.  FF7 will halt running if you are not in the '''access''' specified triangle.

Revision as of 22:10, 25 November 2006

Section 5: Walkmesh (Kero)

Wutai Walkmesh

Every every offset is here relative, 00 is at the start of section 5 (after length indicator).

Section 5 of field files is a stored walkmesh. A walkmesh is a mesh of polygons on which characters move, telling the engine for example how high it is, and using this the character can, for example, cross bridges with the real feeling that in the middle he is at a higher place than on the sides. It has very simple structure.

Offset Name Data Type Description
0x0000 NoS DWORD [0x04] Number of Sectors
0x0004 Sector Pool (SP) WORD [3][4] * NoS The data pool of Secots
0x0004 + 24 * NoS Sector Access Pool (SAP) WORD [3] * NoS Gate movement across Mesh Edges

Section 5 Header

Startofs 0x00 Length 0x04

The walkmesh information is preceeded by a DWORD (4 bytes) unsigned int, named NoS, short for the Number of Sectors in the walkmesh.

Sector pool

Startofs 0x04 Length NoS*24

typedef struct {
   short x,z,y,res;		// short is a 2 byte signed integer
} vertex_3s;			// 3s == 3 short although there are 4 this is for 32 bit data alignment in PSX
typedef struct {
   vertex_3s v[3];		// a triangle has 3 vertices
} sect_t; 			// Sector Type

The pool of pool consists of sectors, which are in fact triangles with there vertex position. For each sector you have 3 vertexs (3 vertex_3s). Res and z values are often the same, for z this is expected (think planes of data), more study is needed as to what res might be being used for. The polygons are 'wound' clockwise, likely it is used for determining if a point is in said triangle.

Access pool

Startofs 0x04 + NoS*24 Length NoS*6

typedef {
   short acces1,acces2,acces3;
}

The access pool is an array of access data (ID's of triangles in the Mesh) in the mesh, the ID is the triangle you should be in if you cross that edge.

acces1 is for line from vertex 0 to 1 acces2 is for line from vertex 1 to 2 acces3 is for line from vertex 2 to 0

If the edge value is 0xFFFF, than this edge cannot be crossed (it's blocked). The access pool and sector pool have the same number of entries, thus you use the same index value for both pools of data to access the data for the same triangle. The access data merely informs one that if the PC object crosses this line the object should be in the indentified triangle. FF7 will halt running if you are not in the access specified triangle.