void UString::reserve( uint num ) { if ( !num ) num = 1; if ( !d || d->max < num ) reserve2( num ); }
// создать финальные матрицы для шейдера void AnimModel::CreateFinalMatricesOldStyle(UINT clipNumber, UINT frameNumber, XMFLOAT4X4* finalMatrices) { // без смешивания клипов по древнему алгоритму (для отладки) // загрузка матриц std::vector<XMFLOAT4X4> reserve(bonesAmount); std::vector<XMFLOAT4X4> reserve2(bonesAmount); for (UINT i(0); i < bonesAmount; i++) { XMFLOAT3 position = clips[clipNumber].bonesPositions[i + bonesAmount * frameNumber]; XMMATRIX T = XMMatrixTranslation(position.x, position.y, position.z); XMFLOAT4 quaternion = clips[clipNumber].bonesQuaternions[i + bonesAmount * frameNumber]; XMMATRIX R = XMMatrixRotationQuaternion(XMLoadFloat4(&quaternion)); XMStoreFloat4x4(&reserve[i], R * T); XMStoreFloat4x4(&reserve2[i], R * T); } // перемножение матриц для получения final for (UINT i(0); i < bonesAmount; i++) { XMMATRIX fin = XMMatrixIdentity(); UINT curMatrix = i; fin = fin * XMLoadFloat4x4(&reserve[curMatrix]); while (curMatrix != -1) { curMatrix = hierarchy[curMatrix]; if (curMatrix == -1) break; fin = fin * XMLoadFloat4x4(&reserve[curMatrix]); } XMMATRIX offSet = XMLoadFloat4x4(&offsetMatrices[i]); XMStoreFloat4x4(&finalMatrices[i], offSet * fin); } }