P3D File Format - ODOLV7: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (moved lodframes to own page)
m (Text replacement - "{{HashLink" to "{{Link")
 
(10 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{unsupported-doc}}
{{Feature|UnsupportedDoc}}
{{TOC|side}}
= General =
 
 
== Legend ==


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


===Intro===


====CompressedStruct====
== CompressedStructures ==


ODOL7 uses (potentially) compressed arrays.
(potentially) compressed arrays are endemic to most blocks contained in a p3d.


This obviously slows the engine down during loading. At the time of CWC development, game file sizes were important.
<syntaxhighlight lang="cpp">
CompressedStruct
{
ulong Count;
<type> Array[Count];
};
</syntaxhighlight>


(potentially) compressed arrays are contained in a CompressedStruct
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)


CompressedStructs are endemic to most blocks contained in the p3d.
After decompression, the Count remains the same because it is a count of the arraytype.


CompressedStruct
For uncompressed arrays (byte count < 1024) the Count and data are treated 'as is'.
{
  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)
Thus for various Array <types>
* ulong Array:    > 255  // 1024 /  sizeof(ulong)
* float thing[2]: > 127  // 1024 / 2*sizeof(float)
* SomeStructure:  >      // count * sizeof (SomeStructure) > 1023


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'.
Note that potentially compressed arrays in these structures only have an known output length. the decompressor therefore must work on infinite input length.




Thus for various Array <types>
= Odol7Stuct =
*ulong Array:    > 255  // 1024 /  sizeof(ulong)
*float thing[2]: > 127  // 1024 / 2*sizeof(float)
*SomeStructure:  >      // count * sizeof (SomeStructure) > 1023


See [[P3D Model Info]].
<syntaxhighlight lang="cpp">
ODOLV7
{
StandardP3DHeader Header;
LodStruct Lods[Header.LodCount];
ModelInfo ModelInfo;
};
</syntaxhighlight>


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===
== StandardP3DHeader ==
ODOLV7
{
  StandardP3DHeader Header;
  LodStruct Lods[Header.LodCount];
  struct    ModelInfo;            //see [[P3D Model Info]]
};


====StandardP3DHeader====
<syntaxhighlight lang="cpp">
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
}
}
</syntaxhighlight>


===LodStruct===
LodStruct
{
  struct        VertexTable;
  struct        UnknownStruct; // contains some max/min vertices positions
  struct        TexturesStruct;
  struct        VertexIndices;
  ulong          NoOfFaces;
  ulong          OffsetToSectionStruct;
  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          nNamedProperties;
  NamedProperty  NamedProperties[nNamedProperties];
  ulong          nFrames;
  Frame          Frames[nFrames]; // see [[P3D Lod Frames]]
  ulong          IconColor;
  ulong          SelectedColor;
  ulong          Unknown;
  ulong          nProxies;
  ProxyStruct    ProxyStructs[nProxies]; 
};


===VertexTable===
== LodStruct ==
  VertexTable
  {
    CompressedStruct PointFlags //(vertices)
    {
    ulong Count;              // see [[P3D Point(Vertex) Flags]]
    ulong PointFlag[Count];   
    }
    CompressedStruct UVset
    {
    ulong  Count;              ''// if > 127 then array is compressed
    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.
See:
*The Position and Normals tables appear to be always uncompressed raw data.
* {{Link|#VertexTable}}
* {{Link|#Textures}}
* [[P3D Lod Edges]]
* [[P3D Lod Faces]]
* [[P3D Lod Sections]]
* [[P3D Named Selections]]
* {{Link|#NamedProperty}}
* [[P3D Lod Frames]]
* [[P3D Lod Proxies]]


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


===TexturesStruct===
<syntaxhighlight lang="cpp">
  struct Textures
LodStruct
  {
{
  '''ulong'''  Count;
VertexTable VertexTable;
  '''asciiz''' Textures[...];         ''// "data/1.paa\0data/2.paa\0"...
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];
};
</syntaxhighlight>


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.
=== VertexTable ===


===VertexIndices===
See [[P3D Point and Face Flags]].
VertexIndices
<syntaxhighlight lang="cpp">
{
struct
  CompressedStruct
{  
  {
ulong Count;
  '''ulong'''  Count;           ''// if > 511 etc'' 
ulong PointFlags[Count]; // compressed
  '''ushort''' MlodIndex[Count];
ulong Count;
  }
UVPair UV1[Count]; // compressed
  CompressedStruct
ulong Count;
  {
XYZTriplet Points[Count]; // UNcompressed
  '''ulong'''  nVerticesStructs;           ''// same value as any of the VerticesStruct.Counts''
ulong Count;
  '''ushort''' VerticesStructNum[nVerticesStructs];
XYZTriplet Normals[Count]; // UNcompressed
  }
}
}
</syntaxhighlight>


For each of the VerticesStructs (0..Count-1) there is a lookup into the MlodIndex
*Count is the same value for all four tables.
'''MLOD'''vertexindex = 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.
=== Textures ===


===NamedProperty===
<syntaxhighlight lang="cpp">
struct
{
ulong Count;
asciiz Textures[...]; // "data/1.paa\0data/2.paa\0"...
}
</syntaxhighlight>


  NamedProperty
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.
  {
    '''asciiz''' Name;  ''// "noshadow\0"
    '''asciiz''' Value; ''//"1\0"'
  };


=== NamedProperty ===


<syntaxhighlight lang="cpp">
struct
{
Asciiz Property; // e.g "noshadow" = "1"
Asciiz Value;
}
</syntaxhighlight>


===ProxyStruct===
ProxyStruct
{
  asciiz          Name;
  TransformMatrix Transform;//see [[Generic FileFormat Data Types]]
  ulong          Indices[2];
}


= Related Page(s) =


== LZ in ODOL ==


=Related Page(s)=
==LZ in ODOL==
see [[Compressed LZSS File Format]]
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]]

Latest revision as of 18:43, 4 January 2023

bi symbol white.png
Disclaimer: This page describes internal undocumented structures of Bohemia Interactive software.

This page contains unofficial information.

Some usage of this information may constitute a violation of the rights of Bohemia Interactive and is in no way endorsed or recommended by Bohemia Interactive.
Bohemia Interactive is not willing to tolerate use of such tools if it contravenes any general licenses granted to end users of this community wiki or BI products.

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 decompression, 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

See P3D Model Info.

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

See:


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

See P3D Point and Face Flags.

	struct
	{ 
	ulong		Count;
	ulong		PointFlags[Count];	// compressed
	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; // e.g "noshadow" = "1"
	Asciiz Value;
}


Related Page(s)

LZ in ODOL

see Compressed LZSS File Format

Model File Formats