P3D Lod Faces: Difference between revisions
m (→LodFace) |
mNo edit summary |
||
Line 2: | Line 2: | ||
Alias 'Polygons' | Alias 'Polygons' | ||
=LodFaces= | |||
struct | |||
{ | |||
ulong nFaces; | |||
ulong AllocationSize; // see below | |||
LodFace LodFaces[nFaces]; | |||
} | |||
=LodFace= | =LodFace= | ||
LodFace | LodFace | ||
Line 86: | Line 92: | ||
3. 3rd vertice descriptor | 3. 3rd vertice descriptor | ||
4. 2nd vertice descriptor | 4. 2nd vertice descriptor | ||
==AllocationSize== | |||
Because of the variable amount of face vertices (3 or 4), AllocationSize is used to | |||
*skip the block. | |||
*calculate memory requirements | |||
It's value is relative to the first entry and is computed as follows | |||
AllocationSize= nFaces* (SizeofEach (FaceVertice)); | |||
'''In Memory''', as allocated by the engine, each FaceVertice is: | |||
{| class="wikitable" | |||
|- | |||
! Engine | |||
! FaceFlag | |||
! TextureIndex | |||
! FaceType | |||
! Indexes | |||
|- | |||
| On Disk | |||
| sizeof(ulong) | |||
| sizeof(short) | |||
| sizeof(byte) | |||
| sizeof(short) | |||
| | |||
|- | |||
| OFP (V7) | |||
| sizeof(ulong) | |||
| sizeof(short) | |||
| bgcolor="red" |sizeof(ulong) | |||
| sizeof(short) | |||
| | |||
|- | |||
| Size | |||
| 4+ | |||
| 2+ | |||
| 4+ | |||
| 2*FaceType | |||
| always 16 or 18 | |||
|- | |||
| ARMA (V4x) | |||
| | |||
| | |||
| bgcolor="red" |sizeof(short) | |||
| sizeof(short) | |||
| | |||
|- | |||
| Size | |||
| | |||
| | |||
| 2+ | |||
| 2*FacetType | |||
| always 8 or 10 | |||
|} | |||
This, is the MEMORY requirement. To calculate the offset to the sections struct | |||
*V7 OffsetToSectionsStruct = AllocationSize- 3*nFaces; | |||
*V4x OffsetToSectionsStruct = AllocationSize- nFaces; | |||
The difference being between sizeof(byte) vs long and short respectively | |||
[[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]] |
Revision as of 15:21, 21 May 2010
Alias 'Polygons'
LodFaces
struct { ulong nFaces; ulong AllocationSize; // see below LodFace LodFaces[nFaces]; }
LodFace
LodFace { //////////// MLOD //////////////////////// char TextureName[32] // SP3X ONLY (ofp) ulong FaceType; // 3==Triangle or 4==Box PsuedoVertexTable PsuedoVertexTables[4];// ulong FaceFlags; // P3D Point and Face Flags Asciiz TextureName; // P3DM ONLY (arma) Asciiz MaterialName; // P3DM ONLY (arma) ////////// ODOL //////////////////////// ulong FaceFlags; //ODOL7 ONLY see P3D Point and Face Flags short TextureIndex; //ODOL7 ONLY byte FaceType; // 3==Triangle or 4==Box ushort VertexTableIndex[FaceType]; ////////////////////////////////////////// }
There are always 3, or 4, vertices represented by the value in FaceType.
- 3 point vertices describe a triangle.
- 4 point vertices describe a rectangle.
Ultimately, the value points to a vertex table comprising of points, normals and uvset(s).
- Odol: The actual vertex wanted for each of the vertices of a triangle (eg) are carried in an index table within this structure. The so-called VertexTableIndex. This index table looks up the VertexTable of the lod.
- Mlod: The values of each vertex are supplied in a PsuedoVertexTable. Within which, are indexes to the respective points and normals. The PsuedoVertexTable has a fixed size of 4 vertices. The 4th is unused for triangles.
Indices themselves must be transformed as follows
- triangles : 1st posn, 2nd posn, 0th posn.
- quadrangles : 1st, 2nd, 3rd, 0th
The TextureIndex is a zero based array. If set to -1, there are no textures
In Arma, the FaceFlags and Texture Index have been moved out to their own LodSections.
PsuedoVertexTable
PsuedoVertexTable { ulong PointsIndex; ulong NormalsIndex; float U,V; }
Polygon Vertex Order
For a visible 3-vertex polygon:
AB // clockwise order C . AC // CounterClock B
The same for 4-vertex polygon:
AB // clockwise DC . AD // CounterClock BC
Your 3D device will cull invisible polygons. An invisible polygon is a polygon that has the other direction order. For example, DirectX default setting is 'cull counterclockwise polygons', so only clockwise is visible.
Vertices must be reordered for clockwise vertex order (default for DirectX), and not changed for counterclockwise order:
for 3-vertices polygon: 1. 1st vertice descriptor 2. 3rd vertice descriptor 3. 2nd vertice descriptor 4. (not used, zero filled)
for 4-vertices polygon: 1. 1st vertice descriptor 2. 4th vertice descriptor 3. 3rd vertice descriptor 4. 2nd vertice descriptor
AllocationSize
Because of the variable amount of face vertices (3 or 4), AllocationSize is used to
- skip the block.
- calculate memory requirements
It's value is relative to the first entry and is computed as follows
AllocationSize= nFaces* (SizeofEach (FaceVertice));
In Memory, as allocated by the engine, each FaceVertice is:
Engine | FaceFlag | TextureIndex | FaceType | Indexes | |
---|---|---|---|---|---|
On Disk | sizeof(ulong) | sizeof(short) | sizeof(byte) | sizeof(short) | |
OFP (V7) | sizeof(ulong) | sizeof(short) | sizeof(ulong) | sizeof(short) | |
Size | 4+ | 2+ | 4+ | 2*FaceType | always 16 or 18 |
ARMA (V4x) | sizeof(short) | sizeof(short) | |||
Size | 2+ | 2*FacetType | always 8 or 10 |
This, is the MEMORY requirement. To calculate the offset to the sections struct
- V7 OffsetToSectionsStruct = AllocationSize- 3*nFaces;
- V4x OffsetToSectionsStruct = AllocationSize- nFaces;
The difference being between sizeof(byte) vs long and short respectively