View Single Post
  #36  
Old 01-28-2002, 02:41 AM
Windcatcher
Demi-God
 
Join Date: Jan 2002
Posts: 1,175
Default

Here's what I know (maybe someone can host a FAQ or spec or something--it won't be me though):


Data21
------

The Data21 structure is the main binary tree of the zone. For any given zone, there is only one Data21 structure. I don't know why they use a binary tree, maybe it makes searching easier, but I don't understand how you use a binary efficiently in a three-dimensional space. Anyhow, Data21 contains a number of elements.

Each element is a node in the tree, and either has child nodes or is a leaf node. If it has child nodes, then Index1[0] points to the left node (if any) and Index1[1] points to the right node. They contain zero if there is no such node. If it is a leaf node, then Params2[0] will contain the index of the Data22 structure that this leaf refers to.

Okay, I did some more playing with this. It seems that the tree is used for searching. Basically every node is either a "stem" node or a "leaf" node. Stem nodes contain a vector in the Params1[] array, where the first three elements describe a unit vector (a vector whose length is 1) and the fourth element describes the length of the vector. The idea is thus: the very first node is at the position of a Data22 region (it is a good idea to start at the region closest to the xyz center of the zone). The vector in Params1[] points to another region (probably the closest one). EVERYTHING on that side (the point) of the vector lies on the right half of the tree (that is, originates with Index1[1]), while EVERYTHING on the tail end of the vector (the originating point) is on the same side as the initial region. Thus, each node subdivides zone space into two pieces. Each subnode further subdivides the remaining space into two pieces, and so on, until each subdivision contains only one region. At that point, leaf nodes are written, where all elements of Params1[] and Index1[] contain zero and Params2[] points to the region.

It should be noted that this tree points to ALL Data22 regions, not just the ones that map to Data36 polygons. For instance, trees, braziers, and other "canned" objects are referenced by Data22 regions, but those regions do not point to any Data36 structures.

Data22
------

Data22 structures represent leaf nodes in the Data21 tree. Each Data22 structure represents a "region" in the zone. A region contains EVERYTHING in a cubical area that is 128 world coordinates on a side. So, for example, a zone with an east-west size of 1280 would be ten regions across in the east-west direction. Note that this also applies to height; mountainous zones therefore would have layers of regions stacked on top of one another. It is not necessary that a zone have a "complete" rectangular array of regions; therefore, an irregularly shaped zone need not have any Data22 structures for places where there are no polygons. Perhaps this is the purpose of the Data21 binary-tree format: to save space and memory.

The Params3[] numbers look very interesting but I don't know what they do.

It seems that not all Data22 structures refer to a Data36 structure in the Fragment3 field. Presumably this means that there can be Data22 structures that don't refer to a polygon. Perhaps they refer to lighting? Global objects? It is as yet unknown.

Data36
------

Each Data22 structure may point to one any only one Data36 structure. A Data36 structure contains all of the polygon information for that particular region. The Data1[] array contains a list of polygon vertices. Data1[] is NOT an orderd array; it is simply a list. The Data5[] array is the actual list of polygons (triangles ONLY!!!), where the last three elements are indexes to elements in the Data1[] array. There is also a scaling factor represented by the Size10 value. It represents a power of 2 and is used to create very small polygons. For example, if Size10 contains 4, then each (X,Y,Z) value is divided by 16 = (1 Shl 4) before being rendered. Finally, the Params1[] array in each Data36 structure is an offset point. Therefore, after scaling each vertex, the X,Y,Z value is added to the corresponding Params1 element to form the final vertex.

Presumably the Data36 structure should contain texture information, but this is as yet undiscovered. I strongly suspect that the Data4[] array refers to textures somehow but I have been unable to decipher it.

Data2[] appears to contain two signed 16-bit values for each vertex in the master vertex list. I don't know what they represent. Could these be texture coordinates? From what I've seen, most BMP textures are either 128x128 or 64x64 in size, so maybe these are fixed-point coordinates? My guess is that texture coordinates have to be accurate to a fraction of an actual texture pixel to prevent artifacts.

Data3[] seems to contain three signed 8-bit values for each vertex in the master vertex list. My hunch is that they represent normal vectors for Phong (or is it Goraud?) shading, but I haven't tested it. If I remember correctly, Goraud shading uses normals to each polygon whereas Phong uses normals to each vertex, but it's been years since I delved into that stuff.The current thinking is that Fragment1 points to a texture list (a Data31 structure), and that Fragment4 points to a texture, but I'm not convinced of that as of yet. This definitely needs more inspection.

The function of Params3 is as yet unknown.

Important note: Polygons NEVER cross region boundaries. If a polygon spans two or more regions, it appears that it is ALWAYS subdivided into multiple polygons such that each polygon ends at a region boundary.


Data03
------

This appears to be a direct reference to a BMP texture file. It seems to be the lowest-level of texture referencing.


Data04
------

This seems to point to one or more Data03 structures. Perhaps it involves some sort of texture mixing or alternation?


Data05
------

This seems to point to one and only one Data04 structure.


Data30
------

Edit: These do in fact point to Data05 structures. The reference to the Data05 structure shows up as "FRG(-1)" for instance because the Data05 structures generally don't have a printable name. The -1 means that the index of the Data05 structure is -1 plus the index of the current Data30 structure (i.e. the Data30 structure is pointing to the structure immediately preceding it).

Params2 looks a lot like an RGBA color but it could also be a coordinate or vector.


Data31
------

This seems to be a master texture list, and points to all of the Data30 structures in the zone.


Data29
------

In every file I've seen so far, this is the last structure in the file. There can actually be more than one Data29 structure, but the reason is unknown. It appears to point to one or more Data22 structures, where each element in the Data1[] array is an index of a Data22 structre. It appears to detail special areas, like PvP regions, water, and zone points.


Data2A
------

Seems to have something to do with lighting. I haven't investigated this, but it seems similar to Data29 in that it looks like it contains a number of indices to (presumably) Data22 or Data36 structures (I'd guess Data22).

WC
Reply With Quote