P3D File Format - ODOLV7: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (moved lodframes to own page)
m (moved proxy to own page)
Line 59: Line 59:
  LodStruct
  LodStruct
  {
  {
   struct        VertexTable;
   VertexTable    VertexTable;
   struct         UnknownStruct; // contains some max/min vertices positions
   UVPair         UnknownUV; // just a guess         
   struct        TexturesStruct;
  XYZTriplet    MinPos;
   struct        VertexIndices;  
  XYZTriplet    MaxPos;
  XYZTriplet    AutoCenterPos;
  float          UnknownFloat;
   Textures      Textures;
   VertexIndices  VertexIndices;  
   ulong          NoOfFaces;
   ulong          NoOfFaces;
   ulong          OffsetToSectionStruct;
   ulong          OffsetToLodSections;
   LodFace        LodFaces[NoOfFaces];     // ie polygons see [[P3D Lod Faces]]
   LodFace        LodFaces[NoOfFaces];               // ie polygons see [[P3D Lod Faces]]
   ulong          nSections;
   ulong          nSections;
   LODSection    LODSections[nSections]; // see [[P3D Lod Sections]]
   LODSection    LODSections[nSections];           // see [[P3D Lod Sections]]
   ulong          nNamedSelections;
   ulong          nNamedSelections;
   NamedSelection NamedSelections[nNamedSelections]; //See [[P3D Named Selections]]
   NamedSelection NamedSelections[nNamedSelections]; // see [[P3D Named Selections]]
   ulong          nNamedProperties;
   ulong          nTokens;
   NamedProperty  NamedProperties[nNamedProperties];
   NamedProperty  NamedProperties[nTokens];
   ulong          nFrames;
   ulong          nFrames;
   Frame          Frames[nFrames]; // see [[P3D Lod Frames]]
   Frame          Frames[nFrames];                   // see [[P3D Lod Frames]]
   ulong          IconColor;
   ulong          IconColor;
   ulong          SelectedColor;
   ulong          SelectedColor;
   ulong          Unknown;
   ulong          Unknown;
   ulong          nProxies;
   ulong          nProxies;
   ProxyStruct    ProxyStructs[nProxies];  
   LodProxy      LodProxies[nProxies];             // see [[[P3D Lod Proxies]]
  };
  };


===VertexTable===
===VertexTable===
   VertexTable
   struct
   {  
   {  
     CompressedStruct PointFlags //(vertices)
     ulong      Count;             
     {
     ulong       PointFlags[Count]; // compressed. see [[P3D Point Flags]]
    ulong Count;             // see [[P3D Point(Vertex) Flags]]
    ulong       Count;            
    ulong PointFlag[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
     UVPair UVsets[Count];      
    }
    struct Points // (Vertices)
     {
    ulong     Count;               
    XYZTriplet Point[Count];  
     }
    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.


====UVPair====
====UVPair====
  UVSet
  struct
  {
  {
   float U,V;
   float U,V;
}
===UnKnownStruct===
UnKnownStruct
{
  UVPair      UnknownUV; // just a guess         
  XYZTriplet  MinPos;
  XYZTriplet  MaxPos;
  XYZTriplet  AutoCenterPos;
  float        UnknownFloat;
  }
  }


===TexturesStruct===
===Textures===
   struct Textures
   struct
   {
   {
   '''ulong'''  Count;
   '''ulong'''  Count;
Line 134: Line 116:


===VertexIndices===
===VertexIndices===
  VertexIndices
  struct
  {
  {
  CompressedStruct
   '''ulong'''  Count;             
  {
   '''ushort''' MlodIndex[Count];                   //Compressed
   '''ulong'''  Count;            ''// if > 511 etc'' 
   '''ulong'''  nVerticesStructs;                   //same value as any of the VerticesStruct.Counts''
   '''ushort''' MlodIndex[Count];
   '''ushort''' VerticesStructNum[nVerticesStructs];//Compressed
  }
  CompressedStruct
  {
   '''ulong'''  nVerticesStructs;           ''// same value as any of the VerticesStruct.Counts''
   '''ushort''' VerticesStructNum[nVerticesStructs];
  }
  }
  }


Line 154: Line 130:


===NamedProperty===
===NamedProperty===
 
   struct
   NamedProperty
   {
   {
    '''asciiz''' Name; ''// "noshadow\0"
    Asciiz Property;// "noshadow" = "1" eg
    '''asciiz''' Value; ''//"1\0"'
    Asciiz Value;
  };
  }
 
 
 
===ProxyStruct===
ProxyStruct
{
  asciiz          Name;
  TransformMatrix Transform;//see [[Generic FileFormat Data Types]]
  ulong          Indices[2];
}
 





Revision as of 03:33, 20 May 2010

Template:unsupported-doc

Legend

see Generic FileFormat Data Types

Intro

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
{
  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. see example decompression at end of document

Odol7Stuct

ODOLV7
{
  StandardP3DHeader Header;
  LodStruct Lods[Header.LodCount];
  struct    ModelInfo;            //see P3D Model Info
};

StandardP3DHeader

StandardP3DHeader
{
  char      Signature[4];      //"ODOL"
  ulong     Version;           // 7
  ulong     LodCount;          // at least one
}

LodStruct

LodStruct
{
 VertexTable    VertexTable;
 UVPair         UnknownUV; // just a guess           
 XYZTriplet     MinPos;
 XYZTriplet     MaxPos;
 XYZTriplet     AutoCenterPos;
 float          UnknownFloat;
 Textures       Textures;
 VertexIndices  VertexIndices; 
 ulong          NoOfFaces;
 ulong          OffsetToLodSections;
 LodFace        LodFaces[NoOfFaces];               // ie polygons see P3D Lod Faces
 ulong          nSections;
 LODSection     LODSections[nSections];            // see P3D Lod Sections
 ulong          nNamedSelections;
 NamedSelection NamedSelections[nNamedSelections]; // see P3D Named Selections
 ulong          nTokens;
 NamedProperty  NamedProperties[nTokens];
 ulong          nFrames;
 Frame          Frames[nFrames];                   // see P3D Lod Frames
 ulong          IconColor;
 ulong          SelectedColor;
 ulong          Unknown;
 ulong          nProxies;
 LodProxy       LodProxies[nProxies];              // see [[[P3D Lod Proxies]]
};

VertexTable

 struct
 { 
   ulong       Count;              
   ulong       PointFlags[Count];  // compressed. see P3D Point 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.

UVPair

struct
{
 float U,V;
}

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.

VertexIndices

struct
{
  ulong  Count;            
  ushort MlodIndex[Count];                   //Compressed
  ulong  nVerticesStructs;                   //same value as any of the VerticesStruct.Counts
  ushort VerticesStructNum[nVerticesStructs];//Compressed
}

For each of the VerticesStructs (0..Count-1) there is a lookup into the MlodIndex

MLODvertexindex = MlodIndex[ VerticesStructNum[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.

NamedProperty

 struct
 {
    Asciiz Property;// "noshadow" = "1" eg
    Asciiz Value;
 }


Related Page(s)

LZ in ODOL

see Compressed LZSS File Format

Model File Formats