0

Ive は iqe (Inter Quake Exporter) 形式の解析に成功しましたが、今は bindpose での表示に固執しています。

すべての頂点には奇妙な変換があり、ルート ボーン (向きのために完全なメッシュをカバーする) がその頂点に影響を与える唯一のボーンではありません。メッシュの腕・肩・首部分に見られます。このメッシュには 3 つのボーンがあります。メッシュ全体を覆う 1 つのルート ボーンと 2 つのアーム ボーン。バックグラウンドでメッシュがどのように見えるかを確認できます (obj としてエクスポート) ここに画像の説明を入力

理解を深めるために、次のシステムがあります。

1.すべての頂点データを 1 つの大きな vbo (頂点、UV、法線、タンジェント、バイタンジェント、boneIndicies(4) (ジョイント リストのインデックス)、および boneWeights(4)) にロードします。

2.すべてのジョイントをジョイント リストに追加し、ツリー システムを作成します (位置、回転、および親ポインタを含む単純なリンク リスト)。

3.ボーンマトリックスと呼ばれる個別のリストがあり、ここにボーンマトリックスが格納されています。現在はすべてのフレームですが、後で各アニメーション フレームの行列を事前に計算します。

次の方法で骨マトリックスを計算しようとします。

    for (int i = 0; i < this->jointList.size(); i++)
    {
        pixel::CJoint *joint = this->jointList.at(i);


        std::cout << "Joint ------- " << joint->name << " -------- values: \n";
        std::cout << "Translation: " << joint->position.x << " " << joint->position.y << " " << joint->position.z << "\n";
        std::cout << "Quaternion: " << joint->rotation.x << " " << joint->rotation.y << " " << joint->rotation.z << " " << joint->rotation.w << "\n";


        pixel::matrix4 rotation = pixel::CMatrix::fromQuaternion(joint->rotation);
        pixel::matrix4 offset = pixel::CMatrix::translateMatrix(joint->position);
        pixel::matrix4 baseMatrix = rotation * offset; // translation * rotation


        joint->bindPose = baseMatrix;
        joint->invBindPose = pixel::CMatrix::inverseMatrix(baseMatrix);

        if (joint->parent != NULL)
        {
            std::cout << "Joint: " << joint->name << " is child of " << joint->parent->name << " \n";
            joint->bindPose = joint->bindPose * joint->parent->invBindPose;
            joint->invBindPose = pixel::CMatrix::inverseMatrix(joint->bindPose);
        }


        std::cout << "\n";
    }

転置されたジョイント (そうでなければメッシュが逆さまになる) を boneMatrices に格納し、それをシェーダーに送信します。

boneMatrix は、matrix4 の std::vector です

this->material.setParameter("boneMatrix", this->boneMatrices.at(0), this->boneMatrices.size());

ルート ボーン バインドの計算は正しくなければなりません (少なくとも私はそう思います)。これは、頭が適切な場所にあり、目も (現時点ではボーンの影響を受けていないため) あるためです。

4

0 に答える 0