Difference between revisions of "RpGeometry"

From GTAMods Wiki
Jump to navigation Jump to search
m (Structure)
m
Line 8: Line 8:
  
 
  2b - WORD  - Flags (See [[Geometry (RW Section)#Flags|below]])
 
  2b - WORD  - Flags (See [[Geometry (RW Section)#Flags|below]])
  1b - BYTE  - Number of UV coordinates (GTA default is 1)
+
  1b - BYTE  - Number of UV coordinates (up to 8 sets of UVs, GTA default is 1, 2 for vehicle with reflection maps)
 
  1b - BYTE  - Geometry native flags
 
  1b - BYTE  - Geometry native flags
 
                 // 0x01 rpGEOMETRYNATIVE
 
                 // 0x01 rpGEOMETRYNATIVE
Line 14: Line 14:
 
  4b - DWORD  - Triangle count
 
  4b - DWORD  - Triangle count
 
  4b - DWORD  - Vertex count
 
  4b - DWORD  - Vertex count
  4b - DWORD  - Frame count
+
  4b - DWORD  - Number of morphing targets (blend shapes). Morphing is not used in GTA series, so only one "target" is presented.
  
 
For all [[RenderWare_binary_stream_file#Common_RW_Version_IDs|versions]] below '''3.4''' also some lightning color values are stored.
 
For all [[RenderWare_binary_stream_file#Common_RW_Version_IDs|versions]] below '''3.4''' also some lightning color values are stored.
  
  4b - DWORD - Ambient color (Represents an DirectX <code>D3DCOLOR</code> value {{ref|1}})
+
  4b - float - Ambient
  4b - DWORD - Diffuse color (Represents an DirectX <code>D3DCOLOR</code> value)
+
  4b - float - Diffuse
  4b - DWORD - Specular color (Represents an DirectX <code>D3DCOLOR</code> value)
+
  4b - float - Specular
  
 
=== Flags ===
 
=== Flags ===
Line 54: Line 54:
 
If '''flag 8''' is enabled vertex color information for each vertex get stored up next:
 
If '''flag 8''' is enabled vertex color information for each vertex get stored up next:
  
  4b - DWORD  - Vertex color (D3DCOLOR)
+
  4b - DWORD  - Vertex color (RwRGBA)
 
 
The default value is 0x00FFFFFF (representing non-transparent white).
 
  
 
With ''San Andreas'' Rockstar's engine is able to change the vertex colors for ingame nights. Therefor there is an [[List of RW section IDs#Rockstar.27s_Custom_Sections|custom section]] called [[Night Vertex Colors (RW Section)|Night Vertex Colors]]. This prevents the game from loading new models at different times and increments the performance of the engine. Previous games stored copies of the model with different prelightning information and defined it inside the [[TOBJ]] [[IDE]] section.
 
With ''San Andreas'' Rockstar's engine is able to change the vertex colors for ingame nights. Therefor there is an [[List of RW section IDs#Rockstar.27s_Custom_Sections|custom section]] called [[Night Vertex Colors (RW Section)|Night Vertex Colors]]. This prevents the game from loading new models at different times and increments the performance of the engine. Previous games stored copies of the model with different prelightning information and defined it inside the [[TOBJ]] [[IDE]] section.
Line 62: Line 60:
 
=== Texture/UV coordinates ===
 
=== Texture/UV coordinates ===
  
If '''flag 4''' or '''128''' is set texture coordinates are following next. If both are set then the texture coordinates for the first texture of all vertices are listed before the texture coordinates for the second chanel of all vertices (By default no GTA game ever uses more than 1 UV coordinate at one time).
+
If '''flag 4''' or '''128''' is set texture coordinates are following next. If both are set then the texture coordinates for the first texture of all vertices are listed before the texture coordinates for the second chanel of all vertices. There's a maximum of 8 sets for texture coordinates, but GTA games uses only first (diffuse map) or second (reflection map) set.
  
 
  4b - FLOAT  - Texture coordinate U
 
  4b - FLOAT  - Texture coordinate U
 
  4b - FLOAT  - Texture coordinate V
 
  4b - FLOAT  - Texture coordinate V
  
=== Indices/Attributes ===
+
=== Triangles ===
  
The following array holds indices and attributes for each triangle. The number of indices is represented by the third multiple of the triangle count value. So for each triangle the following format gets used:
+
The following array holds indices and material IDs for each triangle. The number of indices is represented by the third multiple of the triangle count value. So for each triangle the following format gets used:
  
 +
2b - WORD  - Index of second vertex
 
  2b - WORD  - Index of first vertex
 
  2b - WORD  - Index of first vertex
  2b - WORD  - Index of second vertex
+
  2b - WORD  - Material ID
2b - WORD  - Attribute for line/triangle
 
 
  2b - WORD  - Index of third vertex
 
  2b - WORD  - Index of third vertex
 
''Attribute'' describes an index of a subset map of the geometry. Those maps are collectrions of faces with the same material stored inside the [[Bin Mesh PLG (RW Section)|Bin Mesh PLG section]].
 
  
 
=== Bounding information ===
 
=== Bounding information ===
Line 86: Line 82:
 
  4b - FLOAT  - Center Z
 
  4b - FLOAT  - Center Z
 
  4b - FLOAT  - Radius of bounding sphere
 
  4b - FLOAT  - Radius of bounding sphere
  4b - DWORD  - Has position
+
  4b - DWORD  - Has positions
 
  4b - DWORD  - Has normals
 
  4b - DWORD  - Has normals
  
The central vector (<code>D3DXVECTOR3</code>) describes the center of the bounding sphere as an offset from the [[IPL|placement]] of the object inside the real world.
+
The central vector (<code>RwV3d</code>) describes the center of the bounding sphere as an offset from the [[IPL|placement]] of the object inside the real world.
  
 
=== Vertex translation info ===
 
=== Vertex translation info ===
  
The number of vertices gets defined inside the geometry structure. If '''flag 2''' is set the translation information gets stored for each vertex as a <code>D3DXVECTOR3</code>:
+
The number of vertices gets defined inside the geometry structure. If '''flag 2''' is set the translation information gets stored for each vertex as a <code>RwV3d</code>:
  
 
  4b - FLOAT  - Position X
 
  4b - FLOAT  - Position X
Line 103: Line 99:
 
=== Normals ===
 
=== Normals ===
  
In case '''flag 16''' is set the [[wikipedia:Surface_normal|normal vectors]] are the last part of the geometry data structure. They are also stored as a <code>D3DXVECTOR3</code> for each vertex:
+
In case '''flag 16''' is set the [[wikipedia:Surface_normal|normal vectors]] are the last part of the geometry data structure. They are also stored as a <code>RwV3d</code> for each vertex:
  
 
  4b - FLOAT  - Direction X
 
  4b - FLOAT  - Direction X

Revision as of 00:22, 29 April 2015

{{{NAME}}}
RenderWare Stream Section
Vendor {{{VENDORNAME}}}
Module {{{MODULENAME}}}
Module ID 0x{{{MODULEID}}}
Identifier 0x{{{IDENTIFIER}}}
Chunk ID 0x{{{MODULEID}}}{{{IDENTIFIER}}}
Versions All
Hierarchy
Parents:
None
Children:
None
Extensions:
None
File Format

Geometry is a container section used in DFF files as child of a Geometry List section. The section itself does not store any data at all. All additional information get stored inside a struct section which directly follows this one as a child. Geometry is one of the most important sections inside a .dff model file. It stores geometry information for models (like the mesh and the texture maps).

Structure

The structure differs for most files, but it always gets introduced by the following set of values:

2b - WORD   - Flags (See below)
1b - BYTE   - Number of UV coordinates (up to 8 sets of UVs, GTA default is 1, 2 for vehicle with reflection maps)
1b - BYTE   - Geometry native flags
                // 0x01 rpGEOMETRYNATIVE
                // 0x02 rpGEOMETRYNATIVEINSTANCE
4b - DWORD  - Triangle count
4b - DWORD  - Vertex count
4b - DWORD  - Number of morphing targets (blend shapes). Morphing is not used in GTA series, so only one "target" is presented.

For all versions below 3.4 also some lightning color values are stored.

4b - float  - Ambient
4b - float  - Diffuse
4b - float  - Specular

Flags

The following flags descripe the behaviour of the mesh during the rendering progress. Some of the flags indicate the existance of data inside the following file format.

Flag Binary Description
1
0000 0000 0000 0001
Is triangle strip (if disabled it will be an triangle list)
2
0000 0000 0000 0010
Vertex translation (D3DFVF_XYZ)
4
0000 0000 0000 0100
Texture coordinates 1 (D3DFVF_TEX1)
8
0000 0000 0000 1000
Vertex colors (D3DFVF_DIFFUSE)
16
0000 0000 0001 0000
Store normals (D3DFVF_NORMAL)
32
0000 0000 0010 0000
Dynamic vertex lightning (?)
64
0000 0000 0100 0000
Modulate material color
128
0000 0000 1000 0000
Texture coordinates 2 (D3DFVF_TEX2)

All of those flags (except the first) are used to build up the flexible vertex format (FVF) [2].

Prelightning/Vertex colors

If flag 8 is enabled vertex color information for each vertex get stored up next:

4b - DWORD  - Vertex color (RwRGBA)

With San Andreas Rockstar's engine is able to change the vertex colors for ingame nights. Therefor there is an custom section called Night Vertex Colors. This prevents the game from loading new models at different times and increments the performance of the engine. Previous games stored copies of the model with different prelightning information and defined it inside the TOBJ IDE section.

Texture/UV coordinates

If flag 4 or 128 is set texture coordinates are following next. If both are set then the texture coordinates for the first texture of all vertices are listed before the texture coordinates for the second chanel of all vertices. There's a maximum of 8 sets for texture coordinates, but GTA games uses only first (diffuse map) or second (reflection map) set.

4b - FLOAT  - Texture coordinate U
4b - FLOAT  - Texture coordinate V

Triangles

The following array holds indices and material IDs for each triangle. The number of indices is represented by the third multiple of the triangle count value. So for each triangle the following format gets used:

2b - WORD   - Index of second vertex
2b - WORD   - Index of first vertex
2b - WORD   - Material ID
2b - WORD   - Index of third vertex

Bounding information

The bounding information are used to check weather the mesh is visible for the camera, or not. It only exists once per geometry section.

4b - FLOAT  - Center X
4b - FLOAT  - Center Y
4b - FLOAT  - Center Z
4b - FLOAT  - Radius of bounding sphere
4b - DWORD  - Has positions
4b - DWORD  - Has normals

The central vector (RwV3d) describes the center of the bounding sphere as an offset from the placement of the object inside the real world.

Vertex translation info

The number of vertices gets defined inside the geometry structure. If flag 2 is set the translation information gets stored for each vertex as a RwV3d:

4b - FLOAT  - Position X
4b - FLOAT  - Position Y
4b - FLOAT  - Position Z

The position values are an offset relative to the mesh pivot.

Normals

In case flag 16 is set the normal vectors are the last part of the geometry data structure. They are also stored as a RwV3d for each vertex:

4b - FLOAT  - Direction X
4b - FLOAT  - Direction Y
4b - FLOAT  - Direction Z

Child sections

Extension

The extension of an geometry usually holds the following sections in the order they are listed in here:

See also

References

^ * http://msdn.microsoft.com/en-us/library/bb172518%28VS.85%29.aspx
^ * http://msdn.microsoft.com/en-us/library/bb172559%28VS.85%29.aspx