Difference between revisions of "War Drum OpenGL Native Data"

From GTAMods Wiki
Jump to navigation Jump to search
(Created page with "This page describes the format of pre-instanced DFFs as used by the mobile GTA games. =Bin Mesh= The Bin Mesh's chunk format is almost the same...")
 
Line 8: Line 8:
 
The Native Data has no child Struct like on the other platforms and not platform information.
 
The Native Data has no child Struct like on the other platforms and not platform information.
  
  4b - RwUInt32   - number of attributes
+
  RwUInt32       number of attributes (numAttribs)
 +
#repeat for numAttribs (attribute description)
 +
    RwUInt32  attribute index
 +
    RwInt32    type (0 = GL_FLOAT, 1 = GL_BYTE, 2 = GL_UNSIGNED_BYTE, 3 = GL_SHORT, 4 = GL_UNSIGNED_SHORT)
 +
    RwBool    isNormalized
 +
    RwInt32    size
 +
    RwUInt32  stride (same for all attributes)
 +
    RwUInt32  offset
 +
#endrepeat
 +
RwUInt8        data[stride*geometry->numVertices]
  
Next come the attribute descriptions:
+
Apart from the type, attribute descriptions can be directly passed to [https://www.khronos.org/opengles/sdk/docs/man/xhtml/glVertexAttribPointer.xml glVertexAttribPointer].
 
 
4b - RwUInt32  - attribute index
 
4b - RwInt32    - type (0 = GL_FLOAT, 1 = GL_BYTE, 2 = GL_UNSIGNED_BYTE, 3 = GL_SHORT, 4 = GL_UNSIGNED_SHORT)
 
4b - RwBool    - isNormalized
 
4b - RwInt32    - size
 
4b - RwUInt32  - stride
 
4b - RwUInt32  - offset
 
 
 
Apart from the type, these can be directly passed to [https://www.khronos.org/opengles/sdk/docs/man/xhtml/glVertexAttribPointer.xml glVertexAttribPointer].
 
 
 
Next is the vertex data as described by the attribute descriptions.
 
Since the size of a vertex is given by the stride of the attribute descriptions, the size of the vertex data is <code>stride*geometry->numVertices</code>.
 
  
 
== Indices ==
 
== Indices ==
  
Each vertex attribute in an OpenGL shader has an index. The indices used by hte mobile GTAs are the following:
+
Each vertex attribute in an OpenGL shader has an index. The indices used by the mobile GTAs are the following:
  
 
  0 - vertex position
 
  0 - vertex position
Line 35: Line 32:
 
  5 - bone indices (only used with skinned geometry)
 
  5 - bone indices (only used with skinned geometry)
 
  6 - extra color (only used with SA's extra color plugin)
 
  6 - extra color (only used with SA's extra color plugin)
 +
 +
= Skin =
 +
 +
The Skin chunk contains a Struct chunk with the following data:
 +
 +
RwUInt32  platform ID (2 for OpenGL)
 +
RwUInt32  number of Bones (numBones)
 +
RwReal    matrices[numBones][16]

Revision as of 10:00, 13 August 2015

This page describes the format of pre-instanced DFFs as used by the mobile GTA games.

Bin Mesh

The Bin Mesh's chunk format is almost the same as in non-instanced DFFs. The only difference is that the indices are RwUInt16 (as used internally by RW) instead of RwUInt32.

Native Data

The Native Data has no child Struct like on the other platforms and not platform information.

RwUInt32       number of attributes (numAttribs)
#repeat for numAttribs (attribute description)
    RwUInt32   attribute index
    RwInt32    type (0 = GL_FLOAT, 1 = GL_BYTE, 2 = GL_UNSIGNED_BYTE, 3 = GL_SHORT, 4 = GL_UNSIGNED_SHORT)
    RwBool     isNormalized
    RwInt32    size
    RwUInt32   stride (same for all attributes)
    RwUInt32   offset
#endrepeat
RwUInt8        data[stride*geometry->numVertices]

Apart from the type, attribute descriptions can be directly passed to glVertexAttribPointer.

Indices

Each vertex attribute in an OpenGL shader has an index. The indices used by the mobile GTAs are the following:

0 - vertex position
1 - tex coord 0
2 - normal
3 - color
4 - vertex weights (only used with skinned geometry)
5 - bone indices (only used with skinned geometry)
6 - extra color (only used with SA's extra color plugin)

Skin

The Skin chunk contains a Struct chunk with the following data:

RwUInt32  platform ID (2 for OpenGL)
RwUInt32  number of Bones (numBones)
RwReal    matrices[numBones][16]