I know it's old. But I need to complete some tasks before upgrading. So please bear with me If I use this code snippet to parse the x frame hierarchy
void MeshX::ParseParents(/*FRAME* root, FRAME* parent, FRAME* pCurFrame*/)
{
// get all first child first, then the first child's
FRAME* pCurFrame = (FRAME*)m_pFrameRoot;
LPD3DXMESHCONTAINER pCurMesh;
stack st;
st.push(pCurFrame);
while (!st.empty())
{
pCurFrame = st.top();
st.pop();
if (pCurFrame != NULL)
{
FRAME* p = (FRAME*)pCurFrame;
FRAME* c = (FRAME*)pCurFrame->pFrameFirstChild;
FRAME* s = (FRAME*)pCurFrame->pFrameSibling;
if (c && p->Id < m_frames.size())
_linkFrame(p->Id, c->Id, -1);
if (s && p->Id < m_frames.size())
_linkFrame(p->Id, -1, s->Id);
st.push((FRAME*)pCurFrame->pFrameFirstChild);
st.push((FRAME*)pCurFrame->pFrameSibling);
}
}
}
void MeshX::_linkFrame(BONE_ID parentFrameId, BONE_ID childFrameId, BONE_ID siblingID)
{
if (parentFrameId != -1 && childFrameId != -1)
{
m_frames[parentFrameId].childId = childFrameId;
m_frames[childFrameId].parentId = parentFrameId;
}
else if (parentFrameId != -1 && siblingID != -1)
{
m_frames[parentFrameId].siblingId = siblingID;
//m_frames[siblingID].parentId = parentFrameId;
}
}
I will get these
0 Bip001 no parent Bip001_Pelvis Body01
1 Bip001_Pelvis Bip001 Bip001_Spine no sibling
2 Bip001_Spine Bip001_Pelvis Bip001_Spine1 Bip001_L_Thigh
3 Bip001_Spine1 Bip001_Spine Bip001_Spine2 no sibling
4 Bip001_Spine2 Bip001_Spine1 Bip001_Spine3 no sibling
5 Bip001_Spine3 Bip001_Spine2 Bip001_Neck no sibling
6 Bip001_Neck Bip001_Spine3 Bip001_Head Bip001_L_Clavicle
7 Bip001_Head Bip001_Neck no child no sibling
8 Bip001_L_Clavicle no parent Bip001_L_UpperArm Bip001_R_Clavicle
9 Bip001_L_UpperArm Bip001_L_Clavicle Bip001_L_Forearm no sibling
10 Bip001_L_Forearm Bip001_L_UpperArm Bip001_L_Hand no sibling
11 Bip001_L_Hand Bip001_L_Forearm Bip001_L_Finger0 no sibling
12 Bip001_L_Finger0 Bip001_L_Hand no child no sibling
13 Bip001_R_Clavicle no parent Bip001_R_UpperArm no sibling
14 Bip001_R_UpperArm Bip001_R_Clavicle Bip001_R_Forearm no sibling
15 Bip001_R_Forearm Bip001_R_UpperArm Bip001_R_Hand no sibling
16 Bip001_R_Hand Bip001_R_Forearm Bip001_R_Finger0 no sibling
17 Bip001_R_Finger0 Bip001_R_Hand no child no sibling
18 Bip001_L_Thigh no parent Bip001_L_Calf Bip001_R_Thigh
19 Bip001_L_Calf Bip001_L_Thigh Bip001_L_Foot no sibling
20 Bip001_L_Foot Bip001_L_Calf Bip001_L_Toe0 no sibling
21 Bip001_L_Toe0 Bip001_L_Foot Bip001_L_Toe01 no sibling
22 Bip001_L_Toe01 Bip001_L_Toe0 Bip001_L_Toe02 no sibling
23 Bip001_L_Toe02 Bip001_L_Toe01 no child no sibling
24 Bip001_R_Thigh no parent Bip001_R_Calf no sibling
25 Bip001_R_Calf Bip001_R_Thigh Bip001_R_Foot no sibling
26 Bip001_R_Foot Bip001_R_Calf Bip001_R_Toe0 no sibling
27 Bip001_R_Toe0 Bip001_R_Foot Bip001_R_Toe01 no sibling
28 Bip001_R_Toe01 Bip001_R_Toe0 Bip001_R_Toe02 no sibling
29 Bip001_R_Toe02 Bip001_R_Toe01 no child no sibling
30 Body01 no parent no child no sibling
Assuming nothing wrong with the x file. You can see Bip001_L_Clavicle,
Bip001_R_Clavicle has no parents But their parents are supposed to be Bip001_Spine3
I test it in some other parser, it does indicate that
And Bip001_L_Thigh and R_Thigh should get the parent of Bip001_Pelvis
Any ideas how to fix this?
Thanks
Jack