# .msh Format

## Overview

This page lists all .MSH file chunks. In the .MSH file these chunks are organized in a hierarchy with HEDR (header) being the first chunk and branching out from there (as visualized in the sidebar navigation).

Some of these chunks are exclusive to certain versions of the engine (Star Wars: The Clone Wars and before, Star Wars: Battlefront and Star Wars: Battlefront II) or deprecated completely. Most notably Cloth Simulation (CLTH and children) being limited to Star Wars: Battlefront II.

## Chunk Hierarchy

HEDR
SHVO
MSH2
SINF
NAME FRAM BBOX
CAMR
NAME DATA
MATL
MATD
NAME MATD.DATA ATRB TX0D
MODL
NAME
MTYP
MNDX
PRNT
FLGS
TRAN
GEOM
BBOX
SEGM
SHDW
MATI
POSL
CLRL
CLRB
WGHT
NRML
UV0L
NDXL
NDXT
STRP
NAME FRAM BBOX
CLTH
CTEX CPOS CUV0 FIDX FWGT CMSH SPRS CPRS BPRS COLL
ENVL
SWCI
BLN2
SKL2
ANM2
CYCL KFR3
CL1L

## ExampleChunk

This is an example chunk.

Parent | Children | Appearance
--- | --- | ---
PARENT CHUNK | ALL POSSIBLE CHILDREN | Number of appearances or if it's optional.

See also: A list of links for further reading.

Structure
Data Type | Size | Description
--- | --- | ---
byte[4] | 4 | Header/chunk name. Every chunk has this.
long int | 4 | Length indicator. Stores the length in bytes excluding the header and the size indicator. Every chunk has this indicator.
| ~ | The rest of the data.

## HEDR

.msh file header.

Parent | Children | Appearance
--- | --- | ---
- | SHVO MSH2 BLN2 SKL2 ANM2 CL1L | Once.

## SHVO

Indicates a shadow volume.

Parent | Children | Appearance
--- | --- | ---
HEDR |  | Optional.

Structure
Data Type | Size | Description
--- | --- | ---
long int | 4 | 0 or 1 (if .msh has a shadow volume).

## MSH2

.msh file mesh header.

Parent | Children | Appearance
--- | --- | ---
HEDR | SINF CAMR MATL MODL | Once

## FINF

Possibly deprecated. File information. PROJ: project name. USER: user name. TIME: time.

Parent | Children | Appearance
--- | --- | ---
MSH2 | PROJ USER TIME | Once.

Structure
Data Type | Size | Description
--- | --- | ---
ASCII string | 4 * X | File information.

## SINF

Scene information header.

Parent | Children | Appearance
--- | --- | ---
MSH2 | NAME FRAM BBOX | Optional.

## FRAM

Scene frame information.

Parent | Children | Appearance
--- | --- | ---
SINF |  | Optional.

Structure
Data Type | Size | Description
--- | --- | ---
long int | 4 | Start of frame range.
long int | 4 | End of frame range.
float | 4 | Frames per second (usually ~30).

## CAMR

Scene camera header.

Parent | Children | Appearance
--- | --- | ---
MSH2 | NAME DATA | Optional.

## MATL (Materials)

Material list header.

Parent | Children | Appearance
--- | --- | ---
MSH2 | MATD | Once.

Structure
Data Type | Size | Description
--- | --- | ---
long int | 4 | Count of materials (MATD) in this list.

## MATD (Material)

Material header.

Parent | Children | Appearance
--- | --- | ---
MATL | NAME MATD.DATA ATRB TX0D | One or more.

## MATD.DATA

Material colors and specular sharpness (gloss). Colors are stored in 0-1 range.

Parent | Children | Appearance
--- | --- | ---
MATD |  | Once.

Structure
Data Type | Size | Description
--- | --- | ---
float [4] | 16 | Diffuse RGBA color.
float [4] | 16 | Specular RGBA color.
float [4] | 16 | Ambient RGBA color.
float | 4 | Specular sharpness (gloss).

## ATRB

Material flags (glow and other special rendertypes).

Parent | Children | Appearance
--- | --- | ---
MATD |  | Once.

See also: ZeroEngine Render Types , Inside Edit Flags (GT) , GameToast ATRB discussion , Flag Calculator

Structure
Data Type | Size | Description
--- | --- | ---
byte | 1 | Sum of all flag values.
byte | 1 | Render Type number.
byte | 1 | Data0 Value. Range: 0-255
byte | 1 | Data1 Value. Range: 0-255

## TX0D

Texture name with extension (not full path). For multiple textures the name of the chunk will change to TX1D, TX2D, TX3D.

Parent | Children | Appearance
--- | --- | ---
MATD |  | Optional.

Structure
Data Type | Size | Description
--- | --- | ---
ASCII string | ~ | Texture name.

## PRFX

Possibly deprecated. Material prefix.

Parent | Children | Appearance
--- | --- | ---
MATD |  | Once.

Structure
Data Type | Size | Description
--- | --- | ---
ASCII string | 4 * X | Prefix.

## MODL (Model)

Model header.

Parent | Children | Appearance
--- | --- | ---
MSH2 | NAME MTYP MNDX PRNT FLGS TRAN GEOM SWCI | One or more.

## MTYP

Model type.

Parent | Children | Appearance
--- | --- | ---
MODL |  | Once.

Structure
Data Type | Size | Description
--- | --- | ---
long int | 4 | Model type.

## MNDX

0-based Model index.

Parent | Children | Appearance
--- | --- | ---
MODL |  | Once.

Structure
Data Type | Size | Description
--- | --- | ---
long int | 4 | Model index.

## PRNT

Name of the parent model, padded with 00's to fill up to a multiple-of-4 size.

Parent | Children | Appearance
--- | --- | ---
MODL |  | Optional.

Structure
Data Type | Size | Description
--- | --- | ---
ASCII string | ~ | Parent model name.

## FLGS

Model display flags.

Parent | Children | Appearance
--- | --- | ---
MODL |  | Once.

Structure
Data Type | Size | Description
--- | --- | ---
long int | 4 | Render Flags.

## TRAN

Matrix transform. Scale can get ignored in-game.

Parent | Children | Appearance
--- | --- | ---
MODL |  | Once.

Structure
Data Type | Size | Description
--- | --- | ---
float [3] | 12 | Scale factor in XYZ.
float [4] | 16 | Quaternion Rotation in XYZW.
float [3] | 12 | Translation in XYZ.

## SWCI

Collision primitive.

Parent | Children | Appearance
--- | --- | ---
MODL |  | Optional.

Structure
Data Type | Size | Description
--- | --- | ---
long int | 4 | Primitive type (0: sphere, 1: sphere, 2: cylinder, 4: cube).
float | 4 | Data (sphere: radius, cylinder: radius, cube: x_length.
float | 4 | Data (sphere: -, cylinder: height, cube: y_length.
float | 4 | Data (sphere: -, cylinder: -, cube: z_length.

## GEOM (Geometry)

Geometry header. Will be used for static/dynamic geometry and shadow volumes.

Parent | Children | Appearance
--- | --- | ---
MODL | BBOX SEGM CLTH ENVL | Optional (depends on model type).

## ENVL (Envelope)

List of indices into MODL. This model is enveloped to those indices' models.

Parent | Children | Appearance
--- | --- | ---
GEOM |  | Optional.

Structure
Data Type | Size | Description
--- | --- | ---
long int | 4 | Number of indices into MODL.
long int [] | 4 each | Index into MODL.

## SEGM

Geometry segment header.

Parent | Children | Appearance
--- | --- | ---
GEOM | SHDW MATI POSL CLRL CLRB WGHT NRML UV0L NDXL NDXT STRP | One or more.

## SHDW

Shadow mesh geometry.

Parent | Children | Appearance
--- | --- | ---
SEGM |  | If the model is a shadow mesh, once.

Structure
Data Type | Size | Description
--- | --- | ---
long int | 4 | Number of vertex positions.
float [3][] | 12 each | Vertex positions (XYZ).
long int | 4 | Number of edges.
short int [4][] | 8 each | Edge. The following 4 entries form one edge.
> short int | 2 | Vertex index of this edge entry. Refers to the vertex list above.
> short int | 2 | Reference into an edge. Defines the target vertex (the local edge vertex of the referenced edge) to which the edge should be dran from the local vertex.
> short int | 2 | Second reference into an edge. In all example .msh files I've seen this always refers to the same vertex as the first edge reference.
> short int | 2 | MAX_VALUE of short integers (65535). Indicates the end of this edge.

## MATI

Material index (index into MATL).

Parent | Children | Appearance
--- | --- | ---
SEGM |  | Once?

Structure
Data Type | Size | Description
--- | --- | ---
long int | 4 | Material index.

## POSL

List of vertex coordinates.

Parent | Children | Appearance
--- | --- | ---
SEGM |  | Once (unless shadow mesh).

Structure
Data Type | Size | Description
--- | --- | ---
long int | 4 | Number of coordinates stored in this list.
float [3][] | 12 each | XYZ coordinates for each vertex.

## NRML

List of normals.

Parent | Children | Appearance
--- | --- | ---
SEGM |  | Once (unless shadow mesh).

Structure
Data Type | Size | Description
--- | --- | ---
long int | 4 | Number of normal vectors stored in this list.
float [3][] | 12 each | UVW vector for each vertex.

## UV0L

List of UV coordinates.

Parent | Children | Appearance
--- | --- | ---
SEGM |  | Optional.

Structure
Data Type | Size | Description
--- | --- | ---
long int | 4 | Number of UV coordinates stored in this list.
float [2][] | 8 each | UV coordinate for each vertex.

## CLRL

List of vertex colors.

Parent | Children | Appearance
--- | --- | ---
SEGM |  | Optional.

Structure
Data Type | Size | Description
--- | --- | ---
long int | 4 | Number of colors stored in this list.
byte [4][] | 4 each | RGBA color (0-255).

## CLRB

One vertex color for the whole segment.

Parent | Children | Appearance
--- | --- | ---
SEGM |  | Optional.

Structure
Data Type | Size | Description
--- | --- | ---
byte [4] | 4 | RGBA color (0-255).

## WGHT

List of bone-weight percentage pairs. Always 4 pairs per vertex.

Parent | Children | Appearance
--- | --- | ---
SEGM |  | Optional.

Structure
Data Type | Size | Description
--- | --- | ---
long int | 4 | Number of bone weights stored in this list.
|  | The following appears 4 times per vertex (to allow for soft weighting).
long int | 4 | Index into ENVL (which then indexes into MODL).
float | 4 | Weight value (0-1).

## NDXL

Polygons.

Parent | Children | Appearance
--- | --- | ---
SEGM |  | Optional/deprecated.

## NDXT

Triangles.

Parent | Children | Appearance
--- | --- | ---
SEGM |  | Optional/deprecated.

## STRP

List of triangles strips. The start of a strip is indicated by 2 entries with a high bit set (0x8000 or 32768 added). Triangles are listed CW, CCW, CW, CCW...

NOTE: In some meshes this chunk has a trailing short which is not calculated into the length/size of this chunk or the # of indices. This short can be ignored. If added to the last polygon it will break it as it always seems to be 0.

Parent | Children | Appearance
--- | --- | ---
SEGM | NAME FRAM BBOX | Once (unless shadow mesh).

Structure
Data Type | Size | Description
--- | --- | ---
long int | 4 | Number of indices into POSL.
short int [] | 2 each | Index into POSL. The indices will form polygons.

## VLTB

Possibly deprecated. Baked vertex light.

Parent | Children | Appearance
--- | --- | ---
SEGM |  | Optional.

Structure
Data Type | Size | Description
--- | --- | ---
byte | 1 | Red.
byte | 1 | Green.
byte | 1 | Blue.
byte | 1 | Alpha.

## VLTL

Possibly deprecated. Unique baked vertex lights for vertices.

Parent | Children | Appearance
--- | --- | ---
SEGM |  | Optional.

Structure
Data Type | Size | Description
--- | --- | ---
long int | 4 | Number of colors to come.
byte | 1 | Red.
byte | 1 | Green.
byte | 1 | Blue.
byte | 1 | Alpha.

## CLTH (Cloth)

Cloth header. Replaces SEGM.

Parent | Children | Appearance
--- | --- | ---
GEOM | CTEX CPOS CUV0 FIDX FWGT CMSH SPRS CPRS BPRS COLL | Optional.

## CTEX

Texture name with extension.

Parent | Children | Appearance
--- | --- | ---
CLTH |  | Once.

Structure
Data Type | Size | Description
--- | --- | ---
ASCII string | ~ | Texture name.

## CPOS

List of vertex coordinates.

Parent | Children | Appearance
--- | --- | ---
CLTH |  | Once.

Structure
Data Type | Size | Description
--- | --- | ---
long int | 4 | Number of vertex positions.
float [3][] | 12 each | XYZ coordinates.

## CUV0

List of UV coordinates.

Parent | Children | Appearance
--- | --- | ---
CLTH |  | Optional?

Structure
Data Type | Size | Description
--- | --- | ---
long int | 4 | Number of UV coordinates.
float [2][] | 8 each | UV coordinate.

## FIDX

List of fixed points.

Parent | Children | Appearance
--- | --- | ---
CLTH |  | Optional?

Structure
Data Type | Size | Description
--- | --- | ---
long int | 4 | Number of points.
long int ] | 4 each | Index into CPOS.

## FWGT

Index of FIDX weighted to a bone by name.

Parent | Children | Appearance
--- | --- | ---
CLTH |  | Optional?

Structure
Data Type | Size | Description
--- | --- | ---
long int | 4 | Number of points.
ASCII string | ~ | Name of the bone the corresponding FIDX is moving with.

## CMSH

Cloth triangles.

Parent | Children | Appearance
--- | --- | ---
CLTH |  | Once.

Structure
Data Type | Size | Description
--- | --- | ---
long int | 4 | Number of points.
long int [3][] | 16 each | Triangle points defined CCW.

## SPRS

Stretch constraint data. Keeps cloth size by storing relations between points (like edges around a quad). Relations between two fixed points are not stored

Parent | Children | Appearance
--- | --- | ---
CLTH |  | Optional?

See also: Constraint discussion (GT)

Structure
Data Type | Size | Description
--- | --- | ---
long int | 4 | Number of items.
short int [2][] | 4 each | Two points sharing an edge.

## CPRS

Cross constraint data. Keeps individual pieces of the cloth from shearing (cross relations between points). Think of the edges as sticky tape, glueing the points together. Relations between two fixed points are not stored

Parent | Children | Appearance
--- | --- | ---
CLTH |  | Optional?

See also: Constraint discussion (GT)

Structure
Data Type | Size | Description
--- | --- | ---
long int | 4 | Number of items.
short int [2][] | 4 each | Two points sharing a quad.

## BPRS

Bend constraint data. Keeps the cloth's shape (relations between border-points of the cloth mesh, disables bending along those edges). Relations between two fixed points are not stored

Parent | Children | Appearance
--- | --- | ---
CLTH |  | Optional?

See also: Constraint discussion (GT)

Structure
Data Type | Size | Description
--- | --- | ---
long int | 4 | Number of items.
short int [2][] | 4 each | Two border-points sharing a 'straight' edge over the complete cloth.

## COLL

Cloth collision. Note that this chunk is padded with 00's until it has a multiple of 4 chunk size.

Parent | Children | Appearance
--- | --- | ---
CLTH |  | Optional?

Structure
Data Type | Size | Description
--- | --- | ---
long int | 4 | Number of collisions.
ASCII string | ~ | Collision object name.
ASCII string | ~ | Object name this collision moves with.
long int | 4 | Primitive type (0: sphere, 1: cylinder, 2: cube).
float | 4 | Data (sphere: radius, cylinder: radius, cube: x_length / 2).
float | 4 | Data (sphere: radius, cylinder: height, cube: y_length / 2).
float | 4 | Data (sphere: radius, cylinder: -, cube: z_length / 2).

## SKL2 (Skeleton)

Skeleton/chain. Lists some bone properties for every item in the chain. The values don't seem to make a big difference.

Parent | Children | Appearance
--- | --- | ---
HEDR |  | Optional.

Structure
Data Type | Size | Description
--- | --- | ---
long int | 4 | Number of bones in this skeleton.
CRC checksum | 4 | CRC checksum of the bone.
long int | 4 | Type (bone?). Usual value: 0.
float | 4 | Constrain. Usual value: -1 or 1.
float | 4 | Bone length 1. Usual value: 0.
float | 4 | Bone length 2. Usual value: 0.

## BLN2

Blend factors for the chain items (bones). Purpose unknown. Blend factor usually is 0/nothing (if float).

Parent | Children | Appearance
--- | --- | ---
HEDR |  | Optional.

Structure
Data Type | Size | Description
--- | --- | ---
long int | 4 | Number of bones.
CRC checksum | 4 | CRC checksum of the bone.
? | 4 | Blend factor. Usual value: 0.

## ANM2 (Animation)

Animation header.

Parent | Children | Appearance
--- | --- | ---
HEDR | CYCL KFR3 | Optional.

## CYCL

Animation cycles. Can contain multiple animations.

Parent | Children | Appearance
--- | --- | ---
ANM2 |  | Once.

Structure
Data Type | Size | Description
--- | --- | ---
long int | 4 | Number of animations.
|  | The following can appear multiple times.
ASCII string | 64 | Aimation name.
float | 4 | Frame rate.
long int | 4 | Play Style.
long int | 4 | First frame.
long int | 4 | Last frame.

## KFR3

All the frames and their local translation and rotation. Frame indices don't have to be consecutive. They can skip frames (like keyframes).

Parent | Children | Appearance
--- | --- | ---
ANM2 |  | Once.

Structure
Data Type | Size | Description
--- | --- | ---
long int | 4 | Number of bones in this animation.
|  | The following will appear once per chain item.
> CRC checksum | 4 | CRC checksum.
> long int | 4 | Keyframe type.
> long int | 4 | Number of translation frames.
> long int | 4 | Number of rotation frames.
|  | Translation frames will be listed first.
>> long int | 4 | Translation frame index.
>> float [3][] | 12 | Translation in XYZ.
|  | Rotation frames will be listed second.
>> long int | 4 | Rotation frame index.
>> float [4][] | 16 | Quaternion rotation in XYZW.

## CL1L

Closing chunk, indicates the end of the .msh file.

Parent | Children | Appearance
--- | --- | ---
- |  | Once.

## NAME

Name, padded with 00's to fill up a multiple-of-4 size.

Parent | Children | Appearance
--- | --- | ---
- |  | Once.

Structure
Data Type | Size | Description
--- | --- | ---
ASCII string | 4 * X | Name.

## BBOX

Bounding box. SINF's BBox will determine the blue/green selection box in ZeroEdit.

Parent | Children | Appearance
--- | --- | ---
- |  | Once.

Structure
Data Type | Size | Description
--- | --- | ---
float [4] | 16 | Quaternion Rotation in XYZW.
float [3] | 12 | Center of the BBox.
float [3] | 12 | Extents of the BBox (width/2, height/2, depth/2).
float | 4 | Bounding sphere radius.

## LGTP

Possibly deprecated. Point Light.

Parent | Children | Appearance
--- | --- | ---
- | PRFX NAME DATA | Optional.

Structure
Data Type | Size | Description
--- | --- | ---
float | 4 | Red.
float | 4 | Green.
float | 4 | Blue.
float | 4 | Alpha.
float | 4 | X.
float | 4 | Y.
float | 4 | Z.
float | 4 | Falloff start.
float | 4 | Falloff end.
long int | 4 | Flags (1: CastShadows).

## LGTI

Possibly deprecated. Infinite Light.

Parent | Children | Appearance
--- | --- | ---
- | PRFX NAME DATA | Optional.

Structure
Data Type | Size | Description
--- | --- | ---
float | 4 | Red.
float | 4 | Green.
float | 4 | Blue.
float | 4 | Alpha.
float | 4 | X.
float | 4 | Y.
float | 4 | Z.
float | 4 | Falloff start.
float | 4 | Falloff end.
long int | 4 | Flags (1: CastShadows).

## LGTS

Possibly deprecated. Spot Light.

Parent | Children | Appearance
--- | --- | ---
- | PRFX NAME DATA | Optional.

Structure
Data Type | Size | Description
--- | --- | ---
float | 4 | Red.
float | 4 | Green.
float | 4 | Blue.
float | 4 | Alpha.
float | 4 | X.
float | 4 | Y.
float | 4 | Z.
float | 4 | Interest X.
float | 4 | Interest Y.
float | 4 | Interest Z.
float | 4 | Falloff start.
float | 4 | Falloff end.
float | 4 | Cone Angle.
float | 4 | Spread Angle.
long int | 4 | Flags (1: CastShadows).

## FOGD

Possibly deprecated. Fog data.

Parent | Children | Appearance
--- | --- | ---
- |  | Optional.

Structure
Data Type | Size | Description
--- | --- | ---
float | 4 | Red.
float | 4 | Green.
float | 4 | Blue.
float | 4 | Alpha.
float | 4 | Near plane.
float | 4 | Far plane.