---
description: >-
  Documentation of the process to reconstruct an Arma 3 skeleton as an FK
  armature in Blender
---

# Armature reconstruction

## Introduction

Arma 3 has no file formats that can store an armature/skeleton in the sense that modern, more general purpose 3D scene formats like FBX, BLEND (**Blender**'s own project file), USD can. This means that the data has to be distributed distributed accross multiple files:

1. `model.cfg` that contains the skeleton bone hierarchy of the armature to which the animation applies
2. bone pivot points stored in the Memory LOD of a P3D model file, linked in the `model.cfg`

From these two files, we can extract all (or almost all) the necessary information needed to reconstruct the armature.

## Bone hierarchy

The first batch of information we need is having the list of bones in the skeleton, and their bone -> parent hierarchy.

This data can be found in the character `model.cfg` files. Most common skeleton in Arma 3 is the `OFP2_ManSkeleton`, so let's take that as an example.

<figure><img src="https://3093199008-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FW202g4rqtsk2O6cTvlfr%2Fuploads%2F9hSazBINBHMfcoqgm7qu%2Fimage.png?alt=media&#x26;token=6ac70b23-260e-4dca-be36-704194d54540" alt=""><figcaption></figcaption></figure>

The bone list defines how the graph-like skeleton structure is composed.

## Pivot points

<figure><img src="https://3093199008-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FW202g4rqtsk2O6cTvlfr%2Fuploads%2FH5Qqbra5IwBA51LXZpEp%2Fimage.png?alt=media&#x26;token=239715ae-2151-4edf-ac17-68e375b82320" alt="" width="563"><figcaption><p>ManSkeleton_Pivots.p3d from the Arma 3 Samples</p></figcaption></figure>

The pivot points define the positions of the heads of the armature bones, around which the bones rotate. Each position is defined by a vertex in the Memory LOD of the pivot points model file, with each vertex assigned to a unique vertex group, defining the bone it belongs to.

We can extract these points from the binary data in the P3D file.

## Reconstruction

Given the bone hierarchy and the positions of the bones, we can reconstruct the skeleton as an FK armature.

<figure><img src="https://3093199008-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FW202g4rqtsk2O6cTvlfr%2Fuploads%2FQxZqd6jiMxRJJYuKBfwU%2Fimage.png?alt=media&#x26;token=e5199063-b116-4772-b368-ca744255e849" alt=""><figcaption><p>OFP2_ManSkeleton partially reconstructed from the Arma 3 Samples (the included pivots model is incomplete)</p></figcaption></figure>

For every bone in the hierarchy:

1. Create a bone with the head-end at the associated pivot point
2. Find the pivots of children bones (if any)
3. Move tail-end of bone
   * If bone has no children, leave the bone vertical (not necessary, but the easiest to automate)
   * If bone has exactly 1 child, move the tail to the pivot of the child
   * If bone has multiple children, move the tail to the average point of the pivots of the children

{% hint style="info" %}
It's possible that the pivot model might be missing the pivot point for one or more bones. In that case we can either skip those bones, or create them at a default location, and position them manually later.
{% endhint %}

After every bone is created, we can set up the parenting relations. Every bone needs to have its parent set. It's recommended that the tail-end of bones with exactly 1 child is connected to the head-end of that child, in order to make posing easier.

{% hint style="info" %}
Due to the nature of how Arma 3 RTM animation files store the animation transformation, as long as the bone heads are in the correct places, the rotational orientation of the bones in the rest position doesn't actually matter. Because of this, the bones can be rotated in any way to make posing easier (as long as the heads are not moved).
{% endhint %}
