Yes, I sometimes get stuck on the easy stuff. Here's my code, if anyone is as inept at maths as me and needs it:
// Decompose the bone head world matrix.
XMVECTOR boneHeadScale, boneHeadRotation, boneHeadPosition;
if (!XMMatrixDecompose(&boneHeadScale, &boneHeadRotation, &boneHeadPosition, worldMatrix))
Log::Warn(L"Failed to decompose bone world matrix.");
// Create the mid-point in local space.
XMVECTOR midPoint = XMVectorSet(0.0f, m_Bones[i].HalfLength, 0.0f, 0.0f);
// Transform the mid-point to world space.
midPoint = XMVector3TransformNormal(midPoint, worldMatrix) + boneHeadPosition;
// Construct the bounding volume world matrix.
worldMatrix = XMMatrixTransformation(XMVectorZero(), XMQuaternionIdentity(), boneHeadScale,
XMVectorZero(), boneHeadRotation, midPoint);
The ragdoll currently looks like this:
I was thinking of letting the artist define the bone volume "width" and "height" in the 3d editor, however I'm now thinking I should be able to automate this too - I should be able to just to min/max calculations on all of the vertices in each bone's vertex group to calculate the volume. Anyone tried this before, or should I just let the artist define the rest?