Fandom

Midtown Madness 2 Wiki

PKG File

265pages on
this wiki
Add New Page
Comments0 Share

A PKG File is a geometry file for Midtown Madness 2. It is used in most objects except for such things like roads in cities.


The structure of a PKG file is as follows


PKG 

    char[4]   header = "PKG3"; 
    PKGFile[] files; 


PKGFile 

    char[4]     header = "FILE"; 

    String      name;   // Name of this section 
    long        length; // Length of this PKGFile in bytes 
    PKGFileData data;   // Format depends of name, see below 


String 

    unsigned byte    length;     // Number of bytes in this string including the string terminator. 
    char[length - 1] characters; // ASCII characters 
    char             terminator = '\0'; 

The PKGFileData is different depending on the name of the PKGFile. 


"VL", "L", "M", "H": 

PKGFileData 

    long nSections;    // Number of sections making up this LOD 
    long nVerticesTot; // Total number of vertices in this LOD 
    long nIndiciesTot; // Total number of indicies in this LOD 
    long nSections2;   // Repetition of the number of sections? 
                       // Highly unlikely, but I have no better suggestion at this time 
    long flags;        // Flags defining what components are provided with each vertex, see below 
    PKGSection[nSections] sections; 


PKGSection 

    long nStrips;         // Number of geometry strips in this section 
    long shaderOffset;    // Offset into the shader list of the requested paintjob 
    long verticesPerFace; // Determines if the strips are quads or triangles, have only seen 3 in this field though 
    long nVertices;       // Number of vertices in this section 
    PKGVertex[nVertices]; 
    long nIndices;        // Number of indices making up the geometry strip 
    ushort[nIndices] indices; 


PKGVertex 

    Vertex3D coordinate;         // If flags indicate coordinates 
    Vector3D normal;            // If flags indicate normals 
    Vertex2D textureCoordinate;  // If flags indicate texture coordinates 


Vertex3D 

    float x; 
    float y; 
    float z; 


Vector3D 

    float x; 
    float y; 

    float z; 


Vertex2D 

    float x; 
    float y; 



Description of the bits for the flags field: 

  • Bit 1: Texture coordinates or coordinates 
  • Bit 4: Normals 
  • Bit 8: Coordinates or texture coordinates 

All other bits are unknown at this time. 

"shaders": 

PKGFileData 

    long shaderType; // Bit 7: Shader type 
                     // Bit 0-6: Number of paint jobs 
    long shadersPerPaintJob; 
    PKGShader[Number of paint jobs * shadersPerPaintJob] shaders; 


PKGShader (Type 0) 

    String textureName; 
    Color4f ambient; 
    Color4f diffuse; 
    Color4f specular; 
    Color4f emissive; 
    float shininess; 


PKGShader (Type 1) 

    String textureName; 
    Color4f ambient; 


Color4f 

    float red; 
    float green; 
    float blue; 
    float alpha; 

"offset": 

PKGFileData 
{ 
    Vector3D offset; // Have not tested, but could be an offset added to all vertices in the object 
}      

"xref":  A PKG can reference external objects stored in other PKGs, when rendering a PKG with external references, each object referenced will be rendered too. These objects are possibly breakable, meaning that they can be detached from the main object. 

PKGFileData 
{ 
    long     nReferences; 
    Vector3D xAxis; 
    Vector3D yAxis; 
    Vector3D zAxis; 
    Vector3D origin; 
    char[]   name; 
    char     terminator = 0x00; // Just to end the string 
    char[]   unknown0 = "max"; 
    ushort[] unknown1 = {0, 0, 0, 0, 0, 0, 0}; 
}



A big thanks goes out to fre_ber for the structure information.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.