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