Wrp File Format - OPRWv17 to 24 – Talk

From Bohemia Interactive Community
Jump to navigation Jump to search
(→‎packed blocks: null GridBlocks)
m (Talk:T D's Sandbox moved to Talk:OPRW v18 File Format: progress is far enough now I guess)
(No difference)

Revision as of 21:24, 11 December 2008

For the TextureIndices block I found out that it is organized in 8x4 blocks. If the block starts with 0x00 you just read in 32 short values describing the block. Otherwise you mostly see 2 identical short values describing one 8x4 block filled just with this value. Sometimes instead of the 0x00 value or the 2 identical short values, other values occur probably describing what sort of data follows and what position the next 8x4 block in the whole texX x texZ block has. But I am still not sure what order these 8x4 blocks follow. The TextureIndices block also seems to start with some "header" data which I couldnt identify so far. --T_D 12:11, 13 October 2008 (CEST)


The unknown int in the the TextureGridRoads block is the checksum of the packed data before so it does not belong to the TextureGridRoads block --T_D 14:54, 17 October 2008 (CEST)
Agreed, yeah... saw that, also, maxObjectID isn't part of the TextureGridRoads structure and it will probably end up really being NoOfObjects.
No it is not NoOfObjects. Already checked that by reading objects from 8WVR and comparing readed objects with this value --T_D 04:33, 18 October 2008 (CEST)
Experience has taught me that one can never be to certain about these things until one is certain, if you know what I mean... :)
It maybe MaxObjectId it maybe not... time will tell.
Building the standard SampleMap.pew into a 8wvr.wrp yeilds 5134 obejcts, then into a oprw18.wrp yeilds 5132 in the MaxOjectId/NoOfObjects field. If you add 1 to this value this is the number of obejcts that happens to be in the array of objects in this particular file.
However, this senario doesn't hold true for a certain 'ca' mod oprw18.wrp. That value (as I mentioned earlier) is 637,876 and the number of actual objects in the list array is 602,481.
This may be because there is a prior structure in the file that denotes out of the 637,876 objects ones that are not specified in the Objects array... dunno, well see if that pans out.
The most logical senario is that this is the NoOfObjects less some other structure count = ObejctList count.
If this isn't the senario then there maybe another ObjectCount item lying around the file somewhere that does indicate how many objects are in the objects list array.


this block ushort[gridZ][gridX] unknown //packed seems to consist of random numbers. So my guess is, that these random values are used to calculate the positions of the clutter models, so that the island is always looking the same without saving the pos of every grass model. Could this be the case? --T_D 13:50, 19 October 2008 (CEST)

struct GridBlock

I have kept the names below as simply indices and blocks, A and B, rather than MaterialIndicesBlockFlags X,Y, and blah


where a GridBlock has no data

struct NullGridBlock
{
 byte Flag; // =0
 ulong NullBits; // always 0
}

when the GridBlock has data

struct GridBlock
{
 byte   Flag;  // =1
 ABPacket[1];
}


ABPacket
{
  ushort      flagbits;
  Array[16];   Mixtures of 16 ABpairs and/or more ABPackets
}


The atomic unit of each indices block is a ushort pair A,B

ABPair
{
 ushort AB[2];
}

A and B are mostly the same value. For the rvmat index table eg, they are regressively linear (9,9,9,9,8,8,8,8,7,7,7,7 etc) Other tables appear to be flag types

flagbits declare how many ABpairs and how many EMBEDDED ABpackets are in *this* array. A mixture of up to 16 items exist for each ABpacket.

Embedded ABPackets can (and often do) contain further, embedded ABpackets.

There is only a single ABpacket struct to start off. Everything else in the block, is embedded to that 1st struct.



flagbits are read right to left (lsb 1st)

bit = 0 means the next item is an ABpair bit = 1 means next item is the start of an EMBEDDED ABpacket

Flagbit Examples:

0x0000: standard. 16 ABpairs follow
0xFFFF: 16 Embedded ABpackets follow
0xC000: There are 14 ABpairs immediately following this flag, followed by two embedded ABpackets (which in turn will contain more ABPair/Packets)
0x1000: 12 ABpairs followed by One ABpacket followed by 3 AB pairs


the last example is important to understand, when decoding as the 'stream' looks initially complex (it isn't, a simple recursive function can handle this).

To keep it simple, assuming the single (embedded) packet contains a flag of all zeros (meaning 16 ab-pairs follow)

0x1000: means  12 pairs 0x0000 19 pairs 

the last trailing 3 pairs are NOT associated with the embedded packet, they 'follow on' from the initial packet.

I mention the above because in a hex dump, there appears to be no rhyme or reason why some pair strings are one's and two;s, others, quite a lot <grin>


Mikero (nee Ook?)

I think that after the byte Indicator already an ABPacket block follows. It makes sense at least. Your description works so far and I am able to go through this datastructure but we still need to find out how to interprete the data to create TextureIndices[texZ][texX] array --T_D 20:03, 5 December 2008 (CET)

The answer to that is no (it looked very much like a leading ABpacket flag but isn't). It is a chunks flag, declaring how many chunks are in the block. I used Plank's haggis island (32 x 32) to discover the difference. Mikero (nee Ook?)

I have an OPRW for example that doesn't have 4 zero bytes when the chunkFlag bit is zero but instead has 0x10001000 (ABPair?). So I still think that this structure only consist of an ABPacket leaded by an indicatorByte which is probably missing when there are no textures on the island. It would also fit for haggis.wrp. --T_D 15:08, 6 December 2008 (CET)

you're right about that 1st ushort. Have ammended text accordingly

And you are right that the first 2 flag bytes aren't part of an ABPacket --T_D 19:18, 7 December 2008 (CET)

structMaterials

i think the reason for the 1st null entry eg 'one less' than stated is for faster indexing

an material index with a value of zero means, no rvmat, don't go looking.

any other value in the 'cell' (for want of a better term) means the 'cell' has an rvmat.

This is a small point, but, I also suspect that structMaterials is indeed a concatenated string type. I suspect, that BI can add additional rvmats to the same 'object' if they choose to do so. It's very typical of them to use this string type in class:inheritance type stuctures eg.