Imagination PowerVR SDK Blog

Skinning Bone Attachments


#1

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


#2

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.




#3

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.