P3D Named Selections: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (→‎ODOL: section index)
Line 72: Line 72:
   LodNamedSelection
   LodNamedSelection
   {
   {
     asciiz      SelectedName;                         // "rightleg" or "neck" eg
     asciiz      SelectedName;                       // "rightleg" or "neck" eg
     ulong      NoOfFaces;
     ulong      NoOfFaces;
     ushort      FaceIndexes[NoOfFaces];            // indexing into the LodFaces Table
     ushort      FaceIndexes[NoOfFaces];            // indexing into the LodFaces Table
     ulong      Always0Count;
     ulong      Always0Count;
     unknownType Array[Always0Count]
     unknownType Array[Always0Count]                 //IsSectional must be true
     ///// ODOL7 only ///////////////////
     ///// ODOL7 only ///////////////////
     ulong      Count;
     ulong      Count;
     ulong      UnknownV7Array[Count];
     ulong      UnknownV7Array[Count];
     ////////////////////////////////////
     ////////////////////////////////////
     tbool      IsSectional;                                 //Appears in the sections[]= list of a model.cfg
     tbool      IsSectional;                       //Appears in the sections[]= list of a model.cfg
     ulong      NoOfUlongs;
     ulong      NoOfUlongs;
     ulong      UnknownArray[NoOfUlongs];
     ulong      SectionIndex[NoOfUlongs];         //IsSectional must be true. Indexes into the LodSections Table
     ulong      nVertices;
     ulong      nVertices;
     ushort      VertexTableIndexes[nVertices];
     ushort      VertexTableIndexes[nVertices];

Revision as of 13:11, 14 May 2010

Template:unsupported-doc

Intro

currently a place holder until this is better organised

MLOD

Named Selections are contained in the Taggs structure in MLOD file format

struct structTag_SelectedWeighted { TinyBool Active; //Always true asciiz "<Any Ascii Characters>\0"; ulong NoOfBytes; //eg. Will always be NoOfPoints + NoOfFaces byte[NoOfPoints] SelectedWeightedPoints; byte[NoOfFaces] SelectedFaces; }

NB: The byte array's indicate a zero-based offset into the corresponding Points & Faces structures.

To clarify, the purpose of this 'chunk' is to denote which points & faces belong to a given 'Named Selection' and also to denote the 'per-point-weight' associated with this selection.

Each byte in the SelectedWeightedPoints array denotes a value 0 to 255 (0 to FF hex).

And, serves a dual purpose in...

1. Denoting the selectedness and
2. Denoting per point weighting.


  • Zero (0) or 0x00 hex indicates the corresponding point in the LODs Points array is not selected.
Any value other than zero indicates that the point is not only part of the selection but also has a weighting value.


  • One (1) or 0x01 hex indicates the corresponding point in the LODs Points array is selected and has 100% weighting.
Every value between 2 and 255 (0x02 to 0xFF hex) indicates the percentage weight of the corresponding point and that it is part of the selection.
Two (2) being almost 100% weighted and 255 being almost 0% weighted.


Following is some appropriate pseudo-code to illustrate.

byte2weight

float32 byte2weight = (256 - weight)/255; if (byte2weight > 1.0) then byte2weight = 0; Where 'weight' is a unit8 (single byte) in the range... 0 >= weight <= 255 or 0x00 >= weight <= 0xFF.

weight2byte

unit8 weight2byte = round(256 - (255 x weight),0); if (weight2byte == 256) then weight2byte = 0; Where 'weight' is a float32 in the range... 0.0 >= weight <= 1.0.

ODOL

All arrays are subject to the 1024 rule. Which type of compression depends on odol version

  • ODOL7 and ODOL40: LZSS compressed
  • Arma2: LZO compressed.
 LodNamedSelection
 {
   asciiz      SelectedName;                       // "rightleg" or "neck" eg
   ulong       NoOfFaces;
   ushort      FaceIndexes[NoOfFaces];             // indexing into the LodFaces Table
   ulong       Always0Count;
   unknownType Array[Always0Count]                 //IsSectional must be true
   ///// ODOL7 only ///////////////////
   ulong       Count;
   ulong       UnknownV7Array[Count];
   ////////////////////////////////////
   tbool       IsSectional;                       //Appears in the sections[]= list of a model.cfg
   ulong       NoOfUlongs;
   ulong       SectionIndex[NoOfUlongs];          //IsSectional must be true. Indexes into the LodSections Table
   ulong       nVertices;
   ushort      VertexTableIndexes[nVertices];
   ulong       nTextureWeights;
   byte        VerticesWeights[nTextureWeights];  // if present they correspond to (are exentsions of) the VertexTableIndexes
 }