Skinning Bone Attachments

This topic contains 2 replies, has 2 voices, and was last updated by  Gordon 8 years, 3 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #29866

    zibba
    Member

    Hi

    I’m using the training course OGLESSkinning to render an animating character using the matrix palette and bone batches. I’m trying to figure out how to attach another object to the character’s hand. I thought inside the render loop, I could grab the world matrix and use that to transform the attached object, but it’s not working how I imagined, thus:

    Code:
    //     Iterate through all the bones in the batch

    for (int j = 0; j < pMesh->sBoneBatches.pnBatchBoneCnt[i32Batch]; ++j)

    {

         /*

              Set the current matrix palette that we wish to change. An error

              will be returned if the index (j) is not between 0 and

              GL_MAX_PALETTE_MATRICES_OES. The value of GL_MAX_PALETTE_MATRICES_OES

              can be retrieved using glGetIntegerv, the initial value is 9.

              GL_MAX_PALETTE_MATRICES_OES does not mean you need to limit

              your character to 9 bones as you can overcome this limitation

              by using bone batching which splits the mesh up into sub-meshes

              which use only a subset of the bones.

         */

         extensions.glCurrentPaletteMatrixOES(j);

         // Generates the world matrix for the given bone in this batch.

         i32NodeID = pMesh->sBoneBatches.pnBatches[i32Batch * pMesh->sBoneBatches.nBatchBoneMax + j];

         scene.GetBoneWorldMatrix(mBoneWorld, *pNode, scene.pNode[i32NodeID]);

         // Multiply the bone’s world matrix by the view matrix to put it in view space

         mBoneWorld = viewmat * mBoneWorld;

            // here we’d set the transform matrix on the attached object, e.g.

         if (i32Batch == boneBatch && j == boneAttach)

         {

              if (attached)

              {

                   attached->setParentMatrix(mBoneWorld);

              }

         }

         

         // Load the bone matrix into the current palette matrix.

         myglLoadMatrix(mBoneWorld.f);

    Is this the correct matrix to pull out, or do I have to do a further transform?

    regards

    #33274

    zibba
    Member

    Ah this is wrong. What do is get the matrix from the node e.g

    Code:
    PVRTMat4 mat;

    scene.GetWorldMatrix(mat, scene.pNode[some_node_eg_hand]);

    Then transform the attachment object by the parent’s position and rotation, and mat.

    #33275

    Gordon
    Moderator

    We’re hoping to improve the documentation for the POD format (amongst other things) for a future release so this should be more clear for others – glad you worked it out.

Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic.