Zippy-Egoboo Home EgoWiki > Documentation > MapDataNotes EgoWiki webs:
Main | TWiki | Know | Sandbox
Documentation . { Changes | Index | Search | Go }
Map data in Zippy is still stored in parallel arrays for the moment. Here are some tips on this confusing structure:

Organization

Fans and tiles are the same; the terms may be used interchangeably to describe individual squares on the map; however, the array meshtile[] refers to the portion of the texture graphic used to render a particular tile. Don't get the term "fan" confused with OpenGL's triangle fan construction -- in Egoboo source it just means "tile".

"basicdat/fans.txt" defines 26 tile types. These types tell the engine the following things about tiles of each type:

The first four vertices of every tile correspond to the four corners of the tile, as follows:

Index Location
0 (0, 0) (Top Left)
1 (1, 0) (Top Right)
2 (1, 1) (Bottom Right)
3 (0, 1) (Bottom Left)

Each tile command makes an OpenGL triangle strip.

New Accessor Methods

Wherever possible, the accessor methods in map.h should be used. For example, instead of computing the tile index with meshfanstart[y>>7]+x>>7, use get_tile(x, y). Instead of meshfx[fan]&MESHFXWATER, use tile_has_water(fan). This will make it easier to transition to better storage methods.

Water Tiles

Water is currently pre-generated into blocks of four tiles each which are animated over a cyclic 512-frame pattern for each "level" that is enabled. The four-tile block has the following vertex arrangement:

0---1---0
|   |   |
| 0 | 1 |
|   |   |
3---2---3
|   |   |
| 2 | 3 |
|   |   |
0---1---0

The numbers in the center are the indices of the water tiles in the precomputed block, called the "mode" in the current code. The numbers at the junctions are the indices of the points in water tile 0; the values in tile 0 for these vertices are copied to the other tiles as shown in the diagram.

This pattern is tiled over the whole map so that the edges of adjacent water tiles are seamless. The algorithm for deciding which "mode" a water tile has (which of the precomputed tiles it corresponds to above) is as follows:

(tile_index>>watershift)&2 + tile_index&1

Where "watershift" is the floor of the base-two logorithm of the map width (e.g. 3 for maps < 16 tiles wide, 4 for maps narrower than 32 tiles, etc.). This algorithm only seems to work if the map width is a power of two and in the range [8, 512], but this is not enforced by the map loader -- therefore maps with other widths will have water that is not seamless.

-- ElminI - 23 May 2004

Topic MapDataNotes . { Edit | Attach | Ref-By | Printable | Diffs | r1.3 | > | r1.2 | > | r1.1 | More }
Revision r1.3 - 27 Apr 2005 - 19:09 GMT - ElminI
Parents: WebHome
Copyright © 1999-2003 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding EgoWiki? Send feedback.