Difference between revisions of "RpGeometry"

From GTAMods Wiki
Jump to navigation Jump to search
m (Flags)
m
 
(28 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{RW Section|Geometry|0x000F}}
+
{{RW Section
 +
| NAME = Geometry
 +
| VENDORNAME = Criterion Games
 +
| MODULENAME = Core
 +
| MODULEID = 000000
 +
| IDENTIFIER = 0F
 +
| PARENTS = [[Geometry List (RW_Section)|Geometry List]]
 +
| CHILDREN = [[Struct (RW Section)|Struct]], [[Material List (RW_Section)|Material List]]
 +
| EXTENSIONS = [[Bin Mesh PLG (RW Section)|Bin Mesh PLG]], [[Native Data PLG (RW Section)|Native Data PLG]] ''(Consoles only)'', [[Skin PLG (RW Section)|Skin PLG]], [[Breakable (RW Section)|Breakable]], [[Extra Vert Colour (RW Section)|Extra Vert Colour]], [[Morph PLG (RW Section)|Morph PLG]], [[2d Effect (RW Section)|2d Effect]]
 +
}}
  
'''Geometry''' is a container section used in [[model file|DFF files]] as child of a [[Geometry List (RW Section)|Geometry List]] section. The section itself does not store any data at all. All additional information get stored inside a [[Struct (RW Section)|struct section]] which directly follows this one as a child. ''Geometry'' is one of the most important sections inside a <code>.dff</code> model file. It stores geometry information for models (like the mesh and the texture maps).
+
'''RpGeometry''' is a [[RenderWare]] structure that stores geometric data.  
  
 
== Structure ==
 
== Structure ==
  
The structure differs for most files, but it always gets introduced by the following set of values:
 
  
2b - WORD  - Flags (See [[Geometry (RW Section)#Flags|below]])
+
When streamed in/out it is usually the child of a [[Geometry List (RW_Section)|Geometry List]] chunk and the parent of a [[Struct (RW Section)|Struct]], [[Material List (RW_Section)|Material List]] and [[Extension (RW Section)|Extension]] chunk.
2b - WORD  - Number of UV coordinates used (GTA default is 1)
 
2b - WORD  - Unknown
 
4b - DWORD  - Triangle count
 
4b - DWORD  - Vertex count
 
4b - DWORD  - Morph target count
 
  
For some [[RenderWare_binary_stream_file#Common_RW_Version_IDs|versions]] also some lightning color values are stored.
+
The format of the Geometry's Struct chunk is as follows:
  
* <code>0x0C02FFFF</code> (3.3.0.2 &ndash; used by ''Vice City'')
+
int32        format (see [[RpGeometry#Format|below]])
* <code>0x0800FFFF</code> (3.?.?.? &ndash; used by ''GTA III'')
+
int32        number of triangles (numTriangles)
* <code>0x00000310</code> (3.1.0.0 &ndash; used by ''GTA III'')
+
int32        number of vertices (numVertices)
* <code>0x00000304</code>
+
int32        number of morph targets (numMorphTargets) (morphing is not used in GTA series, so this is always 1)
* <code>0x00000C02</code>
+
#if version < 0x34000
* <code>0x00000800</code>
+
  surface properties:
 +
    float32  ambient
 +
    float32  specular
 +
    float32  diffuse
 +
#endif
 +
 +
#if (format & rpGEOMETRYNATIVE) == 0
 +
    #if (format & rpGEOMETRYPRELIT)
 +
        RwRGBA  prelitcolor[numVertices] (RwRGBA: uint8 r, g, b, a)
 +
    #endif
 +
 +
    #repeat numTexSets (see [[Geometry (RW Section)#Format|below]])
 +
        RwTexCoords    texCoords[numVertices]  (RwTexCoords: float32 u, v)
 +
    #endrepeat
 +
   
 +
    RpTriangle  triangles[numTriangles]  (RpTriangle: uint16 vertex2, vertex1, materialId, vertex3)
 +
#endif
 +
 +
#repeat numMorphTargets
 +
    RwSphere    boundingSphere    (RwSphere: float32 x, y, z, radius)
 +
    bool32      has vertices
 +
    bool32      has normals
 +
    #if has vertices
 +
        RwV3d  vertices[numVertices] (RwV3d: float32 x, y, z)
 +
    #endif
 +
    #if has normals
 +
        RwV3d  normals[numVertices]
 +
    #endif
 +
#endrepeat
  
4b - DWORD  - Ambient color (Represents an DirectX <code>D3DCOLOR</code> value {{ref|1}})
+
=== Format ===
4b - DWORD  - Diffuse color (Represents an DirectX <code>D3DCOLOR</code> value)
 
4b - DWORD  - Specular color (Represents an DirectX <code>D3DCOLOR</code> value)
 
  
=== Flags ===
+
The following flags describe the behaviour of the mesh during the rendering progress. Some of the flags indicate the existence of data inside the following file format.
 
 
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.
 
  
 
{|{{Prettytable}} width="100%" class="collapsible"
 
{|{{Prettytable}} width="100%" class="collapsible"
 
!width="120px"|Flag
 
!width="120px"|Flag
!width="25%"|Binary
+
!width="25%"|Name
 
!Description
 
!Description
 
|-
 
|-
|<center>1</center>||<center><code>0000 0000 0000 0001</code></center>||Is [[wikipedia:Triangle_strip|triangle strip]] (If disabled it appears to be an indexed line list, but this is never used ingame).
+
|0x00000001||rpGEOMETRYTRISTRIP||Is [[wikipedia:Triangle_strip|triangle strip]] (if disabled it will be an triangle list)
 +
|-
 +
|0x00000002||rpGEOMETRYPOSITIONS||Vertex translation
 
|-
 
|-
|<center>2</center>||<center><code>0000 0000 0000 0010</code></center>||Vertex translation (<code>D3DFVF_XYZ</code>)
+
|0x00000004||rpGEOMETRYTEXTURED||Texture coordinates
 
|-
 
|-
|<center>4</center>||<center><code>0000 0000 0000 0100</code></center>||Texture coordinates 1 (<code>D3DFVF_TEX1</code>)
+
|0x00000008||rpGEOMETRYPRELIT||Vertex colors
 
|-
 
|-
|<center>8</center>||<center><code>0000 0000 0000 1000</code></center>||Vertex colors (<code>D3DFVF_DIFFUSE</code>)
+
|0x00000010||rpGEOMETRYNORMALS||Store normals
 
|-
 
|-
|<center>16</center>||<center><code>0000 0000 0001 0000</code></center>||Store normals (<code>D3DFVF_NORMAL</code>)
+
|0x00000020||rpGEOMETRYLIGHT||Geometry is lit (dynamic and static)
 
|-
 
|-
|<center>32</center>||<center><code>0000 0000 0010 0000</code></center>||Dynamic vertex lightning ''(?)''
+
|0x00000040||rpGEOMETRYMODULATEMATERIALCOLOR||Modulate material color
 
|-
 
|-
|<center>64</center>||<center><code>0000 0000 0010 0000</code></center>||Modulate material color
+
|0x00000080||rpGEOMETRYTEXTURED2||Texture coordinates 2
 
|-
 
|-
|<center>128</center>||<center><code>0000 0000 1000 0000</code></center>||Texture coordinates 2 (<code>D3DFVF_TEX2</code>)
+
|0x01000000||rpGEOMETRYNATIVE||Native Geometry
 
|}
 
|}
  
All of those flags (except the first) are used to build up the ''flexible vertex format (FVF)'' {{ref|2}}.
+
Bits 16-23 (mask <code>0x00FF0000</code>) in the format description give the number of texture coordinate sets (numTexSets).
 
+
If the value in the file is zero, rpGEOMETRYTEXTURED means there is one set of texture coordinates, rpGEOMETRYTEXTURED2 means there are two.
=== Prelightning/Vertex colors ===
 
 
 
If '''flag 8''' is enabled vertex color information for each vertex get stored up next:
 
 
 
4b - DWORD  - Vertex color (D3DCOLOR)
 
 
 
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.
 
 
 
=== 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).
 
 
 
4b - FLOAT  - Texture coordinate U
 
4b - FLOAT  - Texture coordinate V
 
 
 
=== Indices/Attributes ===
 
 
 
The following array holds indices and attributes for each triangle (or line, depending on ''flag 1''). The number of indices is represented by the third multiple of the triangle count value (or if the flags define a line list just multiply this value with 2). So for each 'line' the following format gets used:
 
 
 
4b - DWORD  - Index of first vertex
 
4b - DWORD  - Index of second vertex
 
2b - WORD  - Attribute for line/triangle
 
 
 
If '''flag 1''' defines a triangle strip a 3rd index simply gets appended.
 
 
 
4b - DWORD  - 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 position
 
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.
 
 
 
=== 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>:
 
 
 
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 [[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:
 
 
 
4b - FLOAT  - Direction X
 
4b - FLOAT  - Direction Y
 
4b - FLOAT  - Direction Z
 
 
 
== Child sections ==
 
 
 
* [[Material List (RW Section)|Material List]]
 
 
 
=== Extension ===
 
 
 
The [[Extension (RW Section)|extension]] of an geometry usually holds the following sections in the order they are listed in here:
 
 
 
* [[Bin Mesh PLG (RW Section)|Bin Mesh PLG]]
 
* [[Native Data PLG (RW Section)|Native Data PLG]] &ndash; (Only for consoles)
 
* [[Skin PLG (RW Section)|Skin PLG]]
 
* [[Mesh Extension (RW Section)|Mesh Extension]]
 
* [[Night Vertex Colors (RW Section)|Night Vertex Colors]]
 
* [[Morph PLG (RW Section)|Morph PLG]]
 
* [[2dfx (RW Section)|2dfx]]
 
 
 
== See also ==
 
* [[Geometry List (RW Section)|Geometry List]]
 
* [[RenderWare_binary_stream_file|RW file format specification]]
 
  
== References ==
+
If rpGEOMETRYNATIVE is set, the platform dependent geometry data is to be found in the [[Native Data PLG (RW Section)|Native Data]] chunk.
{{Note|1}} * http://msdn.microsoft.com/en-us/library/bb172518%28VS.85%29.aspx<br>
 
{{Note|2}} * http://msdn.microsoft.com/en-us/library/bb172559%28VS.85%29.aspx
 
  
{{N|SA|VC}}
+
{{N|SA|VC|3}}
[[Category:GTA_3]]
 

Latest revision as of 10:58, 14 September 2020

Geometry
RenderWare Stream Section
Vendor Criterion Games
Module Core
Module ID 0x000000
Identifier 0x0F
Chunk ID 0x0000000F
Versions All
Hierarchy
Parents:
Geometry List
Children:
Struct, Material List
Extensions:
Bin Mesh PLG, Native Data PLG (Consoles only), Skin PLG, Breakable, Extra Vert Colour, Morph PLG, 2d Effect
File Format

RpGeometry is a RenderWare structure that stores geometric data.

Structure

When streamed in/out it is usually the child of a Geometry List chunk and the parent of a Struct, Material List and Extension chunk.

The format of the Geometry's Struct chunk is as follows:

int32        format (see below)
int32        number of triangles (numTriangles)
int32        number of vertices (numVertices)
int32        number of morph targets (numMorphTargets) (morphing is not used in GTA series, so this is always 1)
#if version < 0x34000
  surface properties:
    float32  ambient
    float32  specular
    float32  diffuse
#endif

#if (format & rpGEOMETRYNATIVE) == 0
    #if (format & rpGEOMETRYPRELIT)
        RwRGBA   prelitcolor[numVertices] (RwRGBA: uint8 r, g, b, a)
    #endif

    #repeat numTexSets (see below)
        RwTexCoords    texCoords[numVertices]  (RwTexCoords: float32 u, v)
    #endrepeat
   
    RpTriangle   triangles[numTriangles]  (RpTriangle: uint16 vertex2, vertex1, materialId, vertex3)
#endif

#repeat numMorphTargets
    RwSphere    boundingSphere    (RwSphere: float32 x, y, z, radius)
    bool32      has vertices
    bool32      has normals
    #if has vertices
        RwV3d   vertices[numVertices] (RwV3d: float32 x, y, z)
    #endif
    #if has normals
        RwV3d   normals[numVertices]
    #endif
#endrepeat

Format

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

Flag Name Description
0x00000001 rpGEOMETRYTRISTRIP Is triangle strip (if disabled it will be an triangle list)
0x00000002 rpGEOMETRYPOSITIONS Vertex translation
0x00000004 rpGEOMETRYTEXTURED Texture coordinates
0x00000008 rpGEOMETRYPRELIT Vertex colors
0x00000010 rpGEOMETRYNORMALS Store normals
0x00000020 rpGEOMETRYLIGHT Geometry is lit (dynamic and static)
0x00000040 rpGEOMETRYMODULATEMATERIALCOLOR Modulate material color
0x00000080 rpGEOMETRYTEXTURED2 Texture coordinates 2
0x01000000 rpGEOMETRYNATIVE Native Geometry

Bits 16-23 (mask 0x00FF0000) in the format description give the number of texture coordinate sets (numTexSets). If the value in the file is zero, rpGEOMETRYTEXTURED means there is one set of texture coordinates, rpGEOMETRYTEXTURED2 means there are two.

If rpGEOMETRYNATIVE is set, the platform dependent geometry data is to be found in the Native Data chunk.