-
Notifications
You must be signed in to change notification settings - Fork 2
Home
can you review and improve the flow and reability of this wiki document including restructuring the table of contents. then return the chains in plain text markdown
Welcome to the IGI2 Covert Strike MEF (Mesh Exported File) File Format Documentation. This guide provides an in-depth look into the QSC script language used to handle MEF files, detailing both the ASCII and binary formats, as well as the conversion process using the gconv
middleware. Additionally, it covers the structure and components of binary MEF files based on the provided MaxScript.
- Introduction
- Four-Character Codes
- QSC Script Language Overview
- Conversion Process
- Binary MEF File Structure
- Detailed Structure Based on MaxScript
- IRES Image Resource Format
- Example MEF File Parsing
- Additional Resources
The MEF (Mesh Exported File) format in IGI2 Covert Strike is used to store data related to characters, props, and stage models. MEF files come in two variants:
-
ASCII MEF (
.mef
): Human-readable format used for editing and scripting. -
Binary MEF (
.MEF
): Compiled format optimized for in-game use.
The QSC script language facilitates the conversion between these formats, allowing developers to export ASCII scripts to binary MEF files using the gconv
middleware.
This documentation aims to provide a comprehensive understanding of the binary MEF file structure, aiding in the creation, manipulation, and troubleshooting of MEF files for modding or development purposes.
QSC (QScript Compiler) is the scripting language used in IGI2 Covert Strike to define and manipulate MEF files. It enables the export of ASCII representations of MEF data and the subsequent conversion to binary format.
The .mef
commands are used to define and manipulate objects, materials, animations, and other resources within the MEF files. Below is a comprehensive list of commands with their descriptions and input parameters.
Command | Description | Input Parameters |
---|---|---|
NewObject | Creates a new object or entity within the scene or model. |
Object_Name (String)
|
Material | Defines a material with diffuse, specular, ambient, and emission properties. |
Material_ID (Int), Name (String), Diffuse_R (Float), Diffuse_G (Float), Diffuse_B (Float), Specular_R (Float), Specular_G (Float), Specular_B (Float), Ambient_R (Float), Ambient_G (Float), Ambient_B (Float), Emission_R (Float), Emission_G (Float), Emission_B (Float), Transparency_Type (Int)
|
MaterialShininess | Sets the shininess property of a material. |
Material_ID (Int), Shininess (Float)
|
DiffuseTMap | Defines the diffuse texture map for a material. |
Material_ID (Int), Texture_Path (String), Param1 (Int), Param2 (Int)
|
ReflectionTMap | Defines the reflection texture map for a material. |
Material_ID (Int), Texture_Path (String), Param1 (Int), Param2 (Int)
|
BreakScript | Signals the end of a script block or separates different script sections. | None |
Bone | Defines a bone within a skeletal structure. |
Bone_Index (Int), Name (String), Parent_Index (Int), Position_X (Float), Position_Y (Float), Position_Z (Float)
|
BuildHierarchy | Constructs the hierarchical structure of bones based on defined Bone commands. |
None |
Vertex | Defines a vertex in the geometry with its position in 3D space. |
Vertex_Index (Int), Position_X (Float), Position_Y (Float), Position_Z (Float)
|
VertexInfluenceRigid | Defines rigid influence of a vertex on a bone with influence vector and weight for animation. |
Vertex_Index (Int), Bone_ID (Int), Influence_X (Float), Influence_Y (Float), Influence_Z (Float), Weight (Float)
|
Normal | Defines a normal vector for lighting calculations. |
Normal_Index (Int), Vector_X (Float), Vector_Y (Float), Vector_Z (Float)
|
Face | Defines a polygonal face in the geometry with associated normals and material. |
Face_Index (Int), Vertex1 (Int), Vertex2 (Int), Vertex3 (Int), Normal1 (Int), Normal2 (Int), Normal3 (Int), Material_ID (Int)
|
UV | Defines UV mapping coordinates for a face's vertices. |
UV_Index (Int), U1 (Float), V1 (Float), U2 (Float), V2 (Float), U3 (Float), V3 (Float)
|
MagicVertex | Defines special properties or behaviors for a specific vertex, possibly for effects or animations. |
MagicVertex_Index (Int), Parameter1 (Int), Value1 (Float), Value2 (Float), Value3 (Float), Flag (Int)
|
Glow | Defines a glow effect with specified position, intensity, and color. |
Position_X (Float), Position_Y (Float), Position_Z (Float), Intensity (Float), Color_R (Float), Color_G (Float), Color_B (Float)
|
MorphChannel | Defines a morph target channel for animation blending. |
Channel_Index (Int), Channel_Name (String)
|
MorphVertex | Defines the displacement of a vertex in a morph target channel. |
Channel_Index (Int), Vertex_Index (Int), Delta_X (Float), Delta_Y (Float), Delta_Z (Float)
|
AttachObject | Attaches an object or mesh to a bone or a specific location, with transformation matrices. |
Object_Name (String), Attach_Index (Int), Matrix (12 Floats), Position_X (Float), Position_Y (Float), Position_Z (Float)
|
AttachObjectBoneID | Specifies the bone ID to which an object is attached. |
Attach_Index (Int), Bone_ID (Int)
|
SetModelDirectory | Specifies the directory where model files are located. |
Directory_Path (String)
|
SetTextureDirectory | Specifies the directory where texture files are located. |
Directory_Path (String)
|
SetPaletteDirectory | Specifies the directory where palette files are located. |
Directory_Path (String)
|
SetTempDirectory | Specifies the directory for temporary files during the build process. |
Directory_Path (String)
|
SetScale | Sets the scaling factor for models during the build process. |
Scale_Factor (Float)
|
SetTargetPlatform | Defines the target platform for which the models are being built (e.g., PC, Xbox). |
Platform_Name (String)
|
StartTexScript | Begins a texture script block, potentially for managing texture-related operations. |
Script_Name (String)
|
SetLightmapResolution | Sets the resolution for lightmaps used in texture mapping. |
Resolution (Int) or Resolution (Float)
|
CreateCompleteModelRigid | Creates and compiles a rigid model into the resource file. |
Model_File_Name (String)
|
CreateCompleteModelBone | Creates and compiles a bone-animated model into the resource file. |
Model_File_Name (String)
|
CreateCompleteModelLightmap | Creates and compiles a lightmapped model into the resource file. |
Model_File_Name (String)
|
CreateModelBoneNotVirtual | Creates and compiles a bone-animated model that is not virtual (i.e., a base model). |
Model_File_Name (String)
|
CreateVirtualModel | Creates a virtual model based on another model, possibly for variations or LODs. |
Virtual_Model_Name (String), Base_Model_Name (String)
|
CreateShadowVolume | Creates a shadow volume for a model, used in shadow rendering. |
Model_File_Name (String)
|
EndTexScript | Ends a texture script block initiated by StartTexScript . |
None |
BuildStatic | Compiles all specified static models into a resource file, associating them under a given identifier. |
Build_Name (String)
|
SetLightmapResolutionDivider | Sets the divider for lightmap resolution, adjusting the resolution of lightmaps. |
Divider (Int)
|
CreateModelRigidNotVirtual | Creates and compiles a rigid model that is not virtual. |
Model_File_Name (String)
|
SetAnimDirectory | Specifies the directory where animation files are located. |
Directory_Path (String)
|
SetCharParts | Sets character parts for models, possibly defining modular character assembly. |
Parts_List (String)
|
EndAnim | Ends an animation block initiated by BeginAnim . |
None |
Additional QSC commands used for setting directories, scaling, and other configurations are listed below:
Command | Description | Input Parameters |
---|---|---|
SetModelDirectory | Specifies the directory where model files are located. |
Directory_Path (String)
|
SetTextureDirectory | Specifies the directory where texture files are located. |
Directory_Path (String)
|
SetPaletteDirectory | Specifies the directory where palette files are located. |
Directory_Path (String)
|
SetTempDirectory | Specifies the directory for temporary files during the build process. |
Directory_Path (String)
|
SetScale | Sets the scaling factor for models during the build process. |
Scale_Factor (Float)
|
SetTargetPlatform | Defines the target platform for which the models are being built (e.g., PC, Xbox). |
Platform_Name (String)
|
StartTexScript | Begins a texture script block, potentially for managing texture-related operations. |
Script_Name (String)
|
SetLightmapResolution | Sets the resolution for lightmaps used in texture mapping. |
Resolution (Int) or Resolution (Float)
|
CreateCompleteModelRigid | Creates and compiles a rigid model into the resource file. |
Model_File_Name (String)
|
CreateCompleteModelBone | Creates and compiles a bone-animated model into the resource file. |
Model_File_Name (String)
|
CreateCompleteModelLightmap | Creates and compiles a lightmapped model into the resource file. |
Model_File_Name (String)
|
CreateModelBoneNotVirtual | Creates and compiles a bone-animated model that is not virtual (i.e., a base model). |
Model_File_Name (String)
|
CreateVirtualModel | Creates a virtual model based on another model, possibly for variations or LODs. |
Virtual_Model_Name (String), Base_Model_Name (String)
|
CreateShadowVolume | Creates a shadow volume for a model, used in shadow rendering. |
Model_File_Name (String)
|
EndTexScript | Ends a texture script block initiated by StartTexScript . |
None |
BuildStatic | Compiles all specified static models into a resource file, associating them under a given identifier. |
Build_Name (String)
|
SetLightmapResolutionDivider | Sets the divider for lightmap resolution, adjusting the resolution of lightmaps. |
Divider (Int)
|
CreateModelRigidNotVirtual | Creates and compiles a rigid model that is not virtual. |
Model_File_Name (String)
|
SetAnimDirectory | Specifies the directory where animation files are located. |
Directory_Path (String)
|
SetCharParts | Sets character parts for models, possibly defining modular character assembly. |
Parts_List (String)
|
EndAnim | Ends an animation block initiated by BeginAnim . |
None |
The conversion from ASCII MEF scripts to binary MEF files involves the following steps:
-
Write QSC Scripts: Define the MEF content in QSC scripts (
.qsc
files), specifying all necessary properties and structures. -
Export ASCII MEF: Use QSC scripts to export the ASCII representation of MEF files (
.mef
). -
Convert to Binary MEF: Utilize the
gconv
middleware to convert the ASCII.mef
files into binary.MEF
files, which are optimized for in-game usage. -
Integration: Replace or add the binary
.MEF
files to the game's directory to implement the changes.
Option | Description | Default Value |
---|---|---|
-? |
Help. | None |
-all |
Make all files. | None |
`-AutoMipMap=<[ON] | [OFF]>` | Enable/disable automatic mipmap generation for textures. |
`-AutoVQ=<[ON] | [OFF]>` | Enable/disable forced VQ compression. |
-BumpHeight=<0-999> |
Height of bumpmap. | 32 |
`-ConversionMode=<[ARGB1555] | [...]>` | Set default texture format. |
-debug |
Keep temporary files. (For debugging) | None |
-DefaultAlignment=<value> |
Set resource default alignment. | None |
-DefaultSoundConvertMethod=<value> |
Set default sound conversion method (e.g., SOUNDPACKMETHOD_RAW, SOUNDPACKMETHOD_ADPCM). | SOUND_PACKMETHOD_RAW_RESIDENT |
`-Dither=<[ON] | [OFF]>` | Enable/disable dithering. |
-ErrorLevel=[0..3] |
Set converter error level. 0: Ignore all errors, 1: Print all errors, 2: Display error message box, 3: Abort. | None |
`-FontAutoScan=<[ON] | [OFF]>` | Enable/disable font graphics autoscanning. |
-gui |
Start GCONV GUI. | None |
-h |
Help. | None |
`-HalfSize=<[ON] | [OFF]>` | Enable/disable texture reduction. |
-help |
Help. | None |
`-IncludePalette=<[ON] | [OFF]>` | Enable/disable palette inclusion in texture. |
`-IncludeResourceDebug=<[ON] | [OFF]>` | Include resource debug information. |
-InputPath=[path] |
Set input path variable. | None |
-noexec |
Don't execute script. (For debugging) | None |
-none |
Make no files, build resources only. | None |
`-OutputMode=<[Dreamcast] | [...]>` | Set default output platform. |
-OutputPath=[path] |
Set output path variable. | None |
`-ReplaceApostrophes=<[ON] | [OFF]>` | Replace Æ with ' in string resources. |
`-StripResourceDebug=<[ON] | [OFF]>` | Strip resource debug information. |
-TempPath=[path] |
Set temporary path variable. | None |
-TextureScaleFactor=[1..9] |
Set default texture scaling factor. | 5 |
`-Transparency=<[ON] | [OFF]>` | Enable/disable texture transparency. |
-TransparentColour=[colour #] |
Set transparent colour number. | 0 |
`-UpToDateCheck=<[ON] | [OFF]>` | Enable/disable up-to-date check on target files. |
`-UseVQdll=<[ON] | [OFF]>` | Use VQdll for compression instead of PVRconv. |
-Verbosity=[0..5] |
Set converter message level. 0: No messages, 5: All messages. | 2 |
Binary MEF files are structured in a hierarchical manner, consisting of a file header followed by various chunks that encapsulate different aspects of the mesh data.
The file header contains basic information about the MEF file, including its type, size, and content type.
Data Type | Variable | Description |
---|---|---|
uint32 |
file_type |
File identifier (e.g., 'FFLI' which is 0x46464C49 ) |
uint32 |
file_size |
Total file size in bytes |
uint32 |
file_unk1 |
Unknown (typically set to 4 ) |
uint32 |
file_unk2 |
Unknown (typically set to 0 ) |
uint32 |
chunk_type |
Chunk identifier (e.g., 'MECO' which is 0x4D45434F ) |
void*[] |
chunks |
Array of content chunks |
- file_type: Identifies the file format.
- file_size: The total size of the MEF file in bytes.
- file_unk1 & file_unk2: Unknown fields, typically set to specific default values.
- chunk_type: Specifies the type of content contained within the file.
- chunks: An array holding various content chunks that define different aspects of the mesh.
Data Type | Variable | Description |
---|---|---|
uint32 |
type |
Type of the chunk (e.g., 0x4D455348 for MESH) |
uint32 |
data |
Size of data following this chunk |
uint32 |
flag |
Always 4
|
uint32 |
size |
Size of the chunk |
Here are the four-character codes for each chunk type used in the Binary MEF format:
Four-Character Code | Code (Hex) | Integer Value | Description |
---|---|---|---|
MESH |
0x4D455348 |
1296388936 | Main mesh data |
ATTA |
0x41545441 |
1096045633 | Attachments |
MVTX |
0x4D565458 |
1297503320 | Magic Vertexes |
RD3D |
0x52443344 |
1380201284 | Render 3D |
FACE |
0x46414345 |
1178682181 | Faces |
VRTX |
0x56525458 |
1448236120 | Vertexes |
CVTX |
0x43565458 |
1129731160 | Collision Vertexes |
CFCE |
0x43464345 |
1128678213 | Collision Faces |
CMAT |
0x434D4154 |
1129136468 | Collision Material |
CSPH |
0x43535048 |
1129533512 | Collision Sphere |
HIER |
0x48494552 |
1212761426 | Hierarchy Information |
BNAM |
0x424E414D |
1112424781 | Bone Name |
GLOW |
0x474C4F57 |
1196183383 | Lights |
PORT |
0x504F5254 |
1347375700 | Portals |
PTVX |
0x50545658 |
1347704408 | Portal Vertexes |
PTFC |
0x50544643 |
1347700291 | Portal Faces |
LTMP |
0x4C544D50 |
1280593232 | Lightmap |
MRPH |
0x4D525048 |
1297240136 | Morph data |
SVTX |
0x53565458 |
1398166616 | Shadow Vertex |
SFAC |
0x53464143 |
1397113155 | Shadow Face |
EDGE |
0x45444745 |
1162102597 | Edges |
Chunks are modular sections within the MEF file, each representing different data components such as mesh data, textures, materials, etc. Each chunk starts with a 16-byte header followed by its specific data.
Defines the primary mesh data, including vertices, faces, and other mesh-related information.
Data Type | Variable | Description |
---|---|---|
float |
unk01 |
Unknown field |
MecoDateStamp_t |
date |
Datestamp and timestamp (28 bytes) |
uint32 |
model_type |
Indicates the type of model (e.g., character, prop, stage) |
uint32 |
unk10 |
Unknown field |
uint32 |
unk11 |
Unknown field |
uint32 |
unk12 |
Unknown field |
MecoMeshSphere_t[] |
unk16 |
Array of 3 mesh spheres |
uint32 |
num_r_faces |
Number of render faces |
uint32 |
num_r_verts |
Number of render vertices |
uint32 |
num_r_buffer |
Number of render buffers |
uint32 |
sum_c_faces |
Cumulative face count |
uint32 |
sum_c_verts |
Cumulative vertex count |
uint32 |
sum_c_buffer |
Cumulative buffer count |
float |
model_radius |
Radius of the model for collision detection |
uint16 |
num_mverts |
Number of morph vertices |
uint16 |
num_attach |
Number of attachments |
uint16 |
num_pverts |
Number of portal vertices |
uint16 |
num_pfaces |
Number of portal faces |
uint16 |
num_portals |
Number of portals |
uint16 |
num_bones |
Number of bones in the skeleton |
uint16 |
num_glows |
Number of glow effects |
uint16[19] |
reserve |
Reserved fields for future use or padding |
Represents attachments related to the mesh, such as weapons, equipment, or other linked objects.
Data Type | Variable | Description |
---|---|---|
char[16] |
name |
Name of the attachment |
float[12] |
unk42 |
Unknown fields |
uint32 |
unk43 |
Unknown field |
int32 |
bone_index |
Index of the bone to attach to |
Stores morph vertex data, used for mesh morphing and animations.
Data Type | Variable | Description |
---|---|---|
float[4] |
x, y, z, w |
Morph target coordinates |
Contains render-related data for the mesh.
Data Type | Variable | Description |
---|---|---|
uint32 |
flag |
Rendering flags |
uint32 |
num_faces |
Number of faces |
uint32 |
num_meshes |
Number of meshes |
uint32 |
num_vertices |
Number of vertices |
uint32[5] |
reserved_type0 |
Reserved fields for size 36 bytes (model_type 0) |
uint32 |
verts_0 |
Verts for size 40 bytes (model_type 1) |
uint32 |
verts_1 |
Verts for size 40 bytes (model_type 1) |
uint32 |
num_vertices_extra |
Additional vertex count for model_type 1 |
uint32[4] |
reserved_type1 |
Reserved fields for size 40 bytes (model_type 1) |
uint32 |
num_lightmaps |
Number of lightmaps for model_type 3 |
uint32[6] |
reserved_type3 |
Reserved fields for size 44 bytes (model_type 3) |
uint32[] |
reserved_extra |
Reserved fields for unknown sizes |
Defines the bone hierarchy for skeletal animations.
Data Type | Variable | Description |
---|---|---|
uint8[] |
num_children |
Number of child bones for each bone |
float[3][] |
position |
Position of each bone in the hierarchy |
Stores bone names.
Data Type | Variable | Description |
---|---|---|
char[16][] |
names |
Array of bone names (16 chars) |
Defines the face indices of the mesh.
Data Type | Variable | Description |
---|---|---|
uint16[] |
face |
Each face consists of three vertex indices |
Holds rendering data for materials and submeshes.
Data Type | Variable | Description |
---|---|---|
uint8 |
opacity |
Opacity of the material |
uint8 |
material_shininess |
Shininess property of the material |
uint8 |
diffuse_color |
Diffuse color of the material |
uint8 |
opacity_detail |
Opacity detail of the material |
float[3] |
position |
Position coordinates |
uint16 |
face_pos |
Position index of faces |
uint16 |
face_count |
Number of faces |
uint16 |
vertex_pos |
Position index of vertices |
uint16 |
vertex_count |
Number of vertices |
int16 |
texture_diffuse_index |
Index of the diffuse texture |
int16 |
texture_bump_index |
Index of the bump texture (DTYPE_DNER_0_and_1) |
int16 |
texture_reflection_index |
Index of the reflection texture (DTYPE_DNER_0_and_1) |
uint8 |
texture_reflection_detail |
Reflection detail (DTYPE_DNER_0_and_1) |
uint8 |
texture_bump_detail |
Bump detail (DTYPE_DNER_0_and_1) |
int16 |
lightmap_index |
Lightmap index (DTYPE_DNER_3) |
uint32[] |
reserved_extra |
Reserved extra data |
Contains vertex data for the mesh.
Data Type | Variable | Description |
---|---|---|
float[3] |
position |
Vertex position coordinates |
float[2] |
texcoord0 |
Primary texture coordinates |
float[3] |
normal |
Normal vectors (optional based on model type) |
float |
weight |
Weight for vertex influence (optional) |
float[2] |
texcoord1 |
Secondary texture coordinates (optional) |
uint16 |
vertex_index |
Vertex normal index |
uint16 |
bone_index |
Bone index influencing this vertex |
Represents collision vertices used for physics calculations.
Data Type | Variable | Description |
---|---|---|
float[3] |
position |
Position of the collision vertex |
uint32 |
bone_index |
Bone index for collision binding |
uint32 |
unk78 |
Unknown field |
Defines collision faces for physics interactions.
Data Type | Variable | Description |
---|---|---|
uint16[3] |
face |
Indices of the vertices forming the face |
int16 |
material_index |
Index of the material used for collision |
int16 |
unk80 |
Unknown field |
int16 |
unk81 |
Unknown field |
Stores collision material properties.
Data Type | Variable | Description |
---|---|---|
uint32 |
unk48 |
Unknown field |
uint16 |
unk49 |
Unknown field |
uint16 |
unk50 |
Unknown field |
uint32 |
unk51 |
Unknown field |
uint32 |
unk52 |
Unknown field |
Defines collision spheres used for bounding and collision detection.
Data Type | Variable | Description |
---|---|---|
float[3] |
position |
Center position of the collision sphere |
float |
radius |
Radius of the collision sphere |
uint16 |
unk72 |
Unknown field |
uint16 |
unk73 |
Unknown field |
uint16 |
unk74 |
Unknown field |
uint16 |
unk75 |
Unknown field |
Contains morph target data for animations.
Data Type | Variable | Description |
---|---|---|
uint32 |
index |
Index of the morph target |
float[3] |
delta |
Delta values for vertex positions |
Represents collision mesh data.
Data Type | Variable | Description |
---|---|---|
uint32 |
num_faces |
Number of collision faces |
uint32 |
num_vertices |
Number of collision vertices |
uint32 |
num_materials |
Number of collision materials |
uint32 |
num_spheres |
Number of collision spheres |
uint32[] |
reserved |
Reserved fields for future use or padding |
Stores collision material properties.
Data Type | Variable | Description |
---|---|---|
uint32 |
unk48 |
Unknown field |
uint16 |
unk49 |
Unknown field |
uint16 |
unk50 |
Unknown field |
uint32 |
unk51 |
Unknown field |
uint32 |
unk52 |
Unknown field |
Defines collision spheres used for bounding and collision detection.
Data Type | Variable | Description |
---|---|---|
float[3] |
position |
Center position of the collision sphere |
float |
radius |
Radius of the collision sphere |
uint16 |
unk72 |
Unknown field |
uint16 |
unk73 |
Unknown field |
uint16 |
unk74 |
Unknown field |
uint16 |
unk75 |
Unknown field |
Contains morph target data for animations.
Data Type | Variable | Description |
---|---|---|
uint32 |
index |
Index of the morph target |
float[3] |
delta |
Delta values for vertex positions |
Represents collision mesh data.
Data Type | Variable | Description |
---|---|---|
uint32 |
num_faces |
Number of collision faces |
uint32 |
num_vertices |
Number of collision vertices |
uint32 |
num_materials |
Number of collision materials |
uint32 |
num_spheres |
Number of collision spheres |
uint32[] |
reserved |
Reserved fields for future use or padding |
The Binary MEF file format is designed to efficiently store mesh data along with related assets such as materials and animations. Each chunk type serves a specific purpose, allowing for organized access to the data needed for rendering and interaction in the game engine.
The structured format ensures that developers can parse and utilize the data effectively, whether it involves importing models into a 3D environment, implementing animations, or setting up collision detection. By understanding the layout and contents of the Binary MEF, developers can create custom tools or scripts to manipulate and optimize the models for use within the game, enhancing performance and visual fidelity.
The .res
file begins with a header providing basic information about the file. The table below details the structure of the header.
Offset (bytes) | Data Type | Variable | Description |
---|---|---|---|
0 | uint32_t |
magic |
Magic number 0x46464C49 ('ILFF'), identifying the "Inner Loop File Format" |
4 | uint32_t |
filesize |
Total file size in bytes, excluding the 4-byte magic field |
8 | uint32_t |
alignment |
Alignment value, typically 4 bytes (default: 4) |
12 | uint32_t |
reserved |
Reserved for future use, usually 0
|
16 | uint32_t |
res_type |
Resource type identifier 0x53455249 ('IRES'), indicating an image resource |
After the header, the .res
file contains multiple chunks. Each chunk has a standard structure followed by a variable-length buffer containing the chunk data.
Offset (bytes) | Data Type | Variable | Description |
---|---|---|---|
0 | uint32_t |
type |
Type identifier of the chunk (e.g., 'NAME', 'BODY') |
4 | uint32_t |
buffer_size |
Size of the buffer containing the chunk data (in bytes) |
8 | uint32_t |
alignment |
Alignment value, usually 4 bytes (default: 4) |
12 | uint32_t |
chunk_size |
Size of the chunk data (in bytes); not always used for skipping |
16 | uint8_t[] |
buffer |
Chunk data buffer, of size buffer_size
|
To properly skip a chunk, use the formula: (buffer_size + 16)
aligned by the alignment
value.
The NAME
chunk contains a null-terminated string representing the name or path of the resource.
Offset (bytes) | Data Type | Variable | Description |
---|---|---|---|
0 | char[] |
name |
Null-terminated string specifying the resource's name or file path |
The BODY
chunk contains image data and metadata. The exact image data format is determined by the metadata fields within the chunk.
Offset (bytes) | Data Type | Variable | Description |
---|---|---|---|
0 | uint32_t |
type |
Image type identifier, typically 0x504F4F4C ('LOOP') |
4 | uint32_t |
unk1 |
Unknown field (possibly image format/type information) |
8 | uint32_t |
unk2 |
Unknown field, often observed as 67
|
12 | uint32_t |
unk3 |
Unknown field, usually 0
|
16 | uint32_t |
unk4 |
Unknown field, usually 0
|
20 | uint16_t |
mip_count |
Number of mip levels (often 5 ) |
22 | uint16_t |
width_1 |
First width field of the image (in pixels) |
24 | uint16_t |
height_1 |
First height field of the image (in pixels) |
26 | uint16_t |
width_2 |
Second width field of the image (in pixels) |
28 | uint16_t |
height_2 |
Second height field of the image (in pixels) |
30 | uint16_t |
unk5 |
Unknown field, often observed as 4
|
32 | uint8_t[] |
image_data |
Raw image data; typically in 32-bit per pixel format (BGRA, 8 bits each) |
-
Skipping Chunks: To skip over a chunk, use
(buffer_size + 16)
, then align to the next boundary according to thealignment
. -
Image Data: The image data in the
BODY
chunk typically uses a 32-bit BGRA format. The dimensions are usually determined bywidth_1
andheight_1
. -
Unknown Fields: Some fields in the
BODY
chunk, such asunk1
,unk2
,unk3
,unk4
, andunk5
, may require further investigation to fully understand their meaning.
For more detailed information regarding the specific structures and implementations related to the Binary MEF file format, consider referring to the following resources:
This concludes the documentation on the Binary MEF file structure. Feel free to reach out for further clarification or additional details on specific sections!