P3M

Table of contents


Format

  • Current version is 0.0
  • File extension is .p3m
  • Data is little endian
TypeDescription
HeaderFile header
DataModel data

TypeValueDescription
char[3]{'P', '3', 'M'}Header magic
u80Major version
u8Header flagsFlags
Header flags
Bits (MSB to LSB)ValueDescription
7..00Reserved

Data

TypeValueDescription
u8Part count
u8[0..32]Part visibility bitmask (Bytes ordered from least to most significant)
Part × “Part count”Parts
u8Material count
Material × “Material count”Materials
u8Texture count
Texture × “Texture count”Textures
u8Bone count
Bone × “Bone count”Bones
u8Animation count
Animation × “Animation count”Animations
u8Action count
Action × “Action count”Actions
char[1...]{..., 0}String table

Part

TypeValueDescription
u8Part flagsFlags
StringPart name
u8Material index
u16Vertex count
Vertex × “Vertex count”Vertices
Normal × “Vertex count” or 0Normals (only present if “Has normals” flag is set)
u16Index count
u16 × “Index count”Indices
u8Weight group count
Weight group × “Weight group count”Weight groups
Part flags
Bits (MSB to LSB)ValueDescription
7..10Reserved
0Has normals

Vertex

TypeDescription
float[3]XYZ
float[2]UV

Normal

TypeDescription
float[3]XYZ

Weight group

TypeDescription
StringBone name
Weight range × 1…Weight data (terminated by a range with a “Weight count” of 0)

Weight range

TypeDescription
u16Vertices to skip
u16Weight count (0 if last range)
u8 × “Weight count”Weights

Note: Weights in Blender are stored as floats from 0.0 to 1.0. The P3M exporter multiplies each weight by 256 and rounds it. Weights with a value of 0 are omitted and the remaining non-zero weights are decremented by 1. To read in weights, add 1, then divide by 256.0.


Material

TypeValueDescription
u8Material render modeRender mode
u8Texture index (255 for none)
u8Extra texture count
u8 × “Extra texture count”Extra texture indices
u32Texture advance time in microseconds
u8[4]RGBA color
u8[3]RGB emission
u8Shading

Note: The ‘shading’ value determines how directional light is. The lower the value, the more light is evenly distributed.

Material render mode
NameValue
P3M_MATRENDMODE_NORMAL0
P3M_MATRENDMODE_ADD1

Texture

TypeValueDescription
u8Texture typeTexture type
Embedded texture or External textureTexture data
Texture type
NameValue
P3M_TEXTYPE_EMBEDDED0
P3M_TEXTYPE_EXTERNAL1

Embedded texture

TypeValueDescription
u32Data size
u8 × “Data size”PTF textureData

External texture

TypeDescription
StringResource path

Bone

TypeDescription
StringName
float[3]Head XYZ
float[3]Tail XYZ
u8Child count

Animation

TypeDescription
StringName
u8Action count
Animation action × “Action count”Action reference

Animation action

TypeDescription
u8Action index
floatSpeed multiplier
u16Start frame
u16End frame

Action

TypeValueDescription
u32Microseconds per frame
u8Action part list modePart list mode
u8Part list length
String × “Part list length”Part list
u8Action data list length
Action data × “Action data list length”Action data
Action part list mode
NameValue
P3M_ACTPARTLISTMODE_DEFAULTWHITE0
P3M_ACTPARTLISTMODE_DEFAULTBLACK1
P3M_ACTPARTLISTMODE_WHITE2
P3M_ACTPARTLISTMODE_BLACK3

Note: The modes with “DEFAULT” in the name use the part visibility mask instead of starting with all or none.

Action data

TypeValueDescription
StringBone
u8Translation keyframe count
u8Rotation keyframe count
u8Scale keyframe count
u8 × “Translation keyframe count”Translation keyframe frame skips
u8 × “Rotation keyframe count”Rotation keyframe frame skips
u8 × “Scale keyframe count”Scale keyframe frame skips
u8 × “Translation keyframe count”Action interpolation modeTranslation keyframe interpolation modes
u8 × “Rotation keyframe count”Action interpolation modeRotation keyframe interpolation modes
u8 × “Scale keyframe count”Action interpolation modeScale keyframe interpolation modes
float[3] × “Translation keyframe count”XYZ translation keyframes
float[3] × “Rotation keyframe count”XYZ rotation keyframes
float[3] × “Scale keyframe count”XYZ scale keyframes

Note: In Blender, a keyframe’s interpolation type is used to transition from that keyframe to the next. In P3M, a keyframe’s interpolation mode is used to transition from the previous keyframe to that keyframe. The P3M exporter will start with the interpolation mode from the last keyframe before the start of the action. If there are no keyframes before the start of the action, the exporter will start with ‘LINEAR’.

Action interpolation mode
NameValue
P3M_ACTINTERP_NONE0
P3M_ACTINTERP_LINEAR1

String

TypeDescription
u16Offset in string table