P3D File Format - ODOLV7: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 1: Line 1:
{{unsupported-doc}}
{{unsupported-doc}}


===Legend===
 
=General=
==Legend==
see [[Generic FileFormat Data Types]]
see [[Generic FileFormat Data Types]]
==CompressedStructures==


===Intro===
(potentially) compressed arrays are endemic to most blocks contained in a p3d.
 
====CompressedStruct====
 
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 31: 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[Header.LodCount];
   LodStruct         Lods[Header.LodCount];
   struct    ModelInfo;            //see [[P3D Model Info]]
   [[P3D Model Info|ModelInfo]]         ModelInfo;
  };
  };


====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
  {
  {
   VertexTable    VertexTable;
   [[#VertexTable|VertexTable]]   VertexTable;
   float          UnknownFloat1;
   float          UnknownFloat1;
   float          UnknownFloat2;
   float          UnknownFloat2;
Line 66: Line 58:
   XYZTriplet    AutoCenterPos;
   XYZTriplet    AutoCenterPos;
   float          UnknownFloat3;
   float          UnknownFloat3;
   Textures      Textures;
   [[#Textures|Textures]]       Textures;
   LodEdges      LodEdges;                          // see [[P3D Lod Edges]]
   [[P3D Lod Edges|LodEdges]]       LodEdges;       
   ulong          NoOfFaces;
   ulong          NoOfFaces;
   ulong          OffsetToLodSections;
   ulong          OffsetToLodSections;
   LodFace        LodFaces[NoOfFaces];              // ie polygons see [[P3D Lod Faces]]
   [[P3D Lod Faces|LodFace]]       LodFaces[NoOfFaces];              // ie polygons
   ulong          nSections;
   ulong          nSections;
   LODSection    LODSections[nSections];           // see [[P3D Lod Sections]]
   [[P3D Lod Sections|LODSection]]     LODSections[nSections];
   ulong          nNamedSelections;
   ulong          nNamedSelections;
   NamedSelection NamedSelections[nNamedSelections]; // see [[P3D Named Selections]]
   [[P3D Named Selections|NamedSelection]] NamedSelections[nNamedSelections];
   ulong          nTokens;
   ulong          nTokens;
   NamedProperty  NamedProperties[nTokens];
   [[#NamedProperty|NamedProperty]] NamedProperties[nTokens];
   ulong          nFrames;
   ulong          nFrames;
   Frame          Frames[nFrames];                   // see [[P3D Lod Frames]]
   [[P3D Lod Frames|Frame]]         Frames[nFrames];  
   ulong          IconColor;
   ulong          IconColor;
   ulong          SelectedColor;
   ulong          SelectedColor;
   ulong          Unknown;
   ulong          Unknown;
   ulong          nProxies;
   ulong          nProxies;
   LodProxy      LodProxies[nProxies];             // see [[[P3D Lod Proxies]]
   [[P3D Lod Proxies|LodProxy]]       LodProxies[nProxies];
  };
  };


Line 90: Line 82:
   {  
   {  
     ulong      Count;               
     ulong      Count;               
     ulong      PointFlags[Count];  // compressed. see [[P3D Point Flags]]
     ulong      PointFlags[Count];  // compressed. see [[P3D Point and Face Flags]]
     ulong      Count;             
     ulong      Count;             
     UVPair      UV1[Count];        // compressed  
     UVPair      UV1[Count];        // compressed  

Revision as of 02:44, 23 May 2010

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