Difference between revisions of "RpGeometry"

From GTAMods Wiki
Jump to navigation Jump to search
(Stream structure: Reverted structure layout that lists format as 16bit and then the two 8bit values for UV sets and native geometry flags. Moved rpGEOMETRYNATIVE information to separate section.)
m
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
+
{{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]]
 +
}}
  
 
'''RpGeometry''' is a [[RenderWare]] structure that stores geometric data.  
 
'''RpGeometry''' is a [[RenderWare]] structure that stores geometric data.  
  
== Stream structure ==
+
== Structure ==
  
{{RW Section|Geometry|0x000F}}
 
  
 
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.
 
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.
Line 11: Line 19:
 
The format of the Geometry's Struct chunk is as follows:
 
The format of the Geometry's Struct chunk is as follows:
  
  int16       format (see [[RpGeometry#Format|below]])
+
  int32       format (see [[RpGeometry#Format|below]])
int8        number of texture coordinate sets (numTexSets)
 
int8        native geometry flags (see [[RpGeometry#Native Geometry|below]])
 
 
  int32        number of triangles (numTriangles)
 
  int32        number of triangles (numTriangles)
 
  int32        number of vertices (numVertices)
 
  int32        number of vertices (numVertices)
Line 24: Line 30:
 
  #endif
 
  #endif
 
   
 
   
  #if nativeGeometry == 0
+
  #if (format & rpGEOMETRYNATIVE) == 0
 
     #if (format & rpGEOMETRYPRELIT)
 
     #if (format & rpGEOMETRYPRELIT)
 
         RwRGBA  prelitcolor[numVertices] (RwRGBA: uint8 r, g, b, a)
 
         RwRGBA  prelitcolor[numVertices] (RwRGBA: uint8 r, g, b, a)
 
     #endif
 
     #endif
 
   
 
   
     #if format & (rpGEOMETRYTEXTURED | rpGEOMETRYTEXTURED2)
+
     #repeat numTexSets (see [[Geometry (RW Section)#Format|below]])
        #repeat numTexSets (see [[Geometry (RW Section)#Format|below]])
+
        RwTexCoords    texCoords[numVertices]  (RwTexCoords: float32 u, v)
            RwTexCoords    texCoords[numVertices]  (RwTexCoords: float32 u, v)
+
    #endrepeat
        #endrepeat
 
    #endif
 
 
      
 
      
 
     RpTriangle  triangles[numTriangles]  (RpTriangle: uint16 vertex2, vertex1, materialId, vertex3)
 
     RpTriangle  triangles[numTriangles]  (RpTriangle: uint16 vertex2, vertex1, materialId, vertex3)
Line 59: Line 63:
 
!Description
 
!Description
 
|-
 
|-
|0x0001||rpGEOMETRYTRISTRIP||Is [[wikipedia:Triangle_strip|triangle strip]] (if disabled it will be an triangle list)
+
|0x00000001||rpGEOMETRYTRISTRIP||Is [[wikipedia:Triangle_strip|triangle strip]] (if disabled it will be an triangle list)
 +
|-
 +
|0x00000002||rpGEOMETRYPOSITIONS||Vertex translation
 
|-
 
|-
|0x0002||rpGEOMETRYPOSITIONS||Vertex translation
+
|0x00000004||rpGEOMETRYTEXTURED||Texture coordinates
 
|-
 
|-
|0x0004||rpGEOMETRYTEXTURED||Texture coordinates
+
|0x00000008||rpGEOMETRYPRELIT||Vertex colors
 
|-
 
|-
|0x0008||rpGEOMETRYPRELIT||Vertex colors
+
|0x00000010||rpGEOMETRYNORMALS||Store normals
 
|-
 
|-
|0x0010||rpGEOMETRYNORMALS||Store normals
+
|0x00000020||rpGEOMETRYLIGHT||Geometry is lit (dynamic and static)
 
|-
 
|-
|0x0020||rpGEOMETRYLIGHT||Geometry is lit (dynamic and static)
+
|0x00000040||rpGEOMETRYMODULATEMATERIALCOLOR||Modulate material color
 
|-
 
|-
|0x0040||rpGEOMETRYMODULATEMATERIALCOLOR||Modulate material color
+
|0x00000080||rpGEOMETRYTEXTURED2||Texture coordinates 2
 
|-
 
|-
|0x0080||rpGEOMETRYTEXTURED2||Texture coordinates 2
+
|0x01000000||rpGEOMETRYNATIVE||Native Geometry
 
|}
 
|}
  
The 8 bits after the format description give the number of texture coordinate sets (numTexSets).
+
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.
 
If the value in the file is zero, rpGEOMETRYTEXTURED means there is one set of texture coordinates, rpGEOMETRYTEXTURED2 means there are two.
  
=== Native Geometry ===
 
 
Native geometry flags can be rpGEOMETRYNATIVE (0x1) or rpGEOMETRYNATIVEINSTANCE (0x2).
 
 
If rpGEOMETRYNATIVE is set, the platform dependent geometry data is to be found in the [[Native Data PLG (RW Section)|Native Data]] chunk.
 
If rpGEOMETRYNATIVE is set, the platform dependent geometry data is to be found in the [[Native Data PLG (RW Section)|Native Data]] chunk.
  
=== Extension ===
+
{{N|SA|VC|3}}
 
 
The [[Extension (RW Section)|extension]] of an geometry can hold the following chunks in GTA:
 
 
 
* [[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]]
 
* [[Breakable (RW Section)|Breakable]]
 
* [[Extra Vert Colour (RW Section)|Extra Vert Colour]]
 
* [[Morph PLG (RW Section)|Morph PLG]]
 
* [[2d Effect (RW Section)|2d Effect]]
 
 
 
{{N|SA|VC}}
 
[[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.