Skip to content

ModelBone

Chuck Walbourn edited this page Sep 29, 2021 · 10 revisions

This class is part of the Model hierarchy. The purpose of this structure is to define a hierarchy of transformation matrices used for rigid-body animation, skinning animation, or as metadata for locations associated with a model for runtime insertion of dynamic lights, particle effects, etc.

The use of ModelBone is optional and the Model::bones array an therefore be empty.

Header

#include <Model.h>

Initialization

The ModelBone array bones is typically created by a Model loader along with the ModelMesh instances that contain the submeshes. By default the loader ignores any frames (SDKMESH) or bones (CMO) found in the file. Providing the ModelLoader_IncludeBones flag will result in any bones present in the model file being loaded.

Type aliases

ModelBone::Collection is an alias for std::vector<ModelBone>.

ModelBone::TransformArray is an alias for std::unique_ptr<XMMATRIX[], aligned_deleter>.

Transform arrays

ModelBone::TransformArray instances are created using the static method ModelBone::MakeArray. This memory is always allocated using _aligned_malloc with 16-byte alignment to meet the requirements for SIMD.

auto bones = ModelBone::MakeArray(model->bones.size());

Data

A ModelBone instance contains a name (a wide-character string) typically used for matching up bones with animation keys.

Each bone contains three pointers:

  • parentIndex is the index of the parent of this bone (or ModelBone::c_Invalid if it has no parent).
  • childIndex is the index of the child of this bone (or ModelBone::c_Invalid if it has no children).
  • siblingIndex is the index of the next sibling of this bone (or ModelBone::c_Invalid if it has no siblings).

These pointers are used to form a tree hierarchy. The 0th bone in a Model is the root and should have a parentIndex of ModelBone::c_Invalid.

Note that bones must form an acyclic graph.

Remarks

The XNA Game Studio ModelBone design relied on the fact that the Content Pipeline always sorted the bone array in a particular way. This uses a more complex tree graph structure to support SDKMESH and CMO which may not meet these sorting requirements.

There is no explicit root bone in a Model in DirectX Tool Kit. By convention, the 0th bone is the root.

For Use

  • Universal Windows Platform apps
  • Windows desktop apps
  • Windows 11
  • Windows 10
  • Windows 8.1
  • Xbox One

Architecture

  • x86
  • x64
  • ARM64

For Development

  • Visual Studio 2022
  • Visual Studio 2019 (16.11)
  • clang/LLVM v12 - v18
  • MinGW 12.2, 13.2
  • CMake 3.20

Related Projects

DirectX Tool Kit for DirectX 12

DirectXMesh

DirectXTex

DirectXMath

Win2D

Tools

Test Suite

Model Viewer

Content Exporter

DxCapsViewer

Clone this wiki locally