void RagDoll::InitRagdoll() { Release(); InitBones((Bone*)m_pRootBone); Bone* Head_End = (Bone*)D3DXFrameFind(m_pRootBone, "Head_End"); Bone* Head = (Bone*)D3DXFrameFind(m_pRootBone, "Head"); Bone* Neck = (Bone*)D3DXFrameFind(m_pRootBone, "Neck"); Bone* Pelvis = (Bone*)D3DXFrameFind(m_pRootBone, "Pelvis"); Bone* Spine = (Bone*)D3DXFrameFind(m_pRootBone, "Spine"); Bone* R_Shoulder = (Bone*)D3DXFrameFind(m_pRootBone, "Shoulder_Right"); Bone* L_Shoulder = (Bone*)D3DXFrameFind(m_pRootBone, "Shoulder_Left"); Bone* U_R_Arm = (Bone*)D3DXFrameFind(m_pRootBone, "Upper_Arm_Right"); Bone* U_L_Arm = (Bone*)D3DXFrameFind(m_pRootBone, "Upper_Arm_Left"); Bone* L_R_Arm = (Bone*)D3DXFrameFind(m_pRootBone, "Lower_Arm_Right"); Bone* L_L_Arm = (Bone*)D3DXFrameFind(m_pRootBone, "Lower_Arm_Left"); Bone* R_Hand = (Bone*)D3DXFrameFind(m_pRootBone, "Hand_Right"); Bone* L_Hand = (Bone*)D3DXFrameFind(m_pRootBone, "Hand_Left"); Bone* R_Pelvis = (Bone*)D3DXFrameFind(m_pRootBone, "Pelvis_Right"); Bone* L_Pelvis = (Bone*)D3DXFrameFind(m_pRootBone, "Pelvis_Left"); Bone* R_Thigh = (Bone*)D3DXFrameFind(m_pRootBone, "Thigh_Right"); Bone* L_Thigh = (Bone*)D3DXFrameFind(m_pRootBone, "Thigh_Left"); Bone* R_Calf = (Bone*)D3DXFrameFind(m_pRootBone, "Calf_Right"); Bone* L_Calf = (Bone*)D3DXFrameFind(m_pRootBone, "Calf_Left"); Bone* R_Foot = (Bone*)D3DXFrameFind(m_pRootBone, "Foot_Right"); Bone* L_Foot = (Bone*)D3DXFrameFind(m_pRootBone, "Foot_Left"); Bone* R_Foot_End = (Bone*)D3DXFrameFind(m_pRootBone, "Foot_Right_End"); Bone* L_Foot_End = (Bone*)D3DXFrameFind(m_pRootBone, "Foot_Left_End"); D3DXQUATERNION q, q2; D3DXQuaternionIdentity(&q); D3DXQuaternionRotationAxis(&q2, &D3DXVECTOR3(0.0f, 0.0f, 1.0f), D3DX_PI * -0.5f); //Head OBB* o01 = CreateBoneBox(Head, Head_End, D3DXVECTOR3(0.3f, 0.2f, 0.2f), q); //Right Arm OBB* o03 = CreateBoneBox(U_R_Arm, L_R_Arm, D3DXVECTOR3(0.3f, 0.12f, 0.12f), q); OBB* o04 = CreateBoneBox(L_R_Arm, R_Hand, D3DXVECTOR3(0.3f, 0.12f, 0.12f), q); //Left Arm OBB* o06 = CreateBoneBox(U_L_Arm, L_L_Arm, D3DXVECTOR3(0.3f, 0.12f, 0.12f), q); OBB* o07 = CreateBoneBox(L_L_Arm, L_Hand, D3DXVECTOR3(0.3f, 0.12f, 0.12f), q); //Spine OBB* o08 = CreateBoneBox(Spine, Neck, D3DXVECTOR3(0.5f, 0.35f, 0.15f), q); //Right Leg OBB* o09 = CreateBoneBox(R_Thigh, R_Calf, D3DXVECTOR3(0.4f, 0.15f, 0.15f), q); OBB* o10 = CreateBoneBox(R_Calf, R_Foot, D3DXVECTOR3(0.4f, 0.14f, 0.14f), q); OBB* o11 = CreateBoneBox(R_Foot, R_Foot_End, D3DXVECTOR3(0.15f, 0.06f, 0.12f), q2); //Left Leg OBB* o12 = CreateBoneBox(L_Thigh, L_Calf, D3DXVECTOR3(0.4f, 0.15f, 0.15f), q); OBB* o13 = CreateBoneBox(L_Calf, L_Foot, D3DXVECTOR3(0.4f, 0.14f, 0.14f), q); OBB* o14 = CreateBoneBox(L_Foot, L_Foot_End, D3DXVECTOR3(0.15f, 0.06f, 0.12f), q2); //Constraints CreateTwistCone(Neck, o01, o08, D3DX_PI * 0.15f, D3DXVECTOR3(0.0f, 0.0f, D3DX_PI * 0.5f), D3DXVECTOR3(0.0f, 0.0f, D3DX_PI * 0.5f)); CreateTwistCone(L_Pelvis, o08, o12, D3DX_PI * 0.5f, D3DXVECTOR3(0.3f, D3DX_PI * 0.5f, -D3DX_PI * 0.5f), D3DXVECTOR3(0.0f, 0.0f, D3DX_PI * 0.5f)); CreateHinge(L_Calf, o12, o13, 0.0f, -2.0f, D3DXVECTOR3(0.0f, 0.0f, D3DX_PI * 0.5f), D3DXVECTOR3(0.0f, 0.0f, D3DX_PI * 0.5f)); CreateHinge(L_Foot, o13, o14, 1.5f, 1.0f, D3DXVECTOR3(0.0f, 0.0f, D3DX_PI * 0.5f), D3DXVECTOR3(0.0f, 0.0f, D3DX_PI * 0.5f)); CreateTwistCone(R_Pelvis, o08, o09, D3DX_PI * 0.5f, D3DXVECTOR3(0.3f, D3DX_PI * 0.5f, -D3DX_PI * 0.5f), D3DXVECTOR3(0.0f, 0.0f, D3DX_PI * 0.5f)); CreateHinge(R_Calf, o09, o10, 0.0f, -2.0f, D3DXVECTOR3(0.0f, 0.0f, D3DX_PI * 0.5f), D3DXVECTOR3(0.0f, 0.0f, D3DX_PI * 0.5f)); CreateHinge(R_Foot, o10, o11, 1.5f, 1.0f, D3DXVECTOR3(0.0f, 0.0f, D3DX_PI * 0.5f), D3DXVECTOR3(0.0f, 0.0f, D3DX_PI * 0.5f)); CreateTwistCone(U_L_Arm, o08, o06, D3DX_PI * 0.6f, D3DXVECTOR3(0.0f, D3DX_PI * 0.75f, D3DX_PI * 0.0f), D3DXVECTOR3(0.0f, 0.0f, 0.0f)); CreateHinge(L_L_Arm, o06, o07, 2.0f, 0.0f, D3DXVECTOR3(0.0f, 0.0f, D3DX_PI * 0.5f), D3DXVECTOR3(0.0f, 0.0f, D3DX_PI * 0.5f)); CreateTwistCone(U_R_Arm, o08, o03, D3DX_PI * 0.6f, D3DXVECTOR3(0.0f, D3DX_PI * 0.75f, D3DX_PI * 0.0f), D3DXVECTOR3(D3DX_PI, 0.0f, 0.0f)); CreateHinge(L_R_Arm, o03, o04, 2.0f, 0.0f, D3DXVECTOR3(0.0f, 0.0f, -D3DX_PI * 0.5f), D3DXVECTOR3(0.0f, 0.0f, -D3DX_PI * 0.5f)); //Assign Pelvis bone to Spine OBB Pelvis->m_pObb = o08; D3DXVECTOR3 PelvisPos(Pelvis->CombinedTransformationMatrix(3, 0), Pelvis->CombinedTransformationMatrix(3, 1), Pelvis->CombinedTransformationMatrix(3, 2)); Pelvis->m_pivot = o08->SetPivot(PelvisPos); }