   Help with Bones and Bounding box
  Hi all.Im trying to make a bounding box for each of the Tiny.x bones, but the bounding boxes look's like, there way to big,  look at Image Is this the way I should be creating the boxGetBoundingBoxSize(D3DFRAME_EX *pFrame,    D3DXMESHCONTAINER_EX *pMesh,    D3DXVECTOR3 *vecSize,    D3DXVECTOR3 *vecJointOffset){  // Set default min and max coordinates  D3DXVECTOR3 vecMin = D3DXVECTOR3(0.0f, 0.0f, 0.0f);  D3DXVECTOR3 vecMax = D3DXVECTOR3(0.0f, 0.0f, 0.0f);  // Only process bone vertices if there is a bone to work with  if(pFrame->Name)   {    // Get a pointer to ID3DXSkinInfo interface for    // easier handling.    ID3DXSkinInfo *pSkin = pMesh->pSkinInfo;    // Search for a bone by same name as frame    DWORD BoneNum = -1;    for(DWORD i=0;i<pSkin->GetNumBones();i++) {if(!strcmp(pSkin->GetBoneName(i), pFrame->Name)) {BoneNum = i;break; }    } // Process vertices if a bone was found    if(BoneNum != -1) { // Get the number of vertices attached DWORD NumVertices = pSkin->GetNumBoneInfluences(BoneNum); if(NumVertices)   {   // Get the bone influcences   DWORD *Vertices = new DWORD[NumVertices];   float *Weights  = new float[NumVertices];   pSkin->GetBoneInfluence(BoneNum, Vertices, Weights);D3DVERTEXELEMENT9 elems[MAX_FVF_DECL_SIZE];HRESULT hr = pMesh->MeshData.pMesh->GetDeclaration(elems);if(FAILED(hr)){MessageBox(NULL,"Failed To GetDeclaraction", "cRagdoll::GetBoundingBoxSize()", MB_OK);}   // Get stride of vertex dataDWORD Stride = D3DXGetDeclVertexSize(elems, 0);//D3DXGetFVFVertexSize(pMesh->MeshData.pMesh->GetFVF());   // Get bone's offset inversed transformation matrix   D3DXMATRIX *matInvBone = pSkin->GetBoneOffsetMatrix(BoneNum);   // Lock vertex buffer and go through all of   // the vertices that are connected to bone   //BYTE *pVertices;VertexBlend *pVertices;   pMesh->MeshData.pMesh->LockVertexBuffer(D3DLOCK_READONLY, (void**)&pVertices);   for(int i=0;i<NumVertices;i++) {//if(Weights > 0.000022f && Weights < 1.0f){// Get pointer to vertex coordinatesD3DXVECTOR3 vecPtr = pVertices[Vertices].pos;//D3DXVECTOR3 *vecPtr = (D3DXVECTOR3*)(pVertices+Vertices*Stride);vecPtr = vecPtr *0.5f;// Transform vertex by bone offset transformationD3DXVECTOR3 vecPos;D3DXVec3TransformCoord(&vecPos, &vecPtr, matInvBone);    // Get min/max valuesvecMin.x = min(vecMin.x, vecPos.x);vecMin.y = min(vecMin.y, vecPos.y);vecMin.z = min(vecMin.z, vecPos.z);vecMax.x = max(vecMax.x, vecPos.x);vecMax.y = max(vecMax.y, vecPos.y);vecMax.z = max(vecMax.z, vecPos.z);}   }   pMesh->MeshData.pMesh->UnlockVertexBuffer();   // Free resource   delete [] Vertices;   delete [] Weights; }    }  }  // Factor in child bone connection points to size  if(pFrame->pFrameFirstChild)   { // Get the bone's inverse transformation to// position child connections.    D3DXMATRIX matInvFrame;    D3DXMatrixInverse(&matInvFrame,NULL,&pFrame->ToRoot); // Go through all child frames connected to this frame    D3DFRAME_EX *pFrameChild = (D3DFRAME_EX*)pFrame->pFrameFirstChild;    while(pFrameChild) { // Get the frame's vertex coordinates and transform it D3DXVECTOR3 vecPos; vecPos = D3DXVECTOR3(pFrameChild->ToRoot._41,//matCombined  pFrameChild->ToRoot._42,  pFrameChild->ToRoot._43); D3DXVec3TransformCoord(&vecPos, &vecPos, &matInvFrame); // Get min/max values vecMin.x = min(vecMin.x, vecPos.x); vecMin.y = min(vecMin.y, vecPos.y); vecMin.z = min(vecMin.z, vecPos.z); vecMax.x = max(vecMax.x, vecPos.x); vecMax.y = max(vecMax.y, vecPos.y); vecMax.z = max(vecMax.z, vecPos.z); // Go to next child bone pFrameChild = (D3DFRAME_EX*)pFrameChild->pFrameSibling;    }  }////////////////////////////////////////////////////////////////////////////////////////////////////////  // Set the bounding box size  vecSize->x = (float)fabs(vecMax.x - vecMin.x);  vecSize->y = (float)fabs(vecMax.y - vecMin.y);  vecSize->z = (float)fabs(vecMax.z - vecMin.z);  // Make sure each bone has a minimal size  if(vecSize->x < MINIMUM_BONE_SIZE)   {    vecSize->x = MINIMUM_BONE_SIZE;vecMax.x = MINIMUM_BONE_SIZE*0.5f;  }  if(vecSize->y < MINIMUM_BONE_SIZE)   {    vecSize->y = MINIMUM_BONE_SIZE;vecMax.y = MINIMUM_BONE_SIZE*0.5f;  }  if(vecSize->z < MINIMUM_BONE_SIZE)   {    vecSize->z = MINIMUM_BONE_SIZE;vecMax.z = MINIMUM_BONE_SIZE*0.5f;  }  // Set the bone's offset to center based on half the size   // of the bounding box and the max position  (*vecJointOffset) = ((*vecSize) * 0.5f) - vecMax;}//end////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Or should I make a new low res mesh, will need to have one later for Collisions   
  Can you show the code where you draw the bounding box too?   ;  For some reason I cant copy and past code[Edited by - ankhd on April 19, 2008 10:31:39 PM];;  I think you're being bitten by a forum bug. Try pasting the code on a pastebin site (such as this one) and posting the link to the results here instead.   