Author Topic: FF7 World Map geometry  (Read 11130 times)

Tonberry

  • *
  • Posts: 38
    • View Profile
FF7 World Map geometry
« on: 2006-07-03 04:30:24 »
I post this as I got curious because of some comments by halkun about the WM for FF7 in the Q-Gears forum. I thought the structure wouldn't be too different to the FF9 WM, and it isn't. I didn't find much info about the WM, so excuse me if this is known.

I only looked into 'wm0.bot' in detail, but the other 'bot' and 'map' files seem to be similar, so there is specific information about 'wm0.bot' that maybe doesn't apply to the other files, but general info that applies to all.

This file defines the geometry for the WM (continents, island, etc.). It's divided in sections of 0xB800 bytes, each section representing a square(?) block of the map.

Each block is divided into 16 meshes arranged like this:

Code: [Select]
+----+----+----+----+
|  0 |  1 |  2 |  3 |
|----+----+----+----|
|  4 |  5 |  6 |  7 |
|----+----+----+----|
|  8 |  9 | 10 | 11 |
|----+----+----+----|
| 12 | 13 | 14 | 15 |
|----+----+----+----|

And each mesh is defined by a set of triangles, vertices and some other info I don't know what it is.


A block has this structure: (all pointers in bytes relative to offset 0 of block.)

Code: [Select]
(4 bytes)       Pointer to compressed data for mesh 0.
(4 bytes)       Pointer to compressed data for mesh 1.
...
(4 bytes)       Pointer to compressed data for mesh 15.
(variable size) Compressed data for mesh 0.
(variable size) Compressed data for mesh 1.
...
(variable size) Compressed data for mesh 15.

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.

Once uncompressed, each mesh has this structure:

Code: [Select]
(2 bytes) Number of triangles.
(2 bytes) Number of vertices.
Start of triangle data:
  (1 byte)  Index of vertex 0 of triangle.
  (1 byte)  Index of vertex 1 of triangle.
  (1 byte)  Index of vertex 2 of triangle.
  (1 byte)  Unknown.
  (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 fertex 2.
  (2 bytes) Unknown.
  ... (Repeat for each triangle.)
Start of vertex data:
  (2 bytes) Coordinate x of vertex.
  (2 bytes) Coordinate y of vertex. (Signed.)
  (2 bytes) Coordinate z of vertex.
  (2 bytes) Unknown.
  ... (Repeat for each vertex.)
Start of unknown data: (related to vertices?)
  (2 bytes) Unknown.
  (2 bytes) Unknown.
  (2 bytes) Unknown.
  (2 bytes) Unknown.
  ... (Repeat for each vertex.)

(Yes, I know, that's a lot of unknowns.)

Some of the unknowns in the triangle data must specify the texture and maybe some special effects on the textures. That should be easy to figure out by filtering those fields.
After the info of vertices come a structure that I don't know what it is, but the number of elements seems to be equal to the number of vertices. (I'll have to find one that doesn't have so many zeros.)

As in the FF9 WM, the definition of the blocks is repeated several times in the file, so maybe each block has a version that can be used depending on the parts of the game that were solved.

The WM has a width of 9 blocks and a height of 7 blocks (or 36x28 meshes.) Maybe I'm wrong by a row of water, but it's unlikely.
To render a correct version of the WM, I used the blocks defined every 4 blocks, starting from block 0. As an example:

Code: [Select]
  0   4   8  12  16  20  24  28  32
 36  40  44  48  52  56  60  64  68
... ... ... ... ... ... ... ... ...
216 220 224 228 232 236 240 244 248

That's a total of 63 blocks used, but the file has 332 blocks. I didn't check all the remaining 269 blocks, but I did a visual inspection of most of them and they seem to be repetitions of those 63 blocks. Maybe I'll do a binary comparison among similar blocks.

Hope this helps in some way with Q-Gears.

halkun

  • Global moderator
  • *
  • Posts: 2097
  • NicoNico :)
    • View Profile
    • Q-Gears Homepage
Re: FF7 World Map geometry
« Reply #1 on: 2006-07-03 12:58:59 »
That explains a issue when trying to decipher the code the first time around....

The got down to the individual "bocks" but when editing the blocks we were getting some kind of tree structure that would "break"  iff we sis anything bu move branches. Tuns out we were seeing the data spread in the the LZSS algo....

Thanks for figuring that out.

Keep in mind that the world map isn't just the world map that we see going from midgar to kalm for example. It's also the "Snow maze" where you stick the posts into the ground to get orintated.

I'm guessing the TXZ(?) files are compressed textures. Also remeber that there are most likely pallette look ups as well.

Good news anyway! Thanks...

Cyberman

  • *
  • Posts: 1572
    • View Profile
Re: FF7 World Map geometry
« Reply #2 on: 2006-07-03 14:00:12 »
The second set of numbers (IE matching in length to the vertex count) might be walkmap information.  There are some places you cannot walk on the world map and that might contain the information reguarding it.   The addition grids might be underwater information as well.  There are lots of possibilities.

:D

Cyb

halkun

  • Global moderator
  • *
  • Posts: 2097
  • NicoNico :)
    • View Profile
    • Q-Gears Homepage
Re: FF7 World Map geometry
« Reply #3 on: 2006-07-03 17:09:57 »
I was going to say...

I'm sure the underwater worldmap is in there too.

Tonberry

  • *
  • Posts: 38
    • View Profile
Re: FF7 World Map geometry
« Reply #4 on: 2006-07-04 01:07:32 »
Quote
The got down to the individual "bocks" but when editing the blocks we were getting some kind of tree structure that would "break"  iff we sis anything bu move branches. Tuns out we were seeing the data spread in the the LZSS algo....

When you mentioned the thing about a tree I thought that it could be interesting, but I also remembered from the FF9 WM how the meshes where organized inside a block and that the structure can be interpreted as a tree... so I had to take a look.

Quote
Keep in mind that the world map isn't just the world map that we see going from midgar to kalm for example. It's also the "Snow maze" where you stick the posts into the ground to get orintated.

...

I'm guessing the TXZ(?) files are compressed textures. Also remeber that there are most likely pallette look ups as well.

Thank you for the information. I already looked into the other '.bot' and '.map' files but it's been a long time since I played the game and I only did it once and a quarter, so I'll have to look for some pictures.

Just in case, to avoid generating an unnoticed stall in the development of WM related things for Q-Gears, I'll mention that I'm not going to continue investigating too much into it. I'm trying to "finish" with DIR00 in FF9 and after that I'll continue with DIR01, so I'm not too interested in FF7 at the moment; but if there's something else I can help with that doesn't take much time, I'll probably do it.

A little more info:

- The file WM0.MAP has 69 blocks, that arranged in 9 columns by 7 rows renders a complete WM similar to WM0.BOT. (You'll notice there are 6 more blocks, as 9*7=63, but they are similar to previous blocks.)

- The map in WM2.BOT has a width of 3 blocks and a height of 4 blocks. The total number of blocks defined inside the file is 48. And to render a version of the world that makes sense I used one block every 4 blocks.

- WM2.MAP has a total of 12 blocks, that arranged in 3 columns and 4 rows render the same as WM2.BOT.

- WM3.BOT has a total of 16 blocks and it's almost empty so it's difficult to know the number of columns and rows, but it can be 2x2.

- WM3.MAP has has a total of 4 blocks and it seems almost empty. There is the same building as in WM3.BOT that I don't recognize it right now.


Note: For MAP files I didn't use the trick of "jumping" blocks. I simply put them one after the other in a 2D array.

Quote
The second set of numbers (IE matching in length to the vertex count) might be walkmap information.  There are some places you cannot walk on the world map and that might contain the information reguarding it.   The addition grids might be underwater information as well.  There are lots of possibilities.

Maybe there's walkmap info there, but I'd look in the triangle data instead of the vertex data. Mmmm... but thinking it better if a triangle had 3 "solid" vertices it could be considered "solid" too. That can be easily figured out by using a filter on the unknown fields.

I'll probably take a closer look at individual blocks next weekend to try to find those things, but I did look "under the sea level" and didn't find anything. (Keep in mind that all that might be in WM2 and WM3 but I didn't recognize it.)

If my memory doesn't fail me, there was a minigame that involved a submarine. Isn't there the posibility that the underwater WM is related to a minigame in some way or has that already been discarded?

Then again, I offer the code. If someone wants to take a peek, I'll post it. It's written in C++ (C style), uses OpenGL and it's not too friendly.

Cyberman

  • *
  • Posts: 1572
    • View Profile
Re: FF7 World Map geometry
« Reply #5 on: 2006-07-04 19:05:14 »
There are 4 things that involve under water regions in the game.
the first is the sub game to get the special materia.
The second is battling one of the weapons.
The third is Shinra's downed/drowned airplane.
The fourth is the key of the ancients needed to activate the scene and continue in the plot progression at one point.

The first 3 are optional the last one is not.

The under water map is also quite large but has more restrictions than the surface because you have continents in the way ;)

At least 1 of the 5 map areas has to be the underwater region.
There are at least 4 world maps on the surface.
1 start map.
1 for when the temple of the ancients implodes
1 for when the forest of the ancients area becomes accessable
1 for when the town in which Cloud (over loaded version) and Tifa get caught in the life stream.
These EACH change the surface map.  I'm not sure how the Meteor affect is added myself.
That would account for 5 maps.  1 under water. 1 start. 1 for after the temple of the ancients.  1 for after Med... whatever that town is where the life stream explodes out :D and 1 for after the ancient forest is accessable (Fighting weapon near cosmo canyon).

Cyb

NobodyImportant

  • *
  • Posts: 92
    • View Profile
Re: FF7 World Map geometry
« Reply #6 on: 2006-07-04 22:41:37 »
You're thinking of Mideel.

What about the crater with the energy ring/without?

halkun

  • Global moderator
  • *
  • Posts: 2097
  • NicoNico :)
    • View Profile
    • Q-Gears Homepage
Re: FF7 World Map geometry
« Reply #7 on: 2006-07-04 22:49:31 »
The energy ring was a model. I remeber seeing it using a model browser for the PC version.

Tonberry

  • *
  • Posts: 38
    • View Profile
Re: FF7 World Map geometry
« Reply #8 on: 2006-07-04 23:10:21 »
Thank you Cyberman, I think that kind of info will be very useful in a short time, because there are few thing I remember about the game, but today I made a comparison byte by byte among the blocks of "wm0.bot" and I got this:

- The first 252 blocks (out of 332) are the WM (I mean the one with continents and islands, not the others). There are 4 sets (4*63=252) of the same WM.
- The first set can be built using the blocks 0, 4, 8, 12, 16, ...
- The second set can be built using the blocks 1, 5, 9, 13, 17, ...
- The third set can be built using the blocks 2, 6, 10, 14, 18, ...
- The fourth set can be built using the blocks 3, 7, 11, 15, 19, ...
- The second set is the same (byte by byte) as the first set, but rotated one block to the left.
- The third set is the same (byte by byte) as the first set, but rotated one block upwards.
- The fourth set is the same (byte by byte) as the first set, but rotated one block to the left and one block upwards.
- Of the remaining 80 blocks (332-252), 53 blocks are identical (byte by byte) to some of the blocks of the sets.
- Of the remaining 27 blocks (80-53), there are only 6 unique blocks; the rest are a copy of those 6.
- Of the remaining 6 blocks, 5 are different by 1 or 2 meshes to some of the previous blocks. (That means they are probably the changes in the WM you described.)
- The remaining block has almost all meshes different to the other blocks.

Summing it up, there are 69 unique blocks (the same as in 'wm0.map') and the distribution is the same: 63+6.

The best thing to test now is how similar are the blocks of 'wm0.map' to the ones of 'wm0.bot'. If they are the same, you wouldn't need to use the BOT files at all to render the WM, only the MAP files.

I'll try to render a version of the WM with the meshes where there are differences marked in a different color to see if it matches your info.

Some other thing: In the part of the snow storm is there some kind of hut at the end or when you start? Is the rest of the field almost horizontal?
If that's the case, I think WM3 has the WM for that part.

---------------

Edit:
I compared the blocks of 'wm0.bot' and 'wm0.map'. They are the same down to the last byte, so it should be enough to work only with MAP files. (I'll check the others some other time.) and it should be easier to find the underwater WM if it's in there.

Oh... and thank you too, NobodyImportant and halkun. (You posted while I was writting the original post and I didn't notice.)
« Last Edit: 2006-07-05 00:36:16 by Tonberry »

NobodyImportant

  • *
  • Posts: 92
    • View Profile
Re: FF7 World Map geometry
« Reply #9 on: 2006-07-05 04:41:23 »
Yes, there is a hut. :)

Tonberry

  • *
  • Posts: 38
    • View Profile
Re: FF7 World Map geometry
« Reply #10 on: 2006-07-09 00:46:52 »
I found some bugs in my code that transformed negative Y coordinates to something near 0, so now it's clear the world maps are:

WM0 - Above water.
WM2 - Underwater.
WM3 - Snow storm.

Cyberman

  • *
  • Posts: 1572
    • View Profile
Re: FF7 World Map geometry
« Reply #11 on: 2006-07-09 05:19:16 »
In words of one syllable

WOW.

Ok dokey this is great. We know something more than what we did before :D

Cyb

Tonberry

  • *
  • Posts: 38
    • View Profile
Re: FF7 World Map geometry
« Reply #12 on: 2006-07-09 21:40:45 »
Quote
In words of one syllable

WOW.

Ok dokey this is great. We know something more than what we did before

Cyb

Thank you Cyberman, it certainly is more information than what you knew a week ago and what you provided with the sarcastic bit in your comment altogether. :roll: (For your previous information and the non-sarcastic part of your comment, I truly thank you.)
I admit it's not the most precious information you can get but I thought it was you who was interested in locating the underwater world... and that was the easy part to document. :D

Now, let's go on...


I think the part after the vertices' coordinates in the mesh structure holds the normals of the vertices. I added those vectors to the surface of the WM and more or less they follow the slope. I didn't make any calculation to verify this, so the real interpretation can be a bit different but surface related.

This is an update to the mesh structure I posted before:

Code: [Select]
(2 bytes) Number of triangles.
(2 bytes) Number of vertices.
Start of triangle data:
  (1 byte)  Index of vertex 0 of triangle.
  (1 byte)  Index of vertex 1 of triangle.
  (1 byte)  Index of vertex 2 of triangle.
  (1 byte)  Unknown.
  (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 fertex 2.
  (2 bytes) Unknown.
  ... (Repeat for each triangle.)
Start of vertex data:
  (2 bytes) Coordinate x of vertex.
  (2 bytes) Coordinate y of vertex. (Signed.)
  (2 bytes) Coordinate z of vertex.
  (2 bytes) Unknown.
  ... (Repeat for each vertex.)
Start of normal data:
  (2 bytes) Component on coordinate x of normal for vertex 0. (Signed.)
  (2 bytes) Component on coordinate y of normal for vertex 0. (Signed.)
  (2 bytes) Component on coordinate z of normal for vertex 0. (Signed.)
  (2 bytes) Unknown. (Always 0.)
  ... (Repeat for each vertex.)

That's all I have to add about the meshes. The rest must be texture and walkmap related.


The rest of this post is about the WM in general and the repetition of the blocks, that I find interesting.

I posted to Mirex's trashbin (http://bin.mypage.sk/FILES/ff7wm2.JPG) a picture of WM0. The boxes marked in red delimit the meshes of the blocks that change according to the story of the game. I only marked the meshes but put the numbers of the blocks inside the boxes.

'wm0.map' has the blocks arranged like this:

Code: [Select]
+----+----+----+----+----+----+----+----+----+
+  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 |
+----+----+----+----+----+----+----+----+----+

and blocks 63, 64, 65, 66, 67 and 68 replace blocks 50, 41, 42, 60, 47 and 48, in that order.

- Block 63 replaces mesh 8.
- Block 64 replaces meshes 1, 2, 3, 5, 6, 7, 9, 10, 11, 13, 14 and 15.
- Block 65 replaces mesh 4.
- Block 66 replaces meshes 2 and 3.
- Block 67 replaces meshes 3 and 7.
- Block 68 replaces meshes 0 and 4.


What follows is another take on the blocks of 'wm0.bot':

As I said in a previous post, the blocks in 'wm0.bot' are arranged in sets, but I only mentioned that for the first 252 blocks.
The remaining 80 blocks are arranged in a similar way; they don't cover the whole WM but selected regions, usually around the blocks that are replaced. When I say they are arranged in the same way, I mean that blocks divisible by 4 are part of a set, the ones with a reminder of 1 are part of another set (rotated horizontaly), the ones with a reminder of 2 are another set (rotated vertically) and the ones with a reminder of 3 another set (rotated horizontally and vertically.)
That leaves us with 20 blocks and the remaining 60 blocks simply as translations of those blocks.

Those 20 blocks seem to be arranged in 4 sub-groups arranged like this:
- Blocks 252, 256, 260 and 264 that substitute blocks 40, 41, 49 and 50 of 'wm0.map'.
- Blocks 268, 272, 276, 280, 284 and 288 that substitute blocks 31, 32, 33, 40, 41 and 42 of 'wm0.map'.
- Blocks 292, 296, 300 and 304 that substitute blocks 50, 51, 59 and 60 of 'wm0.map'.
- Blocks 308, 312, 316, 320, 324 and 328 that substitute blocks 37, 38, 39, 46, 47 and 48 of 'wm0.map'.

It seems as if 'wm0.bot' is used to optimize scrolling the world map on the screen... but I wonder why so much redundancy.

Well, that's enough FF7 for me at the moment.

ShinRa Inc

  • *
  • Posts: 416
  • The Ascension of the Ordinary Man
    • View Profile
    • http://shinrainc.org
Re: FF7 World Map geometry
« Reply #13 on: 2006-08-17 05:16:08 »

Some other thing: In the part of the snow storm is there some kind of hut at the end or when you start? Is the rest of the field almost horizontal?
If that's the case, I think WM3 has the WM for that part.


I don't remember if that map has a 'hut' on one of the edges or not (I don't think it does), but it does have a small hill/cave in the center, as I recall.  (it's been a while, tho)