Wrp File Format - OPRWv17 to 24
Current state of my researches on OPRW18 file format. Any additions, suggestions, etc. are appreciated.
char[4] sig //"OPWR"
ulong version //0x12
ulong [2] x,y //texture cell dimension.
ulong [2] x,y //elevations cell dimensions.
float gridSize //in meters
//still unknown stuff here
Peak List
{
ulong size //maybe + 1
float[size][3] XYZ //Position of the Peak(Y is heigth)
}
ushort[][] TextureIndices //need still some research here
ushort[gridX][gridY] unknown //packed
byte[gridX][gridY] envSounds? //packed
float[gridX][gridY] elevation //packed
Rvmat List
{
ulong number of rvmats + 1
ushort 0x0
Rvmat entry
{
asciiz rvmat name
byte 0x00
}
}
Model List (w/o class names)
{
ulong size //number of models
asciiz[size] model_path //e.g. ca\buildings\kostelik.p3d
}
Model List (w/ class names)
{
ulong size //number of models
Model
{
asciiz class_name //e.g. Land_Hangar
asciiz model_path
float[3] unknown
ulong unknown
}
}
//probably 2 blocks in between
//lot of road blocks, which are divided by blocks of 0x00
Roadblock
{
ulong size //number of roadparts
roadpart
{
ushort 0x02
float PosX_Start
float elev_Start
float PosZ_Start
float PosX_End
float elev_End
float PosZ_End
ulong || ushort[2] unknown //sorta index or ID?? or some flag thingy
asciiz model_path
float[12] matrix
}
}
//Block of 0x00
Object List
{
object entry
{
ulong ObjectID
ulong modelIndex
float[12] matrix
ulong 0x02 ??
}
}
//probably data about how objects are displayed in the editor(grey rectangles for buildings, circles for bushes and trees and so on)
unknown Block
{
block entry
{
ulong type
if(type in [0x18,0x1F,0x20]) type1
if(type in [0x03,0x04,0x14) type2
if(type in [0x19]) type3
if(type in [0x02, 0x0A, 0x0B, 0x16]) type4
//for 0x18, 0x1F, 0x20
type1
{
ulong ObjectID
float[4][2] rectangle //boundaries of object
}
//for 0x03, 0x04, 0x14
type2
{
ulong ObjectID
float[4][2] rectangle //boundaries of object
ulong color??
}
//for 0x19
type3
{
ulong 0xFFFFFFFF
ulong unknown
float[4] unknown
}
for 0x02, 0x0A, 0x0B, 0x16
type4
{
ulong ObjectID
float[2] pos
}
}
Are you still interested in some input/observations or are you fine now? -- Sy 09:16, 9 October 2008 (CEST)
- Of course I am still interested. Gimme all you have and know ;) --T_D 15:18, 9 October 2008 (CEST)
TextureGridModels
Ok, first let's talk about the area of the file you call the 'Road Block'.
As you've noted it appears at first glance to be road models with intermittent x00 blocks.
First of all find the first lot of road models in your file and you'll see there is a 'block' of x00's before these... Navigate backwards through these x00's till they stop being x00's.
This is the real start of this area of the file.
You should see 3 int's before it starts into the x00's.
- The first int is undecided about at the moment.
- The second int is the number of 'classless' objects there are in the file. Further talk about this later as there is a small issue with this.
- The third int would be better described as a long because it's the total size of the structure of this area of the file. This, structure size int is then the starting point for this area of the file.
At the moment a preference exists to describe this part of the file as the 'TextureGridModels' area. This is because it is a area that is of the form int[TxGrid_Z, TxGrid_X]. Although the models defined within this area always seem to be of the 'road' type I have for the moment decided to call the area (as mentioned) 'TextureGridModels' to identify this area as a list of models within each cell of the 'TextureGrid'. It is imagined at some later date this area would most likely be renamed to something like 'TextureGridRoads' or 'RoadNetworks' or just 'Roads' or some such.
To illustrate... If there were NO roads and the texture grid was 128 x 128 then this entire block would be 128 x 128 0x0000 entries, or 65,536 bytes in length. This size would also be equal to the 'Third' integer I mentioned above.
Everytime you come across a number in one of these 'slots' (if you will) it represents how many 'sub-objects' are present in this one cell. Then of course the 'sub-objects' are defined. At the end of these 'sub-objects' you are into the next 'cell' of the grid array.
Do you understand this?
Objects
As you've already indicated the structure that directly follows the above 'TextureGridModels' area is of course the 'Objects' list. Probably, more accurately it's the list of 'Classless' models that are present on the island. The problem is that the '2nd int' that was mentioned at the beginning of the 'TextureGridModels' area it apprears now is the 'maximum' object Id that is present on the island. This, is because in the are often quite a number of items less than this, but never more, of course. Eg. In a large island that comes with the 'ca' mod the NoOfObjects or MaxObjectId is 637,876 and the number of actual objects in the list array is 602,481. And, the highest Object Id in this list array is 637,876. It's unfortunate at this time that the array does not contain 637,876 entries, with some of them say having an Object Id of -1 or something as this would then mean that the '2nd int' truly would indicate the NoOfObjects in the array list of 'Classless Objects'. Currently, this makes iterating this area a little difficult.
Map Object Features
Dunno, if this is an appropriate name for this area but you have an accurate description for it anyway. The only thing to add is that it extends to the the EndOfFile. And, there are a number of other values + another type. Some quick psdeuo-code...
while (filepointer < filesize)
{
//type1 = Id, x, z
//type2 = Id, Bounds (float[8])
//type3 = int[2], float[4]
//type4 = Id, Bounds (float[8]), Colour (byte[4])
//type5 = Id, float[4]
type=readint();
switch(type)
{
case 0:
{
typeid = TypeIdEnum.Type1;
break;
}
case 1:
{
typeid = TypeIdEnum.Type1;
break;
}
case 2:
{
typeid = TypeIdEnum.Type1;
break;
}
case 3:
{
typeid = TypeIdEnum.Type4;
break;
}
case 4:
{
typeid = TypeIdEnum.Type4;
break;
}
case 8:
{
typeid = TypeIdEnum.Type4;
break;
}
case 9:
{
typeid = TypeIdEnum.Type4;
break;
}
case 10:
{
typeid = TypeIdEnum.Type1;
break;
}
case 11:
{
typeid = TypeIdEnum.Type1;
break;
}
case 14:
{
typeid = TypeIdEnum.Type1;
break;
}
case 15:
{
typeid = TypeIdEnum.Type1;
break;
}
case 16:
{
typeid = TypeIdEnum.Type1;
break;
}
case 17:
{
typeid = TypeIdEnum.Type1;
break;
}
case 18:
{
typeid = TypeIdEnum.Type4;
break;
}
case 20:
{
typeid = TypeIdEnum.Type4;
break;
}
case 22:
{
typeid = TypeIdEnum.Type1;
break;
}
case 23:
{
typeid = TypeIdEnum.Type1;
break;
}
case 24:
{
typeid = TypeIdEnum.Type2;
break;
}
case 25:
{
typeid = TypeIdEnum.Type3;
break;
}
case 26:
{
typeid = TypeIdEnum.Type1;
break;
}
case 27:
{
typeid = TypeIdEnum.Type1;
break;
}
case 28:
{
typeid = TypeIdEnum.Type4;
break;
}
case 29:
{
typeid = TypeIdEnum.Type4;
break;
}
case 30:
{
typeid = TypeIdEnum.Type1;
break;
}
case 31:
{
typeid = TypeIdEnum.Type2;
break;
}
case 32:
{
typeid = TypeIdEnum.Type2;
break;
}
case 33:
{
typeid = TypeIdEnum.Type3;
break;
}
case 34:
{
typeid = TypeIdEnum.Type5;
break;
}
default:
{
typeid = TypeIdEnum.Nothing;
break;
}
}
}
TextureIndices / TextureGridMaterials
This area as you are probably aware maps the 'TextureGrid' to the material files and (near the beginning of the file) is almost analysed.
That's all to add at this stage. Besides, what you had originally was enough to get a working .pew out of...
If the style in which the above info. is conveyed maybe difficult to envisage or follow, apologies.
Was this at all helpful? If you have any questions or further insights...