|
|
(31 intermediate revisions by 2 users not shown) |
Line 1: |
Line 1: |
| {{unsupported-doc}} | | {{unsupported-doc}} |
|
| |
|
| ===Legend===
| |
| byte: 8 bits unsigned
| |
| char: 8 bit ascii character
| |
| char[]: fixed length string
| |
| asciiz: null terminated char string
| |
| asciiz... concatetaned asciiz strings
| |
| asciiz[]: fixed length and null terminated anyway
| |
| ulong: unsigned integer 32bit. 4 bytes
| |
| ushort: unsigned integer 16bit 2 bytes
| |
| short: signed integer 16bit 2 bytes
| |
| float: 4 bytes
| |
|
| |
|
| ===Intro=== | | =General= |
| | ==Legend== |
| | see [[Generic FileFormat Data Types]] |
| | ==CompressedStructures== |
|
| |
|
| ====CompressedStruct====
| | (potentially) compressed arrays are endemic to most blocks contained in a p3d. |
| | |
| ODOL7 uses (potentially) compressed arrays.
| |
| | |
| This obviously slows the engine down during loading. At the time of CWC development, game file sizes were important.
| |
| | |
| (potentially) compressed arrays are contained in a CompressedStruct | |
| | |
| CompressedStructs are endemic to most blocks contained in the p3d.
| |
|
| |
|
| CompressedStruct | | CompressedStruct |
Line 40: |
Line 24: |
|
| |
|
| Thus for various Array <types> | | Thus for various Array <types> |
| *ulong Array: > 255 // 1024 / sizeof(ulong)
| | *ulong Array: > 255 // 1024 / sizeof(ulong) |
| *float thing[2]: > 127 // 1024 / 2*sizeof(float)
| | *float thing[2]: > 127 // 1024 / 2*sizeof(float) |
| *SomeStructure: > // count * sizeof (SomeStructure) > 1023
| | *SomeStructure: > // count * sizeof (SomeStructure) > 1023 |
| | |
|
| |
|
| | Note that potentially compressed arrays in these structures only have an known output length. the decompressor therefore must work on infinite input length. |
|
| |
|
| Note that potentially compressed arrays in these structures only have an known output length.
| |
| the decompressor therefore must work on infinite input length.
| |
| see example decompression at end of document
| |
|
| |
|
| ===Odol7Stuct===
| | =Odol7Stuct= |
| ODOLV7 | | ODOLV7 |
| { | | { |
| StandardP3DHeader Header; | | StandardP3DHeader Header; |
| LodStruct Lods[LodCount]; | | LodStruct Lods[Header.LodCount]; |
| float Resolution[LodCount]; | | [[P3D Model Info|ModelInfo]] ModelInfo; |
| ulong Unknown; // typically 02 01 00 00
| |
| float Pair[2]; // typically 48 74 07 3F : 48 74 07 3F . pair is often the same
| |
| ulong Unknown[3] // typically 00 00 00 00 00 00 00 00 00 00 B0 0D
| |
| bytes Unknown[120]; // a mixture of floats and index values
| |
| bytes UnknownFlags[6]; // typically 01 00 00 01 00 16
| |
| ulong Count;
| |
| float Array[Count]; // potentially compressed
| |
| float UnknownFloats[4];// almost consistently 00 00 00 00 : F9 02 15 50 : 00 00 48 43 : 0A D7 A3 3B
| |
| ulong UnknownLongs[3]; // generally FF FF FF FF FF FF FF FF FF FF FF FF
| |
| }; | | }; |
|
| |
|
| ====StandardP3DHeader====
| | ==StandardP3DHeader== |
| StandardP3DHeader | | StandardP3DHeader |
| { | | { |
| char Signature[4]; ''//"ODOL"'' | | char Signature[4]; ''//"ODOL" (vs MLOD eg)'' |
| ulong Version; ''// 7'' | | ulong Version; ''// 7'' |
| ulong LodCount; ''// at least one'' | | ulong LodCount; ''// at least one'' |
| } | | } |
|
| |
|
| ===LodStruct===
| | ==LodStruct== |
| LodStruct | | LodStruct |
| { | | { |
| '''structs''' VerticesStructs[...]; | | [[#VertexTable|VertexTable]] VertexTable; |
|
| | float UnknownFloat1; |
| '''float''' Unknown[12]; ''// contains some max/min vertices positions'' | | float UnknownFloat2; |
|
| | XYZTriplet MinPos; |
| '''struct''' TexturesStruct[...]; | | XYZTriplet MaxPos; |
| | | XYZTriplet AutoCenterPos; |
| '''structs''' TableStructs[...]; | | float UnknownFloat3; |
|
| | [[#Textures|Textures]] Textures; |
| '''struct''' FacesStruct[...]; | | [[P3D Lod Edges|LodEdges]] LodEdges; |
|
| | ulong NoOfFaces; |
| '''struct''' UnknownStruct[...]; | | ulong OffsetToLodSections; |
|
| | [[P3D Lod Faces|LodFace]] LodFaces[NoOfFaces]; // ie polygons |
| '''structs''' NamedStructs[...]; | | ulong nSections; |
| | | [[P3D Lod Sections|LODSection]] LODSections[nSections]; |
| '''struct''' UnknownStruct2[...]; | | ulong nNamedSelections; |
|
| | [[P3D Named Selections|NamedSelection]] NamedSelections[nNamedSelections]; |
| '''ulong''' Unknown[3]; | | ulong nTokens; |
|
| | [[#NamedProperty|NamedProperty]] NamedProperties[nTokens]; |
| '''struct''' ProxiStruct[...]; | | ulong nFrames; |
| | [[P3D Lod Frames|Frame]] Frames[nFrames]; |
| | ulong IconColor; |
| | ulong SelectedColor; |
| | ulong Unknown; |
| | ulong nProxies; |
| | [[P3D Lod Proxies|LodProxy]] LodProxies[nProxies]; |
| }; | | }; |
|
| |
|
| ===VerticesStructs=== | | ===VertexTable=== |
| VerticesStructs | | struct |
| { | | { |
| CompressedStruct Attribs | | ulong Count; |
| { | | ulong PointFlags[Count]; // compressed. see [[P3D Point and Face Flags]] |
| '''ulong''' Count; ''// if > 255 then array is compressed
| | ulong Count; |
| '''ulong''' Attribs[Count];
| | UVPair UV1[Count]; // compressed |
| } | | ulong Count; |
| CompressedStruct UVset
| | XYZTriplet Points[Count]; // UNcompressed |
| {
| | ulong Count; |
| '''ulong''' Count; ''// if > 127 then array is compressed
| | XYZTriplet Normals[Count]; // UNcompressed |
| '''float''' UVset[Count]; | |
| } | |
| struct Position
| |
| {
| |
| '''ulong''' Count;
| |
| '''float''' Position[Count][3]; ''// XZY
| |
| } | |
| struct Normals
| |
| {
| |
| '''ulong''' Count;
| |
| '''float''' Normals[Count][3]; ''// XZY
| |
| }
| |
| } | | } |
|
| |
|
| *Count is the same value for all four tables. | | *Count is the same value for all four tables. |
| *The Position and Normals tables appear to be always uncompressed raw data.
| |
|
| |
|
| ===TexturesStruct=== | | ===Textures=== |
| struct Textures | | struct |
| { | | { |
| '''ulong''' Count; | | '''ulong''' Count; |
Line 134: |
Line 101: |
|
| |
|
| Count corresponds to the number of concatenated strings. It is required, since, architecturally at least, one of more of the asciiz strings could be null. | | Count corresponds to the number of concatenated strings. It is required, since, architecturally at least, one of more of the asciiz strings could be null. |
|
| |
| ===TableStruct===
| |
| struct TableStruct
| |
| {
| |
| CompressedStruct
| |
| {
| |
| '''ulong''' Count; ''// if > 511 etc''
| |
| '''ushort''' MlodIndex[Count];
| |
| }
| |
| CompressedStruct
| |
| {
| |
| '''ulong''' Count; ''// this Count is same value as any Vertices.Count''
| |
| '''ushort''' OdolIndex[Count];''//
| |
| }
| |
| }
| |
|
| |
| Tables are used to join vertices. Each face has got 3 or 4 vertices that are unique for each face Eg. Every vertex is owned only by 1 face.
| |
| '''MLOD'''vertexindex = MlodIndex[ OdolIndex['''ODOL'''vertexindex] ];''
| |
|
| |
| ===FacesStruct===
| |
| struct Faces
| |
| {
| |
| '''ulong''' FacesCount;
| |
| '''ulong''' unknown;
| |
| '''struct''' Face
| |
| {
| |
| '''ulong''' Attribs;
| |
| '''short''' TextureIndex;
| |
| '''byte''' Count; // always 3 or 4
| |
| '''ushort''' VerticesIndex[Count];
| |
| }[FacesCount];
| |
| };
| |
|
| |
| The TextureIndex is a zero based array. If set to -1, there are no textures for this face.
| |
|
| |
| ===UnknownStruct===
| |
| UnknownStruct
| |
| {
| |
| '''ulong''' Count;
| |
| '''byte''' Unknown[Count][18];
| |
| }
| |
|
| |
| ===NamedStruct===
| |
| NamedStruct
| |
| {
| |
| CompressedStruct Selection
| |
| {
| |
| '''ulong''' Count;
| |
| '''struct''' NamedSelection[Count];
| |
| }
| |
| struct NamedProperties
| |
| {
| |
| '''ulong''' Count;
| |
| '''struct'''
| |
| {
| |
| '''asciiz''' Name; ''// "noshadow\0"
| |
| '''asciiz''' Value; ''//"1\0"'
| |
| }Properties[Count];
| |
| }
| |
| }
| |
|
| |
|
| |
|
|
| |
|
| ====NamedSelection==== | | ===NamedProperty=== |
| '''struct''' NamedSelection
| | struct |
| {
| |
| '''asciiz''' name;
| |
| CompressedStruct Vertices
| |
| {
| |
| '''ulong''' Count; ''// if > 511 then array is compressed
| |
| '''ushort''' Vertices[Count];
| |
| }
| |
| CompressedStruct UnknownUshort
| |
| {
| |
| '''ulong''' Count; ''// if > 511 then array is compressed
| |
| '''ushort''' Unknown[Count];
| |
| }
| |
| CompressedStruct UnknownUlong
| |
| {
| |
| '''ulong''' Count; ''// if > 255 then array is compressed
| |
| '''ulong''' Unknown[Count];
| |
| }
| |
| '''byte''' Unknown;
| |
| CompressedStruct UnknownUlong2
| |
| {
| |
| '''ulong''' Count; ''// if etc
| |
| '''ulong''' Unknown[Count];
| |
| }
| |
| CompressedStruct Faces
| |
| {
| |
| '''ulong''' Count; ''// if etc
| |
| '''ushort''' Faces[Count];
| |
| }
| |
| CompressedStruct TextureWeights // probably
| |
| { | | { |
| '''ulong''' Count; ''// if etc
| | Asciiz Property;// "noshadow" = "1" eg |
| '''byte''' TextureWeights[Count];
| | Asciiz Value; |
| } | | } |
| };
| |
|
| |
| ===UnknownStruct2===
| |
| UnknownStruct2
| |
| {
| |
| ulong Count;
| |
| struct Unknown
| |
| {
| |
| ulong uvalue;// unknown value
| |
| ulong Count;
| |
| float array[Count][3];
| |
| }[Count];
| |
| };
| |
|
| |
|
| ===ProxiStruct===
| |
| ProxiStruct
| |
| {
| |
| '''ulong''' Count;
| |
| '''struct''' Proxi
| |
| {
| |
| '''asciiz''' Name;
| |
| '''float''' rotationMatrix[9];
| |
| '''float''' translation[3];
| |
| '''ulong''' Index[2];
| |
| }[Count];;
| |
| }
| |
|
| |
| ===LZ in ODOL===
| |
|
| |
| ''Lempel-Ziv compression
| |
|
| |
| Note1.
| |
|
| |
| Regardless of method, 4 extra bytes representing the checksum exist at end of the data count.
| |
|
| |
| Note2.
| |
| The compression code is identical to that employed by pbo packed structures. However, unlike pbo's, the size of the compressed data is unknown, only it's ultimate length. The code below fudges it.
| |
|
| |
|
| |
| ==== pascal code====
| |
|
| |
| '''function''' LZBlockRead(var F:file; var outdata:array of byte;szout:integer):byte;
| |
| '''var'''
| |
| k, r, pr, pi,po,i,j:integer;
| |
| flags:word;
| |
| buf:'''array'''[0..$100e] '''of''' byte;
| |
| c:byte;
| |
| crc:integer;
| |
| '''begin'''
| |
| po:=0;
| |
| pi:=0;
| |
| flags:=0;
| |
| r:=0;
| |
| '''for''' k := 0 '''to''' $100F-1 '''do''' buf[k] := $20;
| |
| '''while''' (po < szout) '''do'''
| |
| '''begin'''
| |
| flags:= flags '''shr''' 1;
| |
| '''if''' ((flags '''and''' $100)= 0) '''then'''
| |
| '''begin'''
| |
| BlockRead(F,c,1); ''// direct reading from file''
| |
| inc(pi);
| |
| flags := c '''or''' $ff00;
| |
| '''end''';
| |
| '''if''' (flags and 1)=1 '''then'''
| |
| '''begin'''
| |
| '''if''' (po >= szout)'''then''' '''break''';
| |
| BlockRead(F,c,1); ''// direct reading from file''
| |
| inc(pi);
| |
| outdata[po] := c;
| |
| inc(po);
| |
| buf[r] := c;
| |
| inc(r);
| |
| r :=r and $fff;
| |
| '''end'''
| |
| '''else'''
| |
| '''begin'''
| |
| i:=0;
| |
| BlockRead(F,i,1); ''// direct reading from file''
| |
| inc(pi);
| |
| j:=0;
| |
| BlockRead(F,j,1);'' // direct reading from file''
| |
| inc(pi);
| |
| i :=i or ((j '''and''' $f0) shl 4);
| |
| j := (j '''and''' $0f) + 2;
| |
| pr := r;
| |
| '''for''' k := 0 '''to''' j '''do'''
| |
| '''begin'''
| |
| c := buf[(pr - i + k''') and''' $fff];
| |
| '''if''' (po >= szout) '''then break''';
| |
| outdata[po]:= c;
| |
| inc(po);
| |
| buf[r]:= c;
| |
| inc(r);
| |
| r :=r '''and''' $fff;
| |
| '''end''';
| |
| '''end''';
| |
| '''end''';
| |
| BlockRead(F,crc,4); ''// 4 byte checksum.''
| |
| result:= pi;
| |
| '''end''';
| |
|
| |
| ====C code====
| |
|
| |
| '''int''' Decode('''unsigned char''' *in,'''unsigned char''' *out,'''int''' szin,'''int''' szout)
| |
| {
| |
| szin = szin > 0? szin: 0x7fffffff;
| |
| '''int''' i, j, k, r = 0, pr, pi = 0,po = 0;
| |
| '''unsigned int''' flags = 0;
| |
| '''unsigned char''' buf[0x100F], c;
| |
| '''for''' (i = 0; i < 0x100F; buf[i] = 0x20, i++);
| |
| '''while''' (pi < szin && po < szout)
| |
| {
| |
| '''if''' (((flags >>= 1) & 256) == 0)
| |
| {
| |
| '''if'''(pi >= szin)'''break''';
| |
| c = in[pi++];
| |
| flags = c | 0xff00;
| |
| }
| |
| '''if''' (flags & 1)
| |
| {
| |
| '''if'''(pi >= szin || po >= szout)'''break''';
| |
| c = in[pi++];
| |
| out[po++] = c;
| |
| buf[r++] = c;
| |
| r &= 0xfff;
| |
| } '''else'''
| |
| {
| |
| '''if'''(pi + 1 >= szin)'''break''';
| |
| i = in[pi++];
| |
| j = in[pi++];
| |
| i |= (j & 0xf0) << 4;
| |
| j = (j & 0x0f) + 2;
| |
| pr = r;
| |
| '''for''' (k = 0; k <= j; k++)
| |
| {
| |
| c = buf[(pr - i + k) & 0xfff];
| |
| '''if'''(po >= szout)'''break''';
| |
| out[po++] = c;
| |
| buf[r++] = c;
| |
| r &= 0xfff;
| |
| }
| |
| }
| |
| }
| |
| '''return''' pi;// next 4 bytes = checksum
| |
| }
| |
|
| |
|
| =Related Page(s)= | | =Related Page(s)= |
| | ==LZ in ODOL== |
| | see [[Compressed LZSS File Format]] |
|
| |
|
| [[BIS_File_Formats#3D_Model_File_Formats|Model File Formats]] | | [[BIS_File_Formats#3D_Model_File_Formats|Model File Formats]] |
| [[Category:BIS_File_Formats]] | | [[Category:BIS_File_Formats]] |
Template:unsupported-doc
General
Legend
see Generic FileFormat Data Types
CompressedStructures
(potentially) compressed arrays are endemic to most blocks contained in a p3d.
CompressedStruct
{
ulong Count;
<type> Array[Count];
};
if Count * sizeof(<type>) exceeds 1023 bytes the array is compressed. The resulting array will be expanded using lzh compression exactly as found in pbo's (for instance)
After de-compression, the Count remains the same because it is a count of the arraytype.
For uncompressed arrays (byte count < 1024) the Count and data are treated 'as is'.
Thus for various Array <types>
- ulong Array: > 255 // 1024 / sizeof(ulong)
- float thing[2]: > 127 // 1024 / 2*sizeof(float)
- SomeStructure: > // count * sizeof (SomeStructure) > 1023
Note that potentially compressed arrays in these structures only have an known output length. the decompressor therefore must work on infinite input length.
Odol7Stuct
ODOLV7
{
StandardP3DHeader Header;
LodStruct Lods[Header.LodCount];
ModelInfo ModelInfo;
};
StandardP3DHeader
StandardP3DHeader
{
char Signature[4]; //"ODOL" (vs MLOD eg)
ulong Version; // 7
ulong LodCount; // at least one
}
LodStruct
LodStruct
{
VertexTable VertexTable;
float UnknownFloat1;
float UnknownFloat2;
XYZTriplet MinPos;
XYZTriplet MaxPos;
XYZTriplet AutoCenterPos;
float UnknownFloat3;
Textures Textures;
LodEdges LodEdges;
ulong NoOfFaces;
ulong OffsetToLodSections;
LodFace LodFaces[NoOfFaces]; // ie polygons
ulong nSections;
LODSection LODSections[nSections];
ulong nNamedSelections;
NamedSelection NamedSelections[nNamedSelections];
ulong nTokens;
NamedProperty NamedProperties[nTokens];
ulong nFrames;
Frame Frames[nFrames];
ulong IconColor;
ulong SelectedColor;
ulong Unknown;
ulong nProxies;
LodProxy LodProxies[nProxies];
};
VertexTable
struct
{
ulong Count;
ulong PointFlags[Count]; // compressed. see P3D Point and Face Flags
ulong Count;
UVPair UV1[Count]; // compressed
ulong Count;
XYZTriplet Points[Count]; // UNcompressed
ulong Count;
XYZTriplet Normals[Count]; // UNcompressed
}
- Count is the same value for all four tables.
Textures
struct
{
ulong Count;
asciiz Textures[...]; // "data/1.paa\0data/2.paa\0"...
}
Count corresponds to the number of concatenated strings. It is required, since, architecturally at least, one of more of the asciiz strings could be null.
NamedProperty
struct
{
Asciiz Property;// "noshadow" = "1" eg
Asciiz Value;
}
Related Page(s)
LZ in ODOL
see Compressed LZSS File Format
Model File Formats